Skip to content

Commit

Permalink
comparing python version 3.10 capable
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Wimmer committed Jul 30, 2024
1 parent 4ea94b8 commit f55e5ce
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions wodoo/module_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,13 @@ def extract_deps(data):

def _filter_requirements(self, pydeps, python_version):
assert isinstance(python_version, tuple)
str_python_version = ".".join(map(str, python_version))
# for string compare make 3.9 to 3.09
str_python_version = ".".join(
map(
lambda x: str(x) if len(str(x)) == 2 else "0" + str(x),
python_version[1:],
)
)

# keep highest version and or leaveout loosers
def _filter(x):
Expand Down Expand Up @@ -1006,9 +1012,7 @@ def _pydeps_filter_best_fit(self, pydeps):
result = set()
allowed = ["==", ">="]
unallowed = [
x
for x in pydeps
if not isinstance(x, str) and x[1][0] not in allowed
x for x in pydeps if not isinstance(x, str) and x[1][0] not in allowed
]
if unallowed:
raise Exception(f"Unhandled: {unallowed} - only {allowed} allowed")
Expand All @@ -1017,7 +1021,7 @@ def _pydeps_filter_best_fit(self, pydeps):
# mixed == and >=
reqs = pydeps.get(libname, [])

#handle case: reqs = [()]
# handle case: reqs = [()]
unspecific_ones = [x for x in reqs if not x]
if len(unspecific_ones) == len(reqs):
result.add(libname)
Expand Down Expand Up @@ -1056,12 +1060,13 @@ def _pydeps_filter_best_fit(self, pydeps):
result.add(f"{libname}{ge[-1][0]}{'.'.join(map(str, ge[-1][1]))}")
else:
if len(reqs) == 1:
result.add(f"{libname}{reqs[0][-1][0]}{'.'.join(map(str, reqs[0][-1][1]))}")
result.add(
f"{libname}{reqs[0][-1][0]}{'.'.join(map(str, reqs[0][-1][1]))}"
)
else:
result.add(libname)
return list(sorted(result))


def resolve_pydeps(self, pydeps, python_version):
pydeps = list(set(pydeps))

Expand Down

0 comments on commit f55e5ce

Please sign in to comment.