File tree 3 files changed +71
-0
lines changed
3 files changed +71
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ===========================================================================
2
+ # PROJECT ENVIRONMENT SETUP: .envrc
3
+ # ===========================================================================
4
+ # SHELL: bash (or similiar)
5
+ # REQUIRES: direnv >= 2.26.0 -- Needed for: source_env_if_exists, ...
6
+ # USAGE:
7
+ # # -- BETTER: Use direnv (requires: Setup in bash -- $HOME/.bashrc)
8
+ # # BASH PROFILE NEEDS: eval "$(direnv hook bash)"
9
+ # direnv allow .
10
+ #
11
+ # SIMPLISTIC ALTERNATIVE (without cleanup when directory scope is left again):
12
+ # source .envrc
13
+ #
14
+ # SEE ALSO:
15
+ # * https://direnv.net/
16
+ # * https://peps.python.org/pep-0582/ Python local packages directory
17
+ # ===========================================================================
18
+ # MAYBE: HERE="${PWD}"
19
+
20
+ # -- USE OPTIONAL PARTS (if exist/enabled):
21
+ dotenv_if_exists .env
22
+ source_env_if_exists .envrc.use_venv
23
+ source_env_if_exists .envrc.use_pep0582
24
+
25
+ # -- SETUP-PYTHON: Prepend ${HERE} to PYTHONPATH (as PRIMARY search path)
26
+ # SIMILAR TO: export PYTHONPATH="${HERE}:${PYTHONPATH}"
27
+ path_add PYTHONPATH .
28
+
29
+ source_env_if_exists .envrc.override
Original file line number Diff line number Diff line change
1
+ # ===========================================================================
2
+ # PROJECT ENVIRONMENT SETUP: tag-expressions/python/.envrc.use_pep0582
3
+ # ===========================================================================
4
+ # DESCRIPTION:
5
+ # Setup Python search path to use the PEP-0582 sub-directory tree.
6
+ #
7
+ # SEE ALSO:
8
+ # * https://direnv.net/
9
+ # * https://peps.python.org/pep-0582/ Python local packages directory
10
+ # ===========================================================================
11
+
12
+ if [ -z "${PYTHON_VERSION}" ]; then
13
+ # -- AUTO-DETECT: Default Python3 version
14
+ # EXAMPLE: export PYTHON_VERSION="3.9"
15
+ export PYTHON_VERSION=$(python3 -c "import sys; print('.'.join([str(x) for x in sys.version_info[:2]]))")
16
+ fi
17
+ echo "USE: PYTHON_VERSION=${PYTHON_VERSION}"
18
+
19
+ # -- HINT: Support PEP-0582 Python local packages directory (supported by: pdm)
20
+ path_add PATH __pypackages__/${PYTHON_VERSION}/bin
21
+ path_add PYTHONPATH __pypackages__/${PYTHON_VERSION}/lib
22
+
23
+ # -- SIMILAR-TO:
24
+ # export PATH="${HERE}/__pypackages__/${PYTHON_VERSION}/bin:${PATH}"
25
+ # export PYTHONPATH="${HERE}:${HERE}/__pypackages__/${PYTHON_VERSION}/lib:${PYTHONPATH}"
Original file line number Diff line number Diff line change
1
+ # ===========================================================================
2
+ # PROJECT ENVIRONMENT SETUP: tag-expressions/python/.envrc.use_venv
3
+ # ===========================================================================
4
+ # DESCRIPTION:
5
+ # Setup and use a Python virtual environment (venv).
6
+ # On entering the directory: Creates and activates a venv for a python version.
7
+ # On leaving the directory: Deactivates the venv (virtual environment).
8
+ #
9
+ # SEE ALSO:
10
+ # * https://direnv.net/
11
+ # * https://github.com/direnv/direnv/wiki/Python
12
+ # * https://direnv.net/man/direnv-stdlib.1.html#codelayout-python-ltpythonexegtcode
13
+ # ===========================================================================
14
+
15
+ # -- VIRTUAL ENVIRONMENT SUPPORT: layout python python3
16
+ # VENV LOCATION: .direnv/python-$(PYTHON_VERSION)
17
+ layout python python3
You can’t perform that action at this time.
0 commit comments