Add option to add git repositories as dependencies (#542)
authorMarvin Schenkel <marvinschenkel@gmail.com>
Fri, 17 Mar 2023 09:50:37 +0000 (10:50 +0100)
committerGitHub <noreply@github.com>
Fri, 17 Mar 2023 09:50:37 +0000 (10:50 +0100)
This PR adds the possibility to add git repositories as pip
dependencies.

script/gen_requirements_all.py

index 8ac9e13f0a048582eb35acc04cc978b635806e30..640c3f4923104f082ff3e2dc036d339ab1ad4cc2 100644 (file)
@@ -10,6 +10,7 @@ import tomllib
 from pathlib import Path
 
 PACKAGE_REGEX = re.compile(r"^(?:--.+\s)?([-_\.\w\d]+).*==.+$")
+GIT_REPO_REGEX = re.compile(r"^(git\+https:\/\/[-_\.\w\d\/]+[@-_\.\w\d\/]*)$")
 
 
 def gather_core_requirements() -> list[str]:
@@ -60,17 +61,18 @@ def main() -> int:
     for req_str in core_reqs + extra_reqs:
         if match := PACKAGE_REGEX.search(req_str):
             package_name = match.group(1).lower().replace("_", "-")
-            if package_name in final_requirements:
-                # duplicate package without version is safe to ignore
-                print("ignoring %s" % package_name)
-                continue
+        elif match := GIT_REPO_REGEX.search(req_str):
+            package_name = match.group(1)
+        elif package_name in final_requirements:
+            # duplicate package without version is safe to ignore
+            continue
         else:
             print("Found requirement without version specifier: %s" % req_str)
             package_name = req_str
 
         existing = final_requirements.get(package_name)
         if existing:
-            print(f"WARNING: ignore duplicate package: {package_name} - existing: {existing}")
+            print("WARNING: ignore duplicate package: %s - existing: %s" % package_name, existing)
             continue
         final_requirements[package_name] = req_str