Skip to main content

Add a shortcut for compiling requirements.txt files with uv

ID
5d325ea
date
2024-06-02 09:07:02+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
bceac54
message
Add a shortcut for compiling `requirements.txt` files with `uv`

For https://github.com/alexwlchan/alexwlchan/issues/9
changed files
2 files, 23 additions, 1 deletion

Changed files

fish_functions/README.md (3640) → fish_functions/README.md (3858)

diff --git a/fish_functions/README.md b/fish_functions/README.md
index f7c16db..e5db2dd 100644
--- a/fish_functions/README.md
+++ b/fish_functions/README.md
@@ -96,6 +96,15 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=functions)
   </dd>
 
   <dt>
+    <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/pip_compile.fish">
+      <code>pip_compile.fish</code>
+    </a>
+  </dt>
+  <dd>
+    Create requirements.txt lock files with uv
+  </dd>
+
+  <dt>
     <a href="https://github.com/alexwlchan/scripts/blob/main/fish_functions/pyfmt.fish">
       <code>pyfmt.fish</code>
     </a>
@@ -131,4 +140,4 @@ cog_helpers.create_description_table(folder_name=folder_name, scripts=functions)
     Create and activate a new virtual environment
   </dd>
 </dl>
-<!-- [[[end]]] (checksum: 4227fcb9e8480fc60a86505c13b16c42) -->
\ No newline at end of file
+<!-- [[[end]]] (checksum: b252f415053e97cb4e0110ae9131b55e) -->
\ No newline at end of file

fish_functions/pip_compile.fish (0) → fish_functions/pip_compile.fish (595)

diff --git a/fish_functions/pip_compile.fish b/fish_functions/pip_compile.fish
new file mode 100644
index 0000000..88f7701
--- /dev/null
+++ b/fish_functions/pip_compile.fish
@@ -0,0 +1,13 @@
+function pip_compile --description "Create requirements.txt lock files with uv"
+    if test \( -e requirements.in \) -a \( -e overrides.txt \)
+        uv pip compile requirements.in --output-file requirements.txt --override overrides.txt
+    else
+        uv pip compile requirements.in --output-file requirements.txt
+    end
+
+    if test \( -e dev_requirements.in \) -a \( -e overrides.txt \)
+        uv pip compile dev_requirements.in --output-file dev_requirements.txt --override overrides.txt
+    else
+        uv pip compile dev_requirements.in --output-file dev_requirements.txt
+    end
+end