Skip to content

Commit

Permalink
Fix PKG os-version control
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimergp committed Jul 12, 2024
1 parent 8600666 commit adcbab9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CONSTRUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ A list of virtual packages that must be satisfied at install time. Virtual
packages must start with `__`. For example, `__osx>=11` or `__glibc>=2.24`.
These specs are dry-run solved offline by the bundled `--conda-exe` binary.
In PKG installers, `__osx` specs can be checked natively without the solver
being involved as long as only `>=`, `<=` or `,` are used.
being involved as long as only `>=`, `<` or `,` are used.

### `exclude`

Expand Down
2 changes: 1 addition & 1 deletion constructor/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
packages must start with `__`. For example, `__osx>=11` or `__glibc>=2.24`.
These specs are dry-run solved offline by the bundled `--conda-exe` binary.
In PKG installers, `__osx` specs can be checked natively without the solver
being involved as long as only `>=`, `<=` or `,` are used.
being involved as long as only `>=`, `<` or `,` are used.
'''),

('exclude', False, list, '''
Expand Down
10 changes: 7 additions & 3 deletions constructor/osxpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def modify_xml(xml_path, info):
root.append(readme)

# -- __osx virtual package checks -- #
# Reference: https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/DistributionDefinitionRef/Chapters/Distribution_XML_Ref.html
osx_versions = {}
for spec in info.get("virtual_specs", ()):
spec = MatchSpec(spec)
Expand All @@ -204,13 +205,16 @@ def modify_xml(xml_path, info):
operator = version.operator_func.__name__
if operator == "ge":
osx_versions["min"] = str(version.matcher_vo)
elif operator == "le":
osx_versions["max"] = str(version.matcher_vo)
elif operator == "lt":
osx_versions["before"] = str(version.matcher_vo)
else:
raise ValueError(
f"Invalid version operator for {spec}. Only `<=` or `>=` are supported.")
f"Invalid version operator for {spec}. Only `<` or `>=` are supported."
)

if osx_versions:
if "min" not in osx_versions:
raise ValueError("Specifying __osx requires a lower bound with `>=`")
allowed_os_versions = ET.Element("allowed-os-versions")
allowed_os_versions.append(ET.Element("os-version", osx_versions))
volume_check = ET.Element("volume-check")
Expand Down
2 changes: 1 addition & 1 deletion docs/source/construct-yaml.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ A list of virtual packages that must be satisfied at install time. Virtual
packages must start with `__`. For example, `__osx>=11` or `__glibc>=2.24`.
These specs are dry-run solved offline by the bundled `--conda-exe` binary.
In PKG installers, `__osx` specs can be checked natively without the solver
being involved as long as only `>=`, `<=` or `,` are used.
being involved as long as only `>=`, `<` or `,` are used.

### `exclude`

Expand Down
2 changes: 1 addition & 1 deletion examples/virtual_specs/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ specs:
- ca-certificates

virtual_specs:
- __osx<=9 # [osx]
- __osx>=5.1,<9 # [osx]
- __glibc>=20 # [linux]
- __win<0 # [win]

Expand Down

0 comments on commit adcbab9

Please sign in to comment.