MCPcopy Create free account
hub / github.com/conda/constructor / parse_virtual_specs

Function parse_virtual_specs

constructor/utils.py:436–460  ·  view source on GitHub ↗
(info)

Source from the content-addressed store, hash-verified

434
435
436def parse_virtual_specs(info) -> dict:
437 from .conda_interface import MatchSpec # prevent circular import
438
439 specs = {"__osx": {}, "__glibc": {}}
440 for spec in info.get("virtual_specs", ()):
441 spec = MatchSpec(spec)
442 if spec.name not in ("__osx", "__glibc"):
443 continue
444 if not spec.version:
445 continue
446 if "|" in spec.version.spec_str:
447 raise ValueError("Can't process `|`-joined versions. Only `,` is allowed.")
448 versions = spec.version.tup if "," in spec.version.spec_str else (spec.version,)
449 for version in versions:
450 operator = version.operator_func.__name__
451 if operator == "ge":
452 specs[spec.name]["min"] = str(version.matcher_vo)
453 elif operator == "lt" and spec.name == "__osx":
454 specs[spec.name]["before"] = str(version.matcher_vo)
455 else:
456 raise ValueError(
457 f"Invalid version operator for {spec}. "
458 "__osx only supports `<` or `>=`; __glibc only supports `>=`."
459 )
460 return specs
461
462
463def has_docker_buildx() -> bool:

Callers 2

get_headerFunction · 0.85
modify_xmlFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected