Skip to content

Commit

Permalink
Add support for evaluating requirement markers
Browse files Browse the repository at this point in the history
  • Loading branch information
jk464 committed Nov 7, 2023
1 parent 38a7f74 commit 61b47db
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/fixate-requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
# Do not error, as will only use on pip >= 20
pass

from packaging.requirements import Requirement


def parse_args():
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -190,6 +192,12 @@ def write_requirements(
if not req.req:
continue

# If the requirement has markers, and they don't meet the
# current environment ignore this requirement
packaging_req = Requirement(req.requirement)
if packaging_req.marker and not packaging_req.marker.evaluate():
continue

if project_name in fixedreq_hash:
raise ValueError(
'Duplicate definition for dependency "%s"' % (project_name)
Expand Down

0 comments on commit 61b47db

Please sign in to comment.