norboten · cheat sheet

A development install is not an installation — cheat sheet

python, users-permissions
$ python3 -m venv /opt/APP/venv                          # a venv (needs python3-venv on Ubuntu)
$ /opt/APP/venv/bin/pip install --no-index --find-links /opt/wheels /opt/APP/src
$ /opt/APP/venv/bin/pip list                             # editable installs show their location
$ /opt/APP/venv/bin/pip show -f PKG                      # where it is, which files it installed
$ /opt/APP/venv/bin/pip uninstall --yes PKG
$ ls /opt/APP/venv/lib/python3*/site-packages/           # __editable__*.pth = editable install
$ /opt/APP/venv/bin/python -c 'import PKG; print(PKG.__file__)'
$ head -1 /opt/APP/venv/bin/TOOL                         # the interpreter a console script uses
$ sudo chmod -R a+rX /opt/APP                            # readable to all; X only where already executable
$ sudo ln -sfn /opt/APP/venv/bin/TOOL /usr/local/bin/TOOL
$ pip download -d /opt/wheels PKG…                       # build a wheelhouse where there is network
$ sudo -u someuser TOOL …                                # test as someone who is not root
Exit status / error Layer
127, command not found nothing on PATH has that name
126, Permission denied a directory on the way, or the file, is not executable for you
ModuleNotFoundError the interpreter runs, but the package is not on its import path
externally-managed-environment pip refused to modify a distribution-managed Python