Skip to content

Commit 512596e

Browse files
committed
Add package name extraction function in install_dev_deps.py
- Introduce get_package_name function to cleanly extract package names from dependency strings, removing version specifiers. - Update conda and pip dependency filtering to utilize the new function for improved accuracy in dependency management.
1 parent 8dbde18 commit 512596e

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

install_dev_deps.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@
2020
CORE_PACKAGES = {"gdal"}
2121

2222

23+
def get_package_name(dep):
24+
"""Extract the package name from a dependency string, removing version specifiers."""
25+
return (
26+
dep.split(">=")[0]
27+
.split("==")[0]
28+
.split("<=")[0]
29+
.split("~=")[0]
30+
.split("!=")[0]
31+
.strip()
32+
)
33+
34+
2335
def install_deps():
2436
logger.info("\n=== Starting install_dev_deps.py ===")
2537

@@ -65,12 +77,16 @@ def install_deps():
6577
logger.info("\nSplitting dependencies between conda and pip...")
6678
# Remove core packages and pip-only packages from conda installation
6779
conda_deps = [
68-
dep for dep in all_deps if dep not in PIP_PACKAGES and dep not in CORE_PACKAGES
80+
dep
81+
for dep in all_deps
82+
if get_package_name(dep) not in PIP_PACKAGES
83+
and get_package_name(dep) not in CORE_PACKAGES
6984
]
7085
pip_deps = [
7186
dep
7287
for dep in all_deps
73-
if dep in PIP_PACKAGES and dep.lower() not in CONDA_ONLY_PACKAGES
88+
if get_package_name(dep) in PIP_PACKAGES
89+
and get_package_name(dep).lower() not in CONDA_ONLY_PACKAGES
7490
]
7591

7692
logger.info("Packages to install via conda: %d", len(conda_deps))

0 commit comments

Comments
 (0)