Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Dockerfile
.dockerignore
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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:<VER> -f Dockerfile --build-arg PYTHON=<VER> .
# 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"]
6 changes: 6 additions & 0 deletions build_docker_images.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ If your question is not described there then you already know what to do
Nevertheless just a refresher on how to submit bugs:

**(From the FAQ)**

Clear all python cache/compiled files (`*.pyc` files and `__pycache__`
directory and everything under it). In Linux/Unix/MacOS you can run:

Expand All @@ -160,6 +161,22 @@ plugin seems broken.

***Do check for sensitive information in the file before submitting.***

## 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>`

* 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.
Expand Down
39 changes: 39 additions & 0 deletions tests/utils/build_vim.sh
Original file line number Diff line number Diff line change
@@ -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}
90 changes: 90 additions & 0 deletions tests/utils/pymoderc
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
" These are all pymode configs. You can read about them using :help pymode
let g:pymode = 1
let g:pymode_warnings = 1
let g:pymode_paths = []
let g:pymode_trim_whitespaces = 1
let g:pymode_options = 1
let g:pymode_options_max_line_length = 79
let g:pymode_options_colorcolumn = 1
let g:pymode_quickfix_minheight = 3
let g:pymode_quickfix_maxheight = 6
let g:pymode_indent = 1
let g:pymode_folding = 0
let g:pymode_motion = 1
let g:pymode_doc = 1
let g:pymode_doc_bind = 'K'
let g:pymode_virtualenv = 1
let g:pymode_virtualenv_path = $VIRTUAL_ENV
let g:pymode_run = 1
let g:pymode_run_bind = '<leader>r'
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_bind = '<leader>b'
let g:pymode_breakpoint_cmd = ''
let g:pymode_lint = 1
let g:pymode_lint_on_write = 1
let g:pymode_lint_unmodified = 0
let g:pymode_lint_on_fly = 0
let g:pymode_lint_message = 1
let g:pymode_lint_checkers = ['pyflakes', 'pep8', 'mccabe']
let g:pymode_lint_ignore = ["E501", "W",]
let g:pymode_lint_select = ["E501", "W0011", "W430"]
let g:pymode_lint_sort = []
let g:pymode_lint_cwindow = 1
let g:pymode_lint_signs = 1
let g:pymode_lint_todo_symbol = 'WW'
let g:pymode_lint_comment_symbol = 'CC'
let g:pymode_lint_visual_symbol = 'RR'
let g:pymode_lint_error_symbol = 'EE'
let g:pymode_lint_info_symbol = 'II'
let g:pymode_lint_pyflakes_symbol = 'FF'
let g:pymode_lint_options_pep8 =
\ {'max_line_length': g:pymode_options_max_line_length}
let g:pymode_lint_options_pyflakes = { 'builtins': '_' }
let g:pymode_lint_options_mccabe = { 'complexity': 12 }
let g:pymode_lint_options_pep257 = {}
let g:pymode_lint_options_pylint =
\ {'max-line-length': g:pymode_options_max_line_length}
let g:pymode_rope = 1
let g:pymode_rope_lookup_project = 0
let g:pymode_rope_project_root = ""
let g:pymode_rope_ropefolder='.ropeproject'
let g:pymode_rope_show_doc_bind = '<C-c>d'
let g:pymode_rope_regenerate_on_write = 1
let g:pymode_rope_completion = 1
let g:pymode_rope_complete_on_dot = 1
let g:pymode_rope_completion_bind = '<C-Space>'
let g:pymode_rope_autoimport = 0
let g:pymode_rope_autoimport_modules = ['os', 'shutil', 'datetime']
let g:pymode_rope_autoimport_import_after_complete = 0
let g:pymode_rope_goto_definition_bind = '<C-c>g'
let g:pymode_rope_goto_definition_cmd = 'new'
let g:pymode_rope_rename_bind = '<C-c>rr'
let g:pymode_rope_rename_module_bind = '<C-c>r1r'
let g:pymode_rope_organize_imports_bind = '<C-c>ro'
let g:pymode_rope_autoimport_bind = '<C-c>ra'
let g:pymode_rope_module_to_package_bind = '<C-c>r1p'
let g:pymode_rope_extract_method_bind = '<C-c>rm'
let g:pymode_rope_extract_variable_bind = '<C-c>rl'
let g:pymode_rope_use_function_bind = '<C-c>ru'
let g:pymode_rope_move_bind = '<C-c>rv'
let g:pymode_rope_change_signature_bind = '<C-c>rs'
let g:pymode_syntax = 1
let g:pymode_syntax_slow_sync = 1
let g:pymode_syntax_all = 1
let g:pymode_syntax_print_as_function = 0
let g:pymode_syntax_highlight_async_await = g:pymode_syntax_all
let g:pymode_syntax_highlight_equal_operator = g:pymode_syntax_all
let g:pymode_syntax_highlight_stars_operator = g:pymode_syntax_all
let g:pymode_syntax_highlight_self = g:pymode_syntax_all
let g:pymode_syntax_indent_errors = g:pymode_syntax_all
let g:pymode_syntax_space_errors = g:pymode_syntax_all
let g:pymode_syntax_string_formatting = g:pymode_syntax_all
let g:pymode_syntax_string_format = g:pymode_syntax_all
let g:pymode_syntax_string_templates = g:pymode_syntax_all
let g:pymode_syntax_doctests = g:pymode_syntax_all
let g:pymode_syntax_builtin_objs = g:pymode_syntax_all
let g:pymode_syntax_builtin_types = g:pymode_syntax_all
let g:pymode_syntax_highlight_exceptions = g:pymode_syntax_all
let g:pymode_syntax_docstrings = g:pymode_syntax_all

" vim:tw=79:ts=8:ft=help:norl:
7 changes: 7 additions & 0 deletions tests/utils/reset_update_repo.sh
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions tests/utils/vimrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
source /root/.vimrc.before
source /root/.pymoderc

syntax on
filetype plugin indent on
set shortmess=at
set cmdheight=10
set ft=python
set shell=bash
set rtp+=/root/.vim/pack/foo/start/python-mode
set term=xterm-256color
set wrap " visually wrap lines
set smartindent " smart indenting
set shiftwidth=4 " default to two spaces
set tabstop=4 " default to two spaces
set softtabstop=4 " default to two spaces
set shiftround " always round indentation to shiftwidth
set mouse= " disable mouse
set expandtab
set backspace=indent,eol,start

source /root/.vimrc.after