Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 549 #563

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion mach_nix/data/nixpkgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import UserDict
from dataclasses import dataclass
from typing import List
import packaging.version

from mach_nix.cache import cached
from mach_nix.versions import parse_ver, Version
Expand Down Expand Up @@ -29,7 +30,11 @@ def __init__(self, nixpkgs_json_file, **kwargs):
if nix_data is None:
continue
pname = nix_data["pname"]
version = parse_ver(nix_data["version"])
try:
version = parse_ver(nix_data["version"])
except packaging.version.InvalidVersion as e:
print("omitting nixpkgs / ", pname, " version was invalid: '", nix_data["version"], "'", sep="")
continue
pname_key = pname.replace("_", "-").lower()
if pname_key not in self.data:
self.data[pname_key] = {}
Expand Down
5 changes: 2 additions & 3 deletions mach_nix/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,10 @@ def parse_reqs_line(line):

return name, extras, all_specs, build, marker


@cached(keyfunc=lambda args: hash((tuple(args[0]), args[1])))
def filter_versions(
versions: List[Version],
req: Requirement):
req: Requirement) -> List[Version]:
"""
Reduces a given list of versions to contain only versions
which are allowed according to the given specifiers
Expand All @@ -202,7 +201,7 @@ def filter_versions(
if not req.specs:
# We filter version with an empty specifier set, since that will filter
# out prerelease, if there are any other releases.
return SpecifierSet().filter(versions)
return list(SpecifierSet().filter(versions)) # return a list in both cases
matched_versions = []
for specs in req.specs:
matched_versions.extend(
Expand Down