Python version & venv management (maybe more ...)
Use pipx (recommend)
pipx install pvxOr pip
pip install pvxDon't forget python-build and it dependencies.
git clone https://github.com/pyenv/pyenv.git ~/.pyenvpyenv 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: ~/.pvxPVX_PYTHON_INSTALLATION_PATH: The installation folder for Python.Default: ~/${PVX_ROOT_PATH}/versionsPVX_VENV_IN_PROJECT: Whether the virtual environment is installed in the project.Default: truePVX_VENV_DIR_NAME_IN_PROJECT: The folder name of virtual environment.Default: .venvPVX_VENV_EXTERNAL_PATH: IfPVX_VENV_IN_PROJECTis false, the virtual environment is installed externally rather than in the project.Default: ~/${PVX_ROOT_PATH}/venvPVX_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.pyfile resides is theroot. root/commandsis the folder where the.pycommand scripts are stored.- If
filenamedis true, use the file name command, otherwise use the argument to@click.command. - The.pyfiles are namedpvx_{group}_{command}.py.For example:pvx_py_install.py, which means we can call it withpvx py install. .pyfile must have a method calledcliand 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