Create a Python virtualenv directory structure.
Note that py_binary and py_test macros automatically provide [name].venv
targets.
Using py_venv
directly is only required for cases where those defaults do not apply.
> [!NOTE] > As an implementation detail, this currently uses <https://github.com/prefix-dev/rip> which is a very fast Rust-based tool.
py_venv_rule(name, deps, imports, location, package_collisions, resolutions, venv_name)
Create a Python virtual environment with the dependencies listed.
ATTRIBUTES
Name | Description | Type | Mandatory | Default |
---|---|---|---|---|
name | A unique name for this target. | Name | required | |
deps | Targets that produce Python code, commonly py_library rules. |
List of labels | optional | [] |
imports | List of import directories to be added to the PYTHONPATH. | List of strings | optional | [] |
location | Path from the workspace root for where to root the virtial environment | String | optional | "" |
package_collisions | The action that should be taken when a symlink collision is encountered when creating the venv. A collision can occour when multiple packages providing the same file are installed into the venv. The possible values are: * "error": When conflicting symlinks are found, an error is reported and venv creation halts. * "warning": When conflicting symlinks are found, an warning is reported, however venv creation continues. * "ignore": When conflicting symlinks are found, no message is reported and venv creation continues. |
String | optional | "error" |
resolutions | FIXME | Dictionary: Label -> String | optional | {} |
venv_name | Outer folder name for the generated virtual environment | String | optional | "" |
py_venv(name, kwargs)
Wrapper macro for py_venv_rule
.
Chooses a suitable default location for the resulting directory.
By default, VSCode (and likely other tools) expect to find virtualenv's in the root of the project opened in the editor. They also provide a nice name to see "which one is open" when discovered this way. See aspect-build#395
Use py_venv_rule directly to have more control over the location.
PARAMETERS
Name | Description | Default Value |
---|---|---|
name | - |
none |
kwargs | - |
none |