Skip to main content

Only run pip compile with pip_sync if I ask

ID
7c91cdf
date
2025-05-04 22:34:57+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
348148a
message
Only run `pip compile` with `pip_sync` if I ask
changed files
1 file, 9 additions, 3 deletions

Changed files

fish_functions/pip_sync.fish (1017) → fish_functions/pip_sync.fish (1242)

diff --git a/fish_functions/pip_sync.fish b/fish_functions/pip_sync.fish
index bb11274..f615ce5 100644
--- a/fish_functions/pip_sync.fish
+++ b/fish_functions/pip_sync.fish
@@ -1,13 +1,19 @@
 function pip_sync --description "Make a virtualenv dependencies look like requirements.txt"
 
-    # Run the `pip compile` script to get a set of version pins.
-    pip_compile $argv
-
     # If there isn't a virtualenv already, create one
     if test -z "$VIRTUAL_ENV"
         venv
     end
 
+    # If there are no `requirements.txt` files, run my `pip compile`
+    # script to create a set of version pins.
+    if not test -e requirements.txt; and not test -e dev_requirements.txt; or contains -- --compile $argv;
+        or contains -- --upgrade $argv
+        pip_compile $argv
+
+        echo ""
+    end
+
     # If we're on an external disk, disable the warning about being
     # unable to clone files.  In particular:
     #