Skip to content

Commit 7d3c21e

Browse files
committed
Replace install_python.sh, see quarto-dev/quarto#809 (comment) and geocompx#107
1 parent fd43fb8 commit 7d3c21e

File tree

1 file changed

+33
-12
lines changed

1 file changed

+33
-12
lines changed

rocker-rpy/Dockerfile

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,40 @@
1+
# Use the specified base image
12
FROM ghcr.io/geocompx/minimal
23

3-
# Use Python already provisioned by the base image virtualenv (/opt/venv).
4-
# Do not reinstall Python; ensure the venv python is preferred and 'python' exists.
5-
RUN /rocker_scripts/install_python.sh
4+
# Install core Python 3 packages and other dependencies.
5+
# - python3-dev: Headers needed to compile certain Python packages with C extensions.
6+
# - python3-pip: The package installer for Python 3, installed globally.
7+
# - swig: Used for wrapping C/C++ libraries for Python.
8+
# - python3-venv: The module to create virtual environments.
9+
RUN apt-get update && apt-get install -y --no-install-recommends \
10+
python3 \
11+
python3-dev \
12+
python3-pip \
13+
python3-venv \
14+
swig && \
15+
rm -rf /var/lib/apt/lists/*
616

7-
# Prefer the venv python and put its bin on PATH so reticulate picks it up.
8-
ENV RETICULATE_PYTHON=/opt/venv/bin/python
9-
ENV PATH=/opt/venv/bin:${PATH}
17+
# Create a symbolic link so the 'python' command defaults to 'python3'
18+
# The '-f' flag forces the creation of the symbolic link, overwriting any existing file.
19+
RUN ln -sf /usr/bin/python3 /usr/bin/python
1020

11-
# Override the python symlink to use the venv Python (not system Python)
12-
RUN ln -sf /opt/venv/bin/python /usr/bin/python
13-
RUN ln -sf /opt/venv/bin/python /bin/python
21+
# Create a symbolic link so the 'pip' command defaults to 'pip3'
22+
# The '-f' flag forces the creation of the symbolic link, overwriting any existing file.
23+
RUN ln -sf /usr/bin/pip3 /usr/bin/pip
1424

15-
# Set version of Python that Quarto will use:
25+
# Create a Python virtual environment to avoid system package conflicts.
26+
RUN python3 -m venv /opt/venv
27+
28+
# Set the environment variable for Quarto to use the virtual environment's Python.
1629
ENV QUARTO_PYTHON=/opt/venv/bin/python
1730

18-
# Optionally install project requirements into the existing venv if desired:
19-
RUN /opt/venv/bin/pip install -r https://github.com/geocompx/geocompy/raw/refs/heads/main/requirements.txt
31+
# Add the virtual environment's bin directory to the PATH.
32+
ENV PATH="/opt/venv/bin:$PATH"
33+
34+
# Install project requirements into the virtual environment.
35+
# This avoids all system package conflicts.
36+
RUN pip install --no-cache-dir -r https://github.com/geocompx/geocompy/raw/refs/heads/main/requirements.txt
37+
38+
# Install reticulate R package to enable R-Python interoperability
39+
# This step remains the same as it is a separate R installation.
40+
RUN R -e "install.packages('reticulate', repos='https://cloud.r-project.org/')"

0 commit comments

Comments
 (0)