pip-safe
pip-safe is the safe and easy pip package manager for command-line apps from PyPi.
Synopsys
pip-safe install lastversion
lastversion linux
Why
Using pip install ... outside virtualenv can simply break your system.
So many tutorials out there blindly recommend that without any note of having to use virtualenvs,
and so many people do just run that without any knowledge of what a virtualenv is.
If you run an OS which distributes Python packages via yum, apt, etc. you will break your
system sooner or later, if you keep using pip as root or sudo.
You either have to package the Python-based program yourself, or have to use a virtualenv for installing it. Everything else is a risk of breakage.
pip-safe is here to make it very easy to install command-line apps from PyPi without having to
package anything.
Installation
Pre-Requisites
Configure your PATH to execute stuff from ~/.local/bin and /usr/local/bin.
Place export PATH=$PATH:$HOME/.local/bin:/usr/local/bin in your ~/.bashrc
then run source ~/.bashrc to apply to current shell.
CentOS/RHEL 7, 8 and Fedora Linux
sudo yum -y install https://extras.getpagespeed.com/release-latest.rpm
sudo yum -y install pip-safe
Using pip-safe command installs a program using Python 3, by default.
If you require to run a legacy app using Python 2, run yum install pip2-safe to install Python 2
support. Then to install a Python 2 app, use pip2-safe install <app>. You can still use
pip-safe as usual, for Python 3 apps.
Other systems
Please do not use these methods if packages for pip-safe are available!
Install pip-safe for current user
If you install pip-safe using this method, you can only install packages for current user,
but this method does not require root.
Ensure ~/.local/bin is in your PATH, then:
mkdir -p ~/.virtualenvs
python3 -m venv ~/.virtualenvs/pip-safe
~/.virtualenvs/pip-safe/bin/pip install pip-safe
mkdir -p $HOME/.local/bin
ln -s $HOME/.virtualenvs/pip-safe/bin/pip-safe $HOME/.local/bin/pip-safe
System-wide installation of pip-safe
When pip-safe is installed system-wide, you can install both system-wide and user packages with it.
Ensure /usr/local/bin is in your PATH, then:
mkdir -p /opt/pip-safe
python3 -m venv /opt/pip-safe/pip-safe
/opt/pip-safe/pip-safe/bin/pip install pip-safe
ln -s /opt/pip-safe/pip-safe/bin/pip-safe /usr/local/bin/pip-safe
Usage
Safely install and remove PyPi (pip) programs without breaking your system
positional arguments:
<command> Command to run, e.g. install, update, remove or list
package-name
optional arguments:
-h, --help show this help message and exit
-v, --verbose
-y, --assumeyes
--system Install for all users
--version show program's version number and exit
Installing a program
pip-safe install <name>
To see what's going on under the hood, pass --verbose flag.
There is limited support for installing directly from Git URLs, e.g.:
pip-safe install git+https://github.com/dvershinin/lastversion.git
Global installation
By default, programs are installed to ~/.local/bin/<package> (for current user).
For a system-wide installation, use --system:
sudo pip-safe install --system lastversion
This installs a package to /opt/pip-safe/<package> and symlinks its executable to /usr/local/bin,
so it's still safe :-)
Removing a program
pip-safe remove <name>
Updating a program
pip-safe update <name>
Listing installed packages
pip-safe list
With pip-safe, you can easily install command line programs from PyPi,
while not worrying about breaking your system.
How
it installs each program into its own virtualenv, and symlinks whichever
executables it has over to ~/.local/bin/
It is that easy and I don't know why nobody did this before.
Caveats
- Only pure Python apps will work absolutely reliably, because others might require system libraries, and we can't decipher what are those
- Tested only with Python 3.6
Helpful stuff used while creating pip-safe
Metadata
Release files for pip-safe 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pip-safe-0.0.12.tar.gz | 12.0 kB | Without provenance | Details for pip-safe-0.0.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pip_safe-0.0.12-py3-none-any.whl | Python 3 | none | any | Details for pip_safe-0.0.12-py3-none-any.whl |
Total release size: 22.7 kB
Release files / pip-safe-0.0.12.tar.gz
| Download URL | pip-safe-0.0.12.tar.gz |
|---|---|
| Size | 12.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c04412cba2ec16d7399000582ec4922f4c005e5f7c235bc0be585a0f37063fc
|
|
BLAKE2b-256 checksum How to use checksums |
37ab17d3d8a4d33dac52a72038b00de442b21ab432e21ec1c165e00ea9894d62
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Release files / pip_safe-0.0.12-py3-none-any.whl
| Download URL | pip_safe-0.0.12-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1d83092c1bd5535901251b52cefb67e9cee6bd30df1a78306a8fe0226586f04
|
|
BLAKE2b-256 checksum How to use checksums |
fe2bb89e4316eda8add82118d5dd16b2aa42a99f5e533f547975aa0c541ca5e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.1
|
Security for pip-safe 0.0.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.