Skip to content

Commit

Permalink
Fix Python with Vim before Vim 7.3g, test it with vim71
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Oct 29, 2017
1 parent 3706f14 commit b839755
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 25 deletions.
2 changes: 1 addition & 1 deletion example/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM testbed/vim

RUN install_vim -tag v7.1 -name vim71 -build \
RUN install_vim -tag v7.1 -name vim71 -py2 -build \
-tag v7.3.429 -name vim73 -py -build \
-tag v7.4.052 -name vim74-trusty -build \
-tag master -py2 -py3 -ruby -lua -build \
Expand Down
7 changes: 7 additions & 0 deletions example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ test: test-setup
fi; \
$(RM) $(TEMPDIR)/py*; \
done; \
$(DOCKER) vim71 -u NONE \
"+py import sys; open('$(TEMPDIR)/py2', 'w').write(str(sys.version_info[0]))" \
'+q'; \
if [ "$$(<$(TEMPDIR)/py2)" != "2" ]; then \
echo "Failed to get Python version from vim71 (2)." >&2; exit 1; \
fi; \
$(RM) $(TEMPDIR)/py2; \
for vim in "neovim-master --headless" vim-master; do \
$(DOCKER) $${vim} -u NONE \
"+ruby open('$(TEMPDIR)/ruby', 'w') { |f| f << 'ruby was here' }" \
Expand Down
68 changes: 44 additions & 24 deletions scripts/install_vim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,41 @@ EOF

apk add --virtual vim-build curl gcc libc-dev make

cd /vim

if [ -d "$INSTALL_PREFIX" ]; then
echo "WARNING: $INSTALL_PREFIX exists already. Overwriting."
fi

BUILD_DIR="${FLAVOR}-${repo}-${tag}"
if [ ! -d "$BUILD_DIR" ]; then
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# The git package adds about 200MB+ to the image. So, no cloning.
url="https://github.com/$repo/archive/${tag}.tar.gz"
echo "Downloading $repo:$tag from $url"
curl --retry 3 -SL "$url" | tar zx --strip-components=1
else
cd "$BUILD_DIR"
fi

vim_has_dynamic_python() {
# Added in b744b2f (released as Vim 7.3g).
if [ -e src/configure.ac ]; then
return 1
fi
grep -q -e '--enable-pythoninterp.*OPTS=.*dynamic' src/configure.in
}

if [ -n "$PYTHON2" ]; then
apk add --virtual vim-build python-dev
if [ "$FLAVOR" = vim ]; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS --enable-pythoninterp=dynamic"
if vim_has_dynamic_python; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS --enable-pythoninterp=dynamic"
else
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS --enable-pythoninterp"
apk add python
fi
else
apk add --virtual vim-build py2-pip
apk add python
Expand All @@ -85,7 +116,15 @@ EOF
if [ -n "$PYTHON3" ]; then
apk add --virtual vim-build python3-dev
if [ "$FLAVOR" = vim ]; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS --enable-python3interp=dynamic"
if ! [ -e src/if_python3.c ]; then
echo 'WARNING: Python 3 support seems to be missing in this version?!'
fi
if vim_has_dynamic_python; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS --enable-python3interp=dynamic"
else
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS --enable-python3interp"
apk add python3
fi
else
apk add python3
pip3 install neovim
Expand Down Expand Up @@ -113,31 +152,12 @@ EOF
fi
fi

if [ "$FLAVOR" = vim ] && [ -n "$CONFIGURE_OPTIONS" ]; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS $CONFIGURE_OPTIONS"
fi

cd /vim

if [ -d "$INSTALL_PREFIX" ]; then
echo "WARNING: $INSTALL_PREFIX exists already. Overwriting."
fi

BUILD_DIR="${FLAVOR}-${repo}-${tag}"
if [ ! -d "$BUILD_DIR" ]; then
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# The git package adds about 200MB+ to the image. So, no cloning.
url="https://github.com/$repo/archive/${tag}.tar.gz"
echo "Downloading $repo:$tag from $url"
curl --retry 3 -SL "$url" | tar zx --strip-components=1
else
cd "$BUILD_DIR"
fi

if [ "$FLAVOR" = vim ]; then
apk add --virtual vim-build ncurses-dev
apk add ncurses
if [ -n "$CONFIGURE_OPTIONS" ]; then
VIM_CONFIG_ARGS="$VIM_CONFIG_ARGS $CONFIGURE_OPTIONS"
fi
elif [ "$FLAVOR" = neovim ]; then
# Some of them will be installed already, but it is a good reference for
# what is required.
Expand Down

0 comments on commit b839755

Please sign in to comment.