Repository navigation
Expand file tree
/
Copy pathpackage_spec.py
More file actions
68 lines (59 loc) · 2.16 KB
/
Copy pathpackage_spec.py
File metadata and controls
68 lines (59 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Data Parallel Control (dpctl)
#
# Copyright 2026 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Prints the conda specs that install the one built dpctl package in a channel.
For intel-ci.yml's examples jobs, as GITHUB_ENV lines: DPCTL_SPEC names the
package's exact version and build, so the solver cannot take conda-forge's
dpctl instead, and PYTHON_SPEC is the version's spec as
conda-recipe/conda_build_config.yaml declares it, with its ABI, such as
3.15.* *_cp315t for 3.15t or 3.12.* *_cpython for 3.12.
Usage:
python ci/package_spec.py CHANNEL PYTHON
"""
import sys
from pathlib import Path
import matrix
def main() -> int:
"""Prints DPCTL_SPEC and PYTHON_SPEC."""
if len(sys.argv) != 3:
print(__doc__.strip().splitlines()[-1].strip(), file=sys.stderr)
return 2
channel, python = Path(sys.argv[1]), sys.argv[2]
packages = sorted(channel.glob("*/dpctl-*.conda"))
if len(packages) != 1:
print(
f"package_spec: {len(packages)} dpctl packages in {channel}, "
"not one",
file=sys.stderr,
)
return 1
specs = {
declared.version: declared.spec
for declared in matrix.declared(*matrix.detect(matrix.ROOT))
}
if python not in specs:
print(
f"package_spec: Python {python} is not declared; "
f'declared: {", ".join(specs)}',
file=sys.stderr,
)
return 1
_, version, build = packages[0].name[: -len(".conda")].split("-")
print(f"DPCTL_SPEC=dpctl={version}={build}")
print(f"PYTHON_SPEC=python {specs[python]}")
return 0
if __name__ == "__main__":
sys.exit(main())