diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..4a246ec6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +Dockerfile +.dockerignore diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..f8ace134 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +# VERSION 1.0.0 +# AUTHOR: Diego Rabatone Oliveira (@diraol) +# DESCRIPTION: Image used to test python-mode +# BUILD: Use the build_docker_images.sh file +# docker build -t python-mode: -f Dockerfile --build-arg PYTHON= . +# SOURCE: https://github.com/python-mode/python-mode +ARG PYTHON +FROM python:$PYTHON + +# Passing arg inside the build stage +ARG PYTHON + +# Never prompts the user for choices on installation/configuration of packages +ENV DEBIAN_FRONTEND noninteractive +ENV TERM linux + +# https://docs.python.org/3.6/using/cmdline.html#envvar-PYTHONUNBUFFERED +# https://github.com/sclorg/s2i-python-container/issues/157 +ENV PYTHONUNBUFFERED 1 + +# Clonning and building VIM for the specific python version +COPY ./tests/utils/build_vim.sh /opt/build_vim.sh +RUN set -ex \ + && cd /opt \ + && chmod +x build_vim.sh \ + && git clone https://github.com/vim/vim.git \ + && ./build_vim.sh ${PYTHON} \ + && rm -rf vim build_vim.sh + +ENV PYTHON_MODE_HOME /root/.vim/pack/foo/start/python-mode/ +ENV VIM_RC /root/.vimrc +ENV PYMODE_RC /root/.pymoderc +ENV TEST_FILE /root/test.py + +COPY . ${PYTHON_MODE_HOME} +RUN set -ex \ + && cd ${PYTHON_MODE_HOME} \ + && find . -type f -name '*.pyc' -delete \ + && find . -type d -name '__pycache__' -delete \ + && ln -s ${PYTHON_MODE_HOME}tests/utils/test.py ${TEST_FILE} \ + && ln -s ${PYTHON_MODE_HOME}tests/utils/pymoderc ${PYMODE_RC} \ + && ln -s ${PYTHON_MODE_HOME}tests/utils/vimrc ${VIM_RC} \ + && touch /root/.vimrc.before /root/.vimrc.after + +RUN set -ex && vim -e -s -c ':exec ":helptags ALL" | exec ":qall!"' + +WORKDIR /root +ENTRYPOINT ["/bin/bash"] diff --git a/build_docker_images.sh b/build_docker_images.sh new file mode 100755 index 00000000..961db554 --- /dev/null +++ b/build_docker_images.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +for VER in 2.7 3.5 3.6 3.7 3.7.1 +do + docker build -t python-mode:${VER} --build-arg PYTHON=${VER} -f Dockerfile . +done diff --git a/readme.md b/readme.md index 47660e45..39eb2c02 100644 --- a/readme.md +++ b/readme.md @@ -188,6 +188,22 @@ Please, also provide more contextual information such as: * `git status` (under your _python-mode_ directory) * `tree ` or something similar (such as `ls -lR`) +## Docker environment +Now you can try python-mode within a docker container, with a python-version +from your choice and a vim built for that python version. + +To build the docker images you should use the script `build_docker_images.sh` +that is located on the root of this repo. + +To run the container for a specific version, after building it, you can do: + +`docker run --rm -it python-mode:` + +* PYTHON\_VERSION can be 2.7, 3.7, etc. + +If you do not want the container to be removed after you exit it, just remove +the `--rm` from the command above. + # Frequent problems Read this section before opening an issue on the tracker. diff --git a/tests/utils/build_vim.sh b/tests/utils/build_vim.sh new file mode 100644 index 00000000..92ef282b --- /dev/null +++ b/tests/utils/build_vim.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e +SPACER="#####################################################################" + +PYTHON=$1 +echo "Python version: ${PYTHON}" + +cd /opt/vim + +args=( ) +# args+=( --with-features=huge ) +args+=( --enable-multibyte ) +args+=( --enable-cscope ) + +PYTHON_CONFIG_DIR=$(find /usr -type d -name 'config*' | grep python | grep -v dist-packages) + +if [[ ${PYTHON} =~ ^2 ]]; then + args+=( --enable-pythoninterp=yes ) + args+=( --with-python-config-dir=${PYTHON_CONFIG_DIR} ) +else + args+=( --enable-python3interp=yes ) + args+=( --with-python3-config-dir=${PYTHON_CONFIG_DIR} ) +fi + +args+=( --prefix=/usr/local ) + +echo ${SPACER} +echo Starting build with args: ${args[@]} +echo ${SPACER} + +./configure ${args[@]} + +make + +make install + +echo ${SPACER} +echo vim installed with config args: ${args[@]} +echo ${SPACER} diff --git a/tests/utils/reset_update_repo.sh b/tests/utils/reset_update_repo.sh new file mode 100644 index 00000000..43622f2d --- /dev/null +++ b/tests/utils/reset_update_repo.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +git reset --hard HEAD +git checkout origin develop +git pull origin develop +git submodule sync --recursive +git submodule update --init --recursive