Skip to content

Instantly share code, notes, and snippets.

@gdamjan
Last active February 14, 2021 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdamjan/88362c9c67b0d20b50fa386e1d58f827 to your computer and use it in GitHub Desktop.
Save gdamjan/88362c9c67b0d20b50fa386e1d58f827 to your computer and use it in GitHub Desktop.
pep-0370 vs virtualenv
  1. bog standard, pep-0370 python:
$ PYTHONUSERBASE=$PWD/pep-370-env pip install --user flask
…
$ du -sh pep-370-env/
3.1M    pep-370-env/
  1. virtualenv (and we need this installed before-hand):
$ virtualenv virt-env
$ ./virt-env/bin/pip install flask
…
$ du -sh virt-env/ 
17M     virt-env/

On top of the needless dependencies in the virtualenv case, pep-370-env/ is relocatable, and virt-env/ is not (ie. it depends on the paths of where it was installed originally).

ps. this is how you enable the pep-0370 environment dependencies in a systemd service:

…
[Service]
Environment=PYTHONUSERBASE=/opt/my-app/pep-370-env
ExecStart=/usr/bin/python /opt/my-app/main.py
…

One line, bam 💥 it works. I have no idea how you do that with the virtualenv environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment