Skip to content

Commit 34599ce

Browse files
committed
added .envrc-python
1 parent 2e57a1c commit 34599ce

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.envrc-python

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env bash
2+
# vim:ts=4:sts=4:sw=4:et
3+
#
4+
# Author: Hari Sekhon
5+
# Date: Mon Feb 22 17:42:01 2021 +0000
6+
#
7+
# https://github.com/HariSekhon/SQL-scripts
8+
#
9+
# License: see accompanying Hari Sekhon LICENSE file
10+
#
11+
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
12+
#
13+
# https://www.linkedin.com/in/HariSekhon
14+
#
15+
16+
# ============================================================================ #
17+
# P y t h o n D i r E n v
18+
# ============================================================================ #
19+
20+
# .envrc to auto-load the virtualenv inside the 'venv' directory if present
21+
22+
# https://direnv.net/man/direnv-stdlib.1.html
23+
24+
set -euo pipefail
25+
[ -n "${DEBUG:-}" ] && set -x
26+
#srcdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27+
28+
# this is necessary because newer versions of pip no longer allow you to install PyPI packages in system-packages by default
29+
for venv in "$PWD/venv" "$HOME/venv"; do
30+
if [ -f "$venv/bin/activate" ]; then
31+
echo
32+
echo "Virtualenv directory found in: $venv"
33+
echo
34+
echo "Activating Virtualenv inside the directory: $venv"
35+
36+
# shellcheck disable=SC1091
37+
source "$venv/bin/activate"
38+
break
39+
fi
40+
done
41+
42+
# read .env too
43+
#dotenv

0 commit comments

Comments
 (0)