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

Invalid versions outside nixpkgs #567

Merged
merged 2 commits into from
Jul 10, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/extractor/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ let
mkdir $out
echo "extracting dependencies"
SETUPTOOLS_USE_DISTUTILS=stdlib out_file=$out/python.json ${py}/bin/python -c "${setuptools_shim}" install &> $out/python.log || true
cat $out/python.log
'';
base_derivation = pyVersions: with pkgs; {
buildInputs = [ unzip pkg-config ];
Expand Down
74 changes: 47 additions & 27 deletions mach_nix/data/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import distlib.markers
from pkg_resources import RequirementParseError
import packaging

from mach_nix.requirements import filter_reqs_by_eval_marker, Requirement, parse_reqs, context, filter_versions
from mach_nix.versions import PyVer, parse_ver, Version
Expand Down Expand Up @@ -313,13 +314,20 @@ def __init__(self, data_dir: str, *args, **kwargs):
def all_candidates(self, pkg_name, extras, builds) -> List[Candidate]:
if builds:
return []
return [Candidate(
w.name,
parse_ver(w.ver),
w.ver,
extras,
provider_info=ProviderInfo(provider=self, wheel_fname=w.fn, data=w)
) for w in self._suitable_wheels(pkg_name)]
result = []
for w in self._suitable_wheels(pkg_name):
try:
result.append(Candidate(
w.name,
parse_ver(w.ver),
w.ver,
extras,
provider_info=ProviderInfo(provider=self, wheel_fname=w.fn, data=w)
))
except packaging.version.InvalidVersion:
print(f"Error parsing (wheel) {w.name} version '{w.ver}")
continue
return result

def get_pkg_reqs(self, c: Candidate) -> Tuple[List[Requirement], List[Requirement]]:
"""
Expand Down Expand Up @@ -479,13 +487,21 @@ def get_pkg_reqs(self, c: Candidate) -> Tuple[List[Requirement], List[Requiremen
def all_candidates(self, pkg_name, extras, builds) -> Iterable[Candidate]:
if builds:
return []
return [Candidate(
pkg_name,
parse_ver(ver),
ver,
extras,
provider_info=ProviderInfo(self, data=pkg)
) for ver, pkg in self._get_candidates(pkg_name).items()]
result = []
for ver, pkg in self._get_candidates(pkg_name).items():
try:
result.append(
Candidate(
pkg_name,
parse_ver(ver),
ver,
extras,
provider_info=ProviderInfo(self, data=pkg)
))
except packaging.version.InvalidVersion:
print(f"Error parsing (sdist) {pkg} version '{ver}")
continue
return result


def conda_virtual_packages():
Expand Down Expand Up @@ -601,19 +617,23 @@ def all_candidates(self, pkg_name, extras, builds) -> Iterable[Candidate]:
else:
url = f"https://anaconda.org/{self.channel}/{p['name']}/" \
f"{p['version']}/download/{p['subdir']}/{p['fname']}"
candidates.append(Candidate(
p['name'],
parse_ver(p['version']),
p['version'],
selected_extras=tuple(),
build=p['build'],
provider_info=ProviderInfo(
self,
url=url,
hash=p['sha256'],
data=p,
)
))
try:
candidates.append(Candidate(
p['name'],
parse_ver(p['version']),
p['version'],
selected_extras=tuple(),
build=p['build'],
provider_info=ProviderInfo(
self,
url=url,
hash=p['sha256'],
data=p,
)
))
except packaging.version.InvalidVersion:
print(f"Error parsing (conda) {p['name']} version '{p['version']}")
continue
if 'collisions' in p:
print(
f"WARNING: Colliding conda package in channel '{self.channel}' "
Expand Down