Skip to content

Commit fed2dd7

Browse files
committed
Docker Base: Setup vim for all python vesions
1 parent 592cdb2 commit fed2dd7

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

Dockerfile.base

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ENV DEBIAN_FRONTEND=noninteractive
44
ENV PYTHON_CONFIGURE_OPTS="--enable-shared"
55
ENV PYENV_ROOT="/opt/pyenv"
66
ENV PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH"
7+
ENV PYTHON_VERSION=3.13.0
78

89
# Install system dependencies for pyenv and Python builds
910
RUN apt-get update && apt-get install -yqq \
@@ -39,23 +40,47 @@ RUN git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT && \
3940
cd $PYENV_ROOT && \
4041
git checkout $(git describe --tags --abbrev=0)
4142

43+
# Set up bash profile for pyenv
44+
RUN echo 'export PYENV_ROOT="/opt/pyenv"' >> /root/.bashrc && \
45+
echo 'export PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:$PATH"' >> /root/.bashrc && \
46+
echo 'eval "$(pyenv init -)"' >> /root/.bashrc && \
47+
echo 'eval "$(pyenv init --path)"' >> /root/.bashrc && \
48+
echo 'alias python=python3' >> /root/.bashrc
49+
4250
# Install Python versions with pyenv
4351
RUN pyenv install 3.10.13 && \
4452
pyenv install 3.11.9 && \
4553
pyenv install 3.12.4 && \
4654
pyenv install 3.13.0
4755

48-
ARG PYTHON_VERSION=3.10.13
49-
ENV PYTHON_VERSION=${PYTHON_VERSION}
50-
RUN pyenv global ${PYTHON_VERSION}
51-
52-
# Create virtual environment
53-
RUN python -m venv /opt/venv
54-
ENV PATH="/opt/venv/bin:$PATH"
55-
ENV VIRTUAL_ENV="/opt/venv"
56-
57-
# Upgrade pip in the virtual environment
58-
RUN pip install --upgrade pip setuptools wheel
56+
# Upgrade pip for each Python version
57+
RUN eval "$(pyenv init -)" && \
58+
for pyver in 3.10.13 3.11.9 3.12.4 3.13.0; do \
59+
echo "Upgrading pip for Python $pyver..." && \
60+
pyenv shell $pyver && \
61+
pip install --upgrade pip setuptools wheel && \
62+
## Python-mode dependency
63+
pip install pytoolconfig; \
64+
done
5965

60-
# Dependency to load some modules within pyton-mode
61-
RUN pip install pytoolconfig
66+
# Build and install Vim from source with Python support for each Python version
67+
RUN cd /tmp && \
68+
git clone https://github.com/vim/vim.git && \
69+
cd vim && \
70+
# Build Vim for each Python version
71+
eval "$(pyenv init -)" && \
72+
for pyver in 3.10.13 3.11.9 3.12.4 3.13.0; do \
73+
echo "Building Vim for Python $pyver..." && \
74+
pyenv global $pyver && \
75+
make clean || true && \
76+
./configure --with-features=huge --enable-multibyte --enable-python3interp=yes --with-python3-config-dir=$(python-config --configdir) --enable-perlinterp=yes --enable-luainterp=yes --enable-cscope --prefix=/usr/local --exec-prefix=/usr/local/vim-$pyver && \
77+
make && \
78+
make install && \
79+
mv /usr/local/bin/vim /usr/local/bin/vim-$pyver && \
80+
mv /usr/local/bin/vimtutor /usr/local/bin/vimtutor-$pyver || true && \
81+
mv /usr/local/bin/xxd /usr/local/bin/xxd-$pyver || true && \
82+
echo "Vim for Python $pyver installed as vim-$pyver"; \
83+
done && \
84+
# Set default Vim to use the current global Python version
85+
pyenv global ${PYTHON_VERSION} && \
86+
echo "alias vim='vim-${PYTHON_VERSION}'" >> ~/.bashrc

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy