Install Python programs in a safe and isolated environment.
This script is intended to be used as an installation tool for Python programs that do not have their own installation method with dependency isolation. It uses Python's built-in modules venv and pip to create a virtual environment, install the program along with its dependencies inside that environment, and create symbolic links for the executable scripts registered in the Python package. These links are placed in the user's local bin directory, usually ~/.local/bin
.
Python 3.7+ with venv, pip, and ensurepip installed.
Most Python installations come with venv, pip, and ensurepip by default.
For a better user experience, copy the install.py
script and define your package and flags directly in the code so users can omit the extra arguments after python3 -
.
The examples below are for illustration purposes and can be run as-is to test the script.
Installing the latest version of cowsay from PyPI:
curl -sSf https://raw.githubusercontent.com/julianolf/sandboxing/refs/heads/main/install.py | python3 - cowsay
Installing a specific version:
curl -sSf https://raw.githubusercontent.com/julianolf/sandboxing/refs/heads/main/install.py | python3 - cowsay --version=6.0
To update a previously installed program, simply run the installation script again.
To uninstall a program:
curl -sSf https://raw.githubusercontent.com/julianolf/sandboxing/refs/heads/main/install.py | python3 - cowsay --uninstall
For more options and usage, run:
curl -sSf https://raw.githubusercontent.com/julianolf/sandboxing/refs/heads/main/install.py | python3 - --help