prometa.python package
Submodules
prometa.python.common module
All things specific to Python (pyproject.toml, PyPI, etc.)
- prometa.python.common.get_license_classifier(spdx_id)[source]
Get the Python license classifier for the given SPDX license ID.
- Parameters:
spdx_id – The SPXD license ID.
- Returns:
The corresponding Python trove classifier if found, else None.
- prometa.python.common.get_pypi_url(name)[source]
Get the URL to the project’s page on PyPI if it exists.
- Parameters:
name – The project name.
- Returns:
The project URL, or None if it does not exist.
- prometa.python.common.get_version(project_dir)[source]
Get the version of a project from its directory.
This will create a temporary virtual environment and install the project in it to get the version. This ensures that VCS-versions are correctly handled.
This should not be necessary but at the time or writing the current version of CodeMetaPy fails to detect versions.
prometa.python.venv module
Virtual environment functions.
- class prometa.python.venv.VirtualEnvironment(update_pip=False, inherit=False)[source]
Bases:
ExitStack
Context manager for temporary Python virtual environments.
- __init__(update_pip=False, inherit=False)[source]
- Parameters:
update_pip – If True, update pip in the virtual environment.
inherit – If True, create a .pth file to inherit packages from the parent environment.
- run_cmd(cmd, **kwargs)[source]
Run a command with subprocess.
- Parameters:
cmd – The command to run, as a list.
**kwargs – Keyword arguments passed through to subprocess.run.
- Returns:
The return value of subprocess.run.
- run_cmd_in_venv(cmd, **kwargs)[source]
Run a command in the virtuel environment. This will pass the virtual environment’s environment variables to the subprocess command.
- run_pip_in_venv(args, **kwargs)[source]
Run a pip command in the virtual environment. This is a wrapper around run_python_in_venv().
- Parameters:
args – The arguments to pass to pip.
**kwargs – Keyword arguments passed through to run_python_in_venv().
- Returns:
The return value of run_python_in_venv().
- run_python_in_venv(args, **kwargs)[source]
Run a Python command in the virtual environment. This will only work within this class’ context.
- Parameters:
args – The arguments to pass to the Python interpretter.
**kwargs – Keyword arguments passed through to subprocess.run.
- Returns:
The return value of subprocess.run.
Module contents
Package stub.