This gist lists steps needed to setup python development environment on FreeBSD using isolated virtual environments.
- Pythonic way is to create virtual enviroments for projects and add libs to these venvs not system python.
- Binary packages available only for one python version. Currently this is 3.8.
- Although we can build python packages against another version using ports, it's still not the Pythonic way.
- Install python 3.9 (latest stable) using pkg
- Install pip using get-pip.py
- Install pipx using pip
- Install poetry using pipx
- Create and Manage python virtual environments using poetry
NOTE:
Both pipx
and poetry
provide isolated environments for python projects with different objectives. pipx
is used to install python-based CLI/TUI tools in isolated env, while poetry
is used to created isolated python environments for coding/development/testing etc.
Here pipx
is used to install poetry
in an isolated env. and from there on we use poetry to create/manage our virtual enviromentns for coding/development etc. Instead you can simply install poetry
directly using pip
w/o installing pipx
.
- System Python binary -
/usr/local/bin/python3.9
- System Python libraries -
/usr/local/lib/python3.9
- User Python binaries -
$HOME/.local/bin
- User Python libraries -
$HOME/.local/lib/python3.9/site-packages
pipx
installed binaries -$HOME/.local/bin
pipx
installed virtual environments -$HOME/.local/pipx/venvs
poetry
virtual environments -$HOME/.cache/pypoetry/virtualenvs