diff options
| author | Tom Rini <[email protected]> | 2025-04-15 12:10:26 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2025-04-24 15:37:27 -0600 |
| commit | efd00b03455644b18eaf2b6dcd07f6d55b95b39e (patch) | |
| tree | 037d898da2753ccf92134099cc643e51b7b3d38d /tools | |
| parent | 10f48365112b164bee6564033ab682747efcb483 (diff) | |
python: Use and refer to the venv module rather than virtualenv
Using some form of sandbox with Python modules is a long standing best
practice with the language. There are a number of ways to have a Python
sandbox be created. At this point in time, it seems the Python community
is moving towards using the "venv" module provided with Python rather
than a separate tool. To match that we make the following changes:
- Refer to a "Python sandbox" rather than virtualenv in comments, etc.
- Install the python3-venv module in our container and not virtualenv.
- In our CI files, invoke "python -m venv" rather than "virtualenv".
- In documentation, tell users to install python3-venv and not
virtualenv.
Signed-off-by: Tom Rini <[email protected]>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/buildman/test.py | 2 | ||||
| -rw-r--r-- | tools/buildman/toolchain.py | 2 | ||||
| -rw-r--r-- | tools/docker/Dockerfile | 5 | ||||
| -rw-r--r-- | tools/u_boot_pylib/test_util.py | 2 |
4 files changed, 5 insertions, 6 deletions
diff --git a/tools/buildman/test.py b/tools/buildman/test.py index c5feb74a105..e31e6c72e1a 100644 --- a/tools/buildman/test.py +++ b/tools/buildman/test.py @@ -987,7 +987,7 @@ class TestBuild(unittest.TestCase): diff = self.call_make_environment(tchn, full_path=True)[0] self.assertEqual({b'LC_ALL': b'C'}, diff) - # Test that virtualenv is handled correctly + # Test that Python sandbox is handled correctly tchn.override_toolchain = False sys.prefix = '/some/venv' env = dict(os.environb) diff --git a/tools/buildman/toolchain.py b/tools/buildman/toolchain.py index f4c832be8d3..5e5bb4b0aed 100644 --- a/tools/buildman/toolchain.py +++ b/tools/buildman/toolchain.py @@ -217,7 +217,7 @@ class Toolchain: elif self.cross: env[b'CROSS_COMPILE'] = tools.to_bytes(wrapper + self.cross) - # Detect a Python virtualenv and avoid defeating it + # Detect a Python sandbox and avoid defeating it if sys.prefix != sys.base_prefix: paths = env[b'PATH'].split(b':') new_paths = [] diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index a0fd174ff60..dec1d516a6c 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -124,7 +124,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ python3-dev \ python3-pip \ python3-sphinx \ - python3-virtualenv \ + python3-venv \ rpm2cpio \ sbsigntool \ socat \ @@ -136,7 +136,6 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ texinfo \ util-linux \ uuid-dev \ - virtualenv \ vboot-kernel-utils \ vboot-utils \ xilinx-bootgen \ @@ -313,7 +312,7 @@ RUN wget -O /tmp/binman-requirements.txt https://source.denx.de/u-boot/u-boot/-/ RUN wget -O /tmp/buildman-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/tools/buildman/requirements.txt RUN wget -O /tmp/patman-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/tools/patman/requirements.txt RUN wget -O /tmp/u_boot_pylib-requirements.txt https://source.denx.de/u-boot/u-boot/-/raw/master/tools/u_boot_pylib/requirements.txt -RUN virtualenv -p /usr/bin/python3 /tmp/venv && \ +RUN python3 -m venv /tmp/venv && \ . /tmp/venv/bin/activate && \ pip install -r /tmp/pytest-requirements.txt \ -r /tmp/sphinx-requirements.txt \ diff --git a/tools/u_boot_pylib/test_util.py b/tools/u_boot_pylib/test_util.py index 4835847bfc6..637403f8715 100644 --- a/tools/u_boot_pylib/test_util.py +++ b/tools/u_boot_pylib/test_util.py @@ -64,7 +64,7 @@ def run_test_coverage(prog, filter_fname, exclude_list, build_dir, if build_dir: prefix = 'PYTHONPATH=$PYTHONPATH:%s/sandbox_spl/tools ' % build_dir - # Detect a Python virtualenv and use 'coverage' instead + # Detect a Python sandbox and use 'coverage' instead covtool = ('python3-coverage' if sys.prefix == sys.base_prefix else 'coverage') |
