Skip to content

Commit

Permalink
Backport PR #1758 on branch 0.11.x (Harmonize min-deps script with sc…
Browse files Browse the repository at this point in the history
…anpy) (#1776)

Co-authored-by: Philipp A <[email protected]>
  • Loading branch information
meeseeksmachine and flying-sheep authored Nov 22, 2024
1 parent 0d43eb3 commit 0435670
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ci/scripts/min-deps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/usr/bin/env python3
# /// script
# dependencies = [
# "tomli; python_version < '3.11'",
# "packaging",
# ]
# ///

from __future__ import annotations

import argparse
Expand Down Expand Up @@ -33,12 +40,14 @@ def min_dep(req: Requirement) -> Requirement:
if req.extras:
req_name = f"{req_name}[{','.join(req.extras)}]"

specs = [spec for spec in req.specifier if spec.operator in {">", ">=", "~=", "=="}]
if not specs:
filter_specs = [
spec for spec in req.specifier if spec.operator in {"==", "~=", ">=", ">"}
]
if not filter_specs:
return Requirement(req_name)

min_version = Version("0.0.0.a1")
for spec in specs:
for spec in filter_specs:
if spec.operator in {">", ">=", "~="}:
min_version = max(min_version, Version(spec.version))
elif spec.operator == "==":
Expand Down

0 comments on commit 0435670

Please sign in to comment.