Prepare a virtual environment for moving to another directory
Project description
venv-retarget - prepare a virtual environment for moving to another directory
[Home | GitLab | PyPI | ReadTheDocs]
Overview
The venv-retarget
tool modifies several files within a virtual environment so that
their contents will correspond to what the venv
module would have done if that
virtual environment were created in a different directory.
This may be useful if a virtual environment is created with the intention of being
packaged and copied over to other systems in a shared path.
Invocation
venv-retarget [-qv] detect [--use-prefix] path/to/venv
venv-retarget [-qv] retarget
[-d /dest/venv | --venvdst /dest/venv]
[-s /source/venv | --venvsrc /source/venv]
path/to/venv
venv-retarget --features
venv-retarget --help
Detect the path stored into a virtual environment's files
The detect
subcommand causes venv-retarget
to examine the files within
the virtual environment and check several places where venv
records
the path to the virtual environment:
- the
command = ...
line in thepyvenv.cfg
file - the paths to the source files stored in the precompiled
__pycache__/*.pyc
files - if
--use-prefix
is specified, thesys.prefix
value from the Python interpreter within the virtual environment
Note that the sys.prefix
value will reflect the current location of the virtual
environment, so if it has already been moved, this path will differ from the rest and
result in the detect
subcommand failing because of inconsistent paths.
Change the paths to reflect a new location for the virtual environment
The main purpose of the venv-retarget
tool is the retarget
subcommand: look for
files within the virtual environment that record the source path (either specified with
the -s
/ --venvsrc
command-line option, or autodetected as per the detect
subcommand),
and modifies those files to refer to the destination path (either specified with
the -d
/ --venvdst
command-line option, or the current path to the virtual environment).
This allows retarget
to be used in three ways:
- after the virtual environment was created in a temporary location, in order to prepare to move it to either a temporary buildroot location or its final one
- after the virtual environment has been moved to a temporary buildroot location
- after the virtual environment has been moved to its final location
In each of the three cases, the source directly should generally not need to be specified.
In any but the last case, the destination directory should be specified, or
venv-retarget
will record the temporary location of the virtual environment instead.
Examples
Figure out what the files within a virtual environment think about where it is at:
venv-retarget detect /path/to/venv
Prepare the files in an existing virtual environment to be moved somewhere else:
venv-retarget retarget -d /usr/libexec/venvs/agent agent-venv
Update the files after a virtual environment has been moved:
venv-retarget retarget -s /home/build/program/agent-venv buildroot/usr/libexec/venvs/agent
The same, but let the venv-retarget
tool figure out the source directory by
examining the contents of the files within the virtual environment, e.g.
when the installation program was able to copy the files directly to
the destination directory instead of a temporary buildroot:
venv-retarget retarget /usr/libexec/venvs/agent
Contact
The venv-retarget
tool was written by Peter Pentchev.
It is developed in a GitLab repository.
This documentation is hosted at Ringlet with a copy at ReadTheDocs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file venv_retarget-0.1.0.tar.gz
.
File metadata
- Download URL: venv_retarget-0.1.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9a51c0742d2b929919971f38cd62acfdca74eeeaa42112533d79d3195184d85 |
|
MD5 | 9246385a693f38b91dec3c13678c5d08 |
|
BLAKE2b-256 | c906216ed2043ac62fdb90ae973c865e000be61201e7b22c40ebd02ae55ffbc1 |
File details
Details for the file venv_retarget-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: venv_retarget-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40d19cb9901d409d87841b3f37d6dd74abd46a366e08916f9c5c28c1d0e92cd8 |
|
MD5 | fc8434558890f7dabe6059618d5269f4 |
|
BLAKE2b-256 | 9e12f9792569385b66730c2477730f692c1d12f0e8e99188125c61f8817ecb44 |