Python version & venv management (maybe more ...)
Use pipx (recommend)
pipx install pvx
Or pip
pip install pvx
Don't forget python-build
and it dependencies.
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
pyenv is usually installed at ~/.pyenv
by default. If it is installed silently, then everything is ready, otherwise add PVX_PY_BUILD_PATH=/your/pyenv/path/plugins/python-build
to env
(plugins/python-build
is usually fixed).
-
List version number that you can download.
pvx py archive # If you want to filter it, do this pvx py archive 3.10
-
Install.
pvx py insetall 3.10.4
-
List versions of installed.
pvx py list
-
Remove the specified version of Python.
pvx py remove 3.10.4
-
Create a virtual environment (pvx use Python Venv and compatible with its parameters)
# All default (current python and default venv prompt) pvx venv new # Specify the version (which install by pvx) pvx venv new 3.10.4 # Use existing Python pvx venv new ~/.pyenv/versions/3.10.4/bin/python # Use venv's parameters, such as specifying prompt pvx venv new 3.10.4 --prompt venv_prompt_name # Use current python and venv's parameters pvx venv new --prompt venv_prompt_name
-
List all virtual environments
# You'll see a table , highlight the activate one. pvx venv list
-
Activate virtual environment with
PROMPT
# use `pvx venv list` to show prompt pvx venv activate prompt_name
-
Remove virtual environment with
PROMPT
# use `pvx venv list` to show prompt pvx venv remove prompt_name
PVX_ROOT_PATH
: pvx home path.Default: ~/.pvx
PVX_PYTHON_INSTALLATION_PATH
: The installation folder for Python.Default: ~/${PVX_ROOT_PATH}/versions
PVX_VENV_IN_PROJECT
: Whether the virtual environment is installed in the project.Default: true
PVX_VENV_DIR_NAME_IN_PROJECT
: The folder name of virtual environment.Default: .venv
PVX_VENV_EXTERNAL_PATH
: IfPVX_VENV_IN_PROJECT
is false, the virtual environment is installed externally rather than in the project.Default: ~/${PVX_ROOT_PATH}/venv
PVX_PY_BUILD_HOME
: pyenv plugin python-build home path.Default: ~/.pyenv/plugins/python-build
If you want to extend commands, be familiar with the following points.
- The folder where the
pvx.py
file resides is theroot
. root/commands
is the folder where the.py
command scripts are stored.- If
filenamed
is true, use the file name command, otherwise use the argument to@click.command
. - The.py
files are namedpvx_{group}_{command}.py
.For example:pvx_py_install.py
, which means we can call it withpvx py install
. .py
file must have a method calledcli
and decorated with@click.command
.
pvx was my experiment after studying pyenv
, poetry
rich
and click
. Thank them for their efforts, fun 😁 ~
- python-build (pyenv's plugin), which pvx depend to install different versions of Python
- poetry
- rich, a Python library for rich text and beautiful formatting in the terminal.
- click, a python composable command line interface toolkit