Python Configuration¶
Setting the environment (python)¶
To keep a consistent environment for python, the following are set:
- PYTHONOPTIMIZE
0, When developing, exceptions, docstrings and breakpoints are wanted!
- PYTHONUNBUFFERED
1, Reduce need to call flush and avoid headaches in general
- PYTHONDONTWRITEBYTECODE
1, Don’t pollute the source tree with __pycache__ directories
- PYTHONHASHSEED
42, Reproducible hashes, if you have to ask why 42, hand in your geek badge!
- PYTHONIOENCODING
utf8, Default to UTF-8 encoding
- PYTHONASYNCIODEBUG
1, Enable asynchronous debugging (required when developing async components)
- PYTHONDEVMODE
- 1, Toogle sys.flags.dev_mode attribute on
and also enables extra run time checks
- PYTHONUTF8
1, Default file encoding
Configuration (bash)¶
Define constants (bash)¶
Assuming bash constants has been followed:
~ $ printf "\\n# Developer environment (python)\\n\\n" >> $RC
~ $ printf "export PYTHONOPTIMIZE=0\n" >> $RC
~ $ printf "export PYTHONUNBUFFERED=1\n" >> $RC
~ $ printf "export PYTHONDONTWRITEBYTECODE=1\n" >> $RC
~ $ printf "export PYTHONHASHSEED=42\n" >> $RC
~ $ printf "export PYTHONIOENCODING=utf8\n" >> $RC
~ $ printf "export PYTHONASYNCIODEBUG=1\n" >> $RC
~ $ printf "export PYTHONUTF8=1\n" >> $RC
~ $ printf "export PYTHONDEVMODE=1\n" >> $RC
Define virtual environment root directory (PY_VENV_DIR)¶
Note
The following are optional
Define the root directory for all virtual environment installations.
~ $ printf "export PY_VENV_DIR=\$PREFIX/.share/virtualenvs\\n" >> $RC
Congratulations, a python baseline environment is now defined!