Skip to content

Make Pip willing to hide system Python modules #5321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 12, 2025
Merged
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: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ the appliance images to, for example:
You might also want to build just for one architecture and load into your
Docker daemon. We have a 'load_docker' target for this.

make load_docker arch=amd64
make load_docker arch=linux/amd64

If Docker is not installed, Docker-related targets tasks and tests will be skipped. The
same can be achieved by setting TOIL_DOCKER_REGISTRY to an empty string.
Expand Down
30 changes: 17 additions & 13 deletions docker/Dockerfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,22 @@ def heredoc(s):
# The stock pip is too old and can't install from sdist with extras
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | {python}

# Include virtualenv, as it is still the recommended way to deploy pipelines
RUN {pip} install --upgrade virtualenv==20.25.1

# Install s3am (--never-download prevents silent upgrades to pip, wheel and setuptools)
# Install setuptools within the virtual environment to properly access distutils due to PEP 632 and gh-95299 in Python 3.12 release notes
# https://docs.python.org/3/whatsnew/3.12.html#summary-release-highlights
RUN virtualenv --python {python} --never-download /home/s3am \
&& /home/s3am/bin/pip install setuptools \
&& /home/s3am/bin/pip install s3am==2.0 \
&& ln -s /home/s3am/bin/s3am /usr/local/bin/

RUN {pip} install --upgrade setuptools==69.2.0
# Include virtualenv, as it is still the recommended way to deploy
# pipelines.
#
# We need to --ignore-installed here to allow shadowing system packages
# from apt in /usr/lib/python3/dist-packages when the installed package
# needs newer versions. We just hope that doesn't break the Ubuntu system
# too badly when we're actually on the system Python, or if Toil needs to
# upgrade a distutils or setuptools dependency. On the deadsnakes Pythons,
# installations into the version-specific package directory won't be seen
# by the system Python which is a different version.
#
# TODO: Change to nested virtual environments and .pth files and teach Toil
# to just ship the user-level one for hot deploy.
RUN {pip} install --ignore-installed --upgrade 'virtualenv>=20.25.1,<21'

RUN {pip} install --ignore-installed --upgrade 'setuptools>=80,<81'

# Fix for https://issues.apache.org/jira/browse/MESOS-3793
ENV MESOS_LAUNCHER=posix
Expand Down Expand Up @@ -222,7 +226,7 @@ def heredoc(s):

# This component changes most frequently and keeping it last maximizes Docker cache hits.
COPY {sdistName} .
RUN {pip} install {sdistName}[all]
RUN {pip} install --ignore-installed --upgrade {sdistName}[all]
RUN rm {sdistName}

# We intentionally inherit the default ENTRYPOINT and CMD from the base image, to the effect
Expand Down
2 changes: 1 addition & 1 deletion src/toil/test/provisioners/aws/awsProvisionerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def _runScript(self, toilOptions):
runCommand = [
self.python(),
self.script(),
"--fileToSort=/home/s3am/bin/asadmin",
"--fileToSort=/etc/passwd",
"--sortMemory=0.6G",
"--mergeMemory=3.0G",
]
Expand Down
2 changes: 1 addition & 1 deletion src/toil/test/provisioners/gceProvisionerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def _runScript(self, toilOptions):
runCommand = [
"/home/venv/bin/python",
"/home/sort.py",
"--fileToSort=/home/s3am/bin/asadmin",
"--fileToSort=/etc/passwd",
"--sortMemory=0.6G",
"--mergeMemory=3.0G",
]
Expand Down
Loading