-
Notifications
You must be signed in to change notification settings - Fork 3
Python Development Environment
-
BEE selects Python 3.6.8 as minimum supported version. Note some of the following instructions are for Python 3.7 but the team has decided to use 3.6.8 to support RHEL systems.
-
We don't need multiple versions of Python 3 on our development machines. Testing against Python versions should happen in our CI/CD environment. So, no need for
pyenv, although it can help to catch backwards-compatibility issues early. -
Those of us on Macs may have a problem with Homebrew and so can't rely on that.
-
In any case, we must have Python 3.7+ (
python3) installed somewhere on our development machines (and on yourPATH). That comes withpip3and thevenvmodule (which is probably required bypipenv). How you get this installed on a Mac without a working Homebrew is an exercise for the user. -
BEE will use
pipenvto manage a virtual development environment and our dev/prod Python package requirements.
Assuming that pipenv couldn't be installed by Homebrew you'll need to install it locally (--user) using Pip:
> pip3 install pipenv --userYou'll need to be careful here. Depending on how you installed Python 3, this command will install pipenv but it may not end up in your PATH (because it's a binary or script). If that's the case, you'll see a message telling you where it is and that you should put it in your PATH. This may be the best approach. In your shell's startup file:
# So we can find xxx binaries or scripts installed with pip3 install xxx --user
# Assumes we have Python installed as python3
export PY_USER_BIN=$(python3 -c 'import site; print(site.USER_BASE + "/bin")')
export PATH=$PY_USER_BIN:$PATHBy default, pipenv creates the project's virtual environment in a centralized location (e.g. ~/.local/share/virtualenvs/) and maps that to the project's directory. It may be preferable to locate the virtual environment with the project (in case you change directory names). Setting PIPENV_VENV_IN_PROJECT=1 in you shell startup file will force pipenv to place the environment in the projects's directory as a .venv directory.
# So pipenv puts virtual environment directory in project directory.
export PIPENV_VENV_IN_PROJECT=1Now you can create your initial environment:
> pipenv --three # or /path/to/pipenv if you don't want to put it in your PATHThis will create the starting environment using the most recent version of Python 3 that is already installed on your system (and on your PATH). pipenv will not download and install Python for you. Now you can activate the new environment and work in a shell there:
> pipenv shell # or /path/to/pipenv if you don't want to put it in your PATH
(envdir) > ADD PIPENV INSTALL DEV/PROD INSTRUCTIONS HERE
When finished, exit the environment shell:
(envdir) > exit
>