Skip to content

Commit 4979c6b

Browse files
committed
Merge branch 'improvements' into 'main'
Make executables installed with pip available and make "main python" the default Closes #3 See merge request divio/incubator/multi-python!5
2 parents 5276725 + d15b8f3 commit 4979c6b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ RUN set -eux \
7171
; fi \
7272
; mkdir /pypy && tar -xf /pypy.tar.bz2 -C /pypy --strip-components=1
7373

74-
ENV PATH="/pypy/bin:$PATH"
74+
# Make pypi available and ensure executables installed by pip are available
75+
# (pip uses the "User Scheme" in recent Debian/Ubuntu,
76+
# see https://packaging.python.org/en/latest/guides/installing-using-linux-tools/#debian-ubuntu)
77+
ENV PATH="$PATH:/pypy/bin:/home/tox/.local/bin"
78+
79+
# Set the default python version
80+
RUN set -eux \
81+
; ln -f -s /usr/bin/python${PYTHON_MAIN_VERSION} /usr/bin/python \
82+
; ln -f -s /usr/bin/python${PYTHON_MAIN_VERSION} /usr/bin/python3
7583

7684
# Create user (with sudo privileges) and app directory
7785
RUN set -eux \

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The list of Python versions to install is passed as arguments (see `Dockerfile`)
1111
One Python version must be selected as "main" - it will be used to install `tox`.
1212
Along with "regular" Python versions, one pypy version will also be installed.
1313

14+
The main python version is set as the default in the container (`python` and `python3`).
15+
1416
**IMPORTANT**: Python versions must be available either in the official Ubuntu repositories or in
1517
the [deadsnakes PPA](https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa). The PyPy version should
1618
be available at https://www.pypy.org/download.html.
@@ -29,3 +31,16 @@ so it is possible to run `sudo apt update && sudo apt install ...`.
2931

3032
After updating the Python versions in the `Dockerfile`, ensure you also update `test/tox.ini` to
3133
reflect the change.
34+
35+
## About pip
36+
37+
As stated in https://packaging.python.org/en/latest/guides/installing-using-linux-tools/#debian-ubuntu:
38+
39+
> Recent Debian/Ubuntu versions have modified pip to use the “User Scheme” by default,
40+
> which is a significant behavior change that can be surprising to some users.
41+
42+
In other words, pip now installs libraries and executables in `$HOME/.local` (or `/home/tox/.local`
43+
in this image).
44+
45+
This has no impact, except when running commands as `sudo`. Just keep in mind the `root` user
46+
doesn't have the same packages installed.

0 commit comments

Comments
 (0)