Push more stuff into my “create venv” script
- ID
11d5438- date
2023-12-12 10:52:46+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
09fd08a- message
Push more stuff into my "create venv" script- changed files
1 file, 33 additions, 1 deletion
Changed files
fish_functions/venv.fish (423) → fish_functions/venv.fish (1566)
diff --git a/fish_functions/venv.fish b/fish_functions/venv.fish
index 5b2a978..2d0e234 100644
--- a/fish_functions/venv.fish
+++ b/fish_functions/venv.fish
@@ -7,9 +7,41 @@ function venv
echo "Creating virtual environment in "(pwd)"/.venv"
python3 -m venv .venv --upgrade-deps
- if [ -f .git ]
+ if test -e .git
echo .venv >>.git/info/exclude
end
source .venv/bin/activate.fish
+
+ echo "Updating to the latest version of pip"
+ pip install --upgrade pip
+
+ # If we're in a trusted Git repository (one that I own) and we
+ # can see a requirements file, go ahead and install pip-tools
+ # and install the dependencies.
+ if test -e .git
+ set remote_url (git remote get-url origin)
+
+ set -a trusted_orgs "Flickr-Foundation" "alexwlchan"
+
+ for org in $trusted_orgs
+ if ! string match -q -- "git@github.com:$org/*" "$remote_url"
+ continue
+ end
+
+ echo "This repo is in in a trusted org; looking for dependencies"
+
+ if test -f dev_requirements.txt
+ echo "Installing dependencies from dev_requirements.txt"
+ pip install pip-tools
+ pip-sync dev_requirements.txt
+ else if test -f requirements.txt
+ echo "Installing dependencies from requirements.txt"
+ pip install pip-tools
+ pip-sync requirements.txt
+ else
+ echo "No requirements.txt file found; no dependencies installed"
+ end
+ end
+ end
end