Skip to content

Commit f80d060

Browse files
authored
Merge branch 'main' into cross-python
2 parents df4b04c + 141732a commit f80d060

File tree

8 files changed

+312
-125
lines changed

8 files changed

+312
-125
lines changed

conda-lock.yml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -701,47 +701,47 @@ package:
701701
python-dateutil: '>=2.1,<3.0.0'
702702
urllib3: '>=1.25.4,!=2.2.0,<3'
703703
hash:
704-
md5: 2d2150ea873387c525a28755c976291f
705-
sha256: f814c6cd184bf7526ef1770fc3e5c33d5f4c4867991d5b2713323599d7911f16
704+
md5: 197f85e572eb35418f60f85ad0a211e7
705+
sha256: 1843a8bdf37d220beed37764b550922fd737838253b32f068fa718c35c7223e4
706706
manager: conda
707707
name: botocore
708708
optional: false
709709
platform: linux-64
710710
url:
711-
https://conda.anaconda.org/conda-forge/noarch/botocore-1.37.18-pyge310_1234567_0.conda
712-
version: 1.37.18
711+
https://conda.anaconda.org/conda-forge/noarch/botocore-1.37.19-pyge310_1234567_0.conda
712+
version: 1.37.19
713713
- category: main
714714
dependencies:
715715
jmespath: '>=0.7.1,<2.0.0'
716716
python: '>=3.10'
717717
python-dateutil: '>=2.1,<3.0.0'
718718
urllib3: '>=1.25.4,!=2.2.0,<3'
719719
hash:
720-
md5: 2d2150ea873387c525a28755c976291f
721-
sha256: f814c6cd184bf7526ef1770fc3e5c33d5f4c4867991d5b2713323599d7911f16
720+
md5: 197f85e572eb35418f60f85ad0a211e7
721+
sha256: 1843a8bdf37d220beed37764b550922fd737838253b32f068fa718c35c7223e4
722722
manager: conda
723723
name: botocore
724724
optional: false
725725
platform: osx-64
726726
url:
727-
https://conda.anaconda.org/conda-forge/noarch/botocore-1.37.18-pyge310_1234567_0.conda
728-
version: 1.37.18
727+
https://conda.anaconda.org/conda-forge/noarch/botocore-1.37.19-pyge310_1234567_0.conda
728+
version: 1.37.19
729729
- category: main
730730
dependencies:
731731
jmespath: '>=0.7.1,<2.0.0'
732732
python: '>=3.10'
733733
python-dateutil: '>=2.1,<3.0.0'
734734
urllib3: '>=1.25.4,!=2.2.0,<3'
735735
hash:
736-
md5: 2d2150ea873387c525a28755c976291f
737-
sha256: f814c6cd184bf7526ef1770fc3e5c33d5f4c4867991d5b2713323599d7911f16
736+
md5: 197f85e572eb35418f60f85ad0a211e7
737+
sha256: 1843a8bdf37d220beed37764b550922fd737838253b32f068fa718c35c7223e4
738738
manager: conda
739739
name: botocore
740740
optional: false
741741
platform: osx-arm64
742742
url:
743-
https://conda.anaconda.org/conda-forge/noarch/botocore-1.37.18-pyge310_1234567_0.conda
744-
version: 1.37.18
743+
https://conda.anaconda.org/conda-forge/noarch/botocore-1.37.19-pyge310_1234567_0.conda
744+
version: 1.37.19
745745
- category: main
746746
dependencies:
747747
__glibc: '>=2.17,<3.0.a0'
@@ -2104,39 +2104,39 @@ package:
21042104
- category: main
21052105
dependencies: {}
21062106
hash:
2107-
md5: 949519bf61c21c9db15f19f67a08a5b9
2108-
sha256: 54cbf4a99778316e05a7c646a92681e2694ee104fa637b5f435d4e6a1da818f6
2107+
md5: 70a927214f86c015bc968a3a9191effd
2108+
sha256: 6b215f2483afc2e36d01c4cc537a02bf3dcc9c8c6fb1bbd1ec6ac3471cee3435
21092109
manager: conda
21102110
name: conda-forge-pinning
21112111
optional: false
21122112
platform: linux-64
21132113
url:
2114-
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.23.21.47.32-hd8ed1ab_0.conda
2115-
version: 2025.03.23.21.47.32
2114+
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.25.13.35.37-hd8ed1ab_0.conda
2115+
version: 2025.03.25.13.35.37
21162116
- category: main
21172117
dependencies: {}
21182118
hash:
2119-
md5: 949519bf61c21c9db15f19f67a08a5b9
2120-
sha256: 54cbf4a99778316e05a7c646a92681e2694ee104fa637b5f435d4e6a1da818f6
2119+
md5: 70a927214f86c015bc968a3a9191effd
2120+
sha256: 6b215f2483afc2e36d01c4cc537a02bf3dcc9c8c6fb1bbd1ec6ac3471cee3435
21212121
manager: conda
21222122
name: conda-forge-pinning
21232123
optional: false
21242124
platform: osx-64
21252125
url:
2126-
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.23.21.47.32-hd8ed1ab_0.conda
2127-
version: 2025.03.23.21.47.32
2126+
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.25.13.35.37-hd8ed1ab_0.conda
2127+
version: 2025.03.25.13.35.37
21282128
- category: main
21292129
dependencies: {}
21302130
hash:
2131-
md5: 949519bf61c21c9db15f19f67a08a5b9
2132-
sha256: 54cbf4a99778316e05a7c646a92681e2694ee104fa637b5f435d4e6a1da818f6
2131+
md5: 70a927214f86c015bc968a3a9191effd
2132+
sha256: 6b215f2483afc2e36d01c4cc537a02bf3dcc9c8c6fb1bbd1ec6ac3471cee3435
21332133
manager: conda
21342134
name: conda-forge-pinning
21352135
optional: false
21362136
platform: osx-arm64
21372137
url:
2138-
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.23.21.47.32-hd8ed1ab_0.conda
2139-
version: 2025.03.23.21.47.32
2138+
https://conda.anaconda.org/conda-forge/noarch/conda-forge-pinning-2025.03.25.13.35.37-hd8ed1ab_0.conda
2139+
version: 2025.03.25.13.35.37
21402140
- category: main
21412141
dependencies:
21422142
click: '>=8'
@@ -9183,45 +9183,45 @@ package:
91839183
python: '>=3.11,<3.12.0a0'
91849184
python_abi: 3.11.*
91859185
hash:
9186-
md5: 19615e39755eac6975671b8a679f7088
9187-
sha256: 2626f5c211749d1e5632c81d92313677e0c537f1376f397432976379db2dabc4
9186+
md5: a0b45a3ae748e3cce6409cb12664bf2b
9187+
sha256: 20ecfaf61224ea92dadb543ee5ca3757e4feff4524c9d6633de908d11f4c5cd4
91889188
manager: conda
91899189
name: orjson
91909190
optional: false
91919191
platform: linux-64
91929192
url:
9193-
https://conda.anaconda.org/conda-forge/linux-64/orjson-3.10.15-py311h9e33e62_0.conda
9194-
version: 3.10.15
9193+
https://conda.anaconda.org/conda-forge/linux-64/orjson-3.10.16-py311h9e33e62_0.conda
9194+
version: 3.10.16
91959195
- category: main
91969196
dependencies:
91979197
__osx: '>=10.13'
91989198
python: '>=3.11,<3.12.0a0'
91999199
python_abi: 3.11.*
92009200
hash:
9201-
md5: a1b4c1e9c26279ae4dcbd4319dffb541
9202-
sha256: 0015c2a458bea689eb5af205bc30770ca3c51e68a23aa9ee0ae2f84282ac11b5
9201+
md5: cb8506609560dbdc5dfc31be0a11f3b5
9202+
sha256: 02b79f1ab9a745a542fd9fa361890ea1b99764fb91a1637d7a64e5bd9c699c96
92039203
manager: conda
92049204
name: orjson
92059205
optional: false
92069206
platform: osx-64
92079207
url:
9208-
https://conda.anaconda.org/conda-forge/osx-64/orjson-3.10.15-py311h3b9c2be_0.conda
9209-
version: 3.10.15
9208+
https://conda.anaconda.org/conda-forge/osx-64/orjson-3.10.16-py311h3b9c2be_0.conda
9209+
version: 3.10.16
92109210
- category: main
92119211
dependencies:
92129212
__osx: '>=11.0'
92139213
python: '>=3.11,<3.12.0a0'
92149214
python_abi: 3.11.*
92159215
hash:
9216-
md5: 1c10494123be62099e1afaa0ea746786
9217-
sha256: 5f34f758aa88da54af624e5bd8e8f19f0cc36acf3f1792efbd4c59748ffa9b7a
9216+
md5: 8d735e647d8e06b1e33ecd296070de34
9217+
sha256: 2f9f6d2541a903ce91f5af8bf31b39d678d7e569c802e73f7c2e2ca91eb763f2
92189218
manager: conda
92199219
name: orjson
92209220
optional: false
92219221
platform: osx-arm64
92229222
url:
9223-
https://conda.anaconda.org/conda-forge/osx-arm64/orjson-3.10.15-py311h3ff9189_0.conda
9224-
version: 3.10.15
9223+
https://conda.anaconda.org/conda-forge/osx-arm64/orjson-3.10.16-py311h3ff9189_0.conda
9224+
version: 3.10.16
92259225
- category: main
92269226
dependencies:
92279227
python: '>=3.8'

conda_forge_tick/migrators/cross_compile.py

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -345,20 +345,24 @@ def migrate(self, recipe_dir: str, attrs: "AttrsTypedDict", **kwargs: Any) -> No
345345
"""
346346

347347

348-
class CrossRBaseMigrator(CrossCompilationMigratorBase):
348+
class CrossRBaseMigrator(MiniMigrator):
349+
allowed_schema_versions = {0, 1}
350+
post_migration = True
351+
349352
def filter(self, attrs: "AttrsTypedDict", not_bad_str_start: str = "") -> bool:
353+
if super().filter(attrs, not_bad_str_start):
354+
return True
355+
350356
host_reqs = attrs.get("requirements", {}).get("host", set())
351-
skip_schema = skip_migrator_due_to_schema(attrs, self.allowed_schema_versions)
352-
if (
353-
"r-base" in host_reqs or attrs.get("name", "").startswith("r-")
354-
) and not skip_schema:
357+
if "r-base" in host_reqs or attrs.get("name", "").startswith("r-"):
355358
return False
356359
else:
357360
return True
358361

359362
def migrate(self, recipe_dir: str, attrs: "AttrsTypedDict", **kwargs: Any) -> None:
360363
with pushd(recipe_dir):
361-
with open("meta.yaml") as fp:
364+
recipe_file = next(filter(os.path.exists, ("recipe.yaml", "meta.yaml")))
365+
with open(recipe_file) as fp:
362366
meta_yaml = fp.readlines()
363367

364368
new_lines = []
@@ -367,10 +371,20 @@ def migrate(self, recipe_dir: str, attrs: "AttrsTypedDict", **kwargs: Any) -> No
367371
for line in meta_yaml:
368372
if previous_was_build:
369373
nspaces = len(line) - len(line.lstrip())
370-
new_lines.append(
371-
" " * nspaces
372-
+ "- cross-r-base {{ r_base }} # [build_platform != target_platform]\n",
373-
)
374+
if recipe_file == "recipe.yaml":
375+
new_lines.extend(
376+
[
377+
" " * nspaces
378+
+ "- if: build_platform != host_platform\n",
379+
" " * nspaces + " then:\n",
380+
" " * nspaces + " - cross-r-base ${{ r_base }}\n",
381+
]
382+
)
383+
else:
384+
new_lines.append(
385+
" " * nspaces
386+
+ "- cross-r-base {{ r_base }} # [build_platform != target_platform]\n",
387+
)
374388
# Add host R requirements to build
375389
host_reqs = attrs.get("requirements", {}).get("host", set())
376390
r_host_reqs = [
@@ -379,15 +393,18 @@ def migrate(self, recipe_dir: str, attrs: "AttrsTypedDict", **kwargs: Any) -> No
379393
if req.startswith("r-") and req != "r-base"
380394
]
381395
for r_req in r_host_reqs:
382-
# Ensure nice formatting
383-
post_nspaces = max(0, 25 - len(r_req))
384-
new_lines.append(
385-
" " * nspaces
386-
+ "- "
387-
+ r_req
388-
+ " " * post_nspaces
389-
+ " # [build_platform != target_platform]\n",
390-
)
396+
if recipe_file == "recipe.yaml":
397+
new_lines.append(" " * nspaces + f" - {r_req}\n")
398+
else:
399+
# Ensure nice formatting
400+
post_nspaces = max(0, 25 - len(r_req))
401+
new_lines.append(
402+
" " * nspaces
403+
+ "- "
404+
+ r_req
405+
+ " " * post_nspaces
406+
+ " # [build_platform != target_platform]\n",
407+
)
391408
in_req = False
392409
previous_was_build = False
393410
if "requirements:" in line:
@@ -396,7 +413,7 @@ def migrate(self, recipe_dir: str, attrs: "AttrsTypedDict", **kwargs: Any) -> No
396413
previous_was_build = True
397414
new_lines.append(line)
398415

399-
with open("meta.yaml", "w") as f:
416+
with open(recipe_file, "w") as f:
400417
f.write("".join(new_lines))
401418

402419
if os.path.exists("build.sh"):

conda_forge_tick/migrators/recipe_v1.py

Lines changed: 32 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,43 @@
1212
logger = logging.getLogger(__name__)
1313

1414

15-
def combine_conditions(node):
15+
def is_same_condition(a: Any, b: Any) -> bool:
16+
return (
17+
isinstance(a, dict)
18+
and isinstance(b, dict)
19+
and "if" in a
20+
and "if" in b
21+
and a["if"] == b["if"]
22+
)
23+
24+
25+
def fold_branch(source: Any, dest: Any, branch: str) -> None:
26+
if branch not in source:
27+
return
28+
source_l = source[branch]
29+
if isinstance(source_l, str):
30+
source_l = [source_l]
31+
32+
if branch not in dest:
33+
dest[branch] = []
34+
elif isinstance(dest[branch], str):
35+
dest[branch] = [dest[branch]]
36+
dest[branch].extend(source_l)
37+
38+
39+
def combine_conditions(node: Any):
1640
"""Breadth first recursive call to combine list conditions"""
1741

1842
# recursion is breadth first because we go through each element here
1943
# before calling `combine_conditions` on any element in the node
2044
if isinstance(node, list):
21-
# 1. loop through list elements, gather the if conditions
22-
23-
# condition ("if:") -> [(then, else), (then, else)...]
24-
conditions = {}
25-
26-
for i in node:
27-
if isinstance(i, dict) and "if" in i:
28-
conditions.setdefault(i["if"], []).append((i["then"], i.get("else")))
29-
30-
# 2. if elements share a compatible if condition
31-
# combine their if...then...else statements
32-
to_drop = []
33-
for i in range(len(node)):
34-
if isinstance(node[i], dict) and "if" in node[i]:
35-
condition = node[i]["if"]
36-
if condition not in conditions:
37-
# already combined it, so drop the repeat instance
38-
to_drop.append(i)
39-
continue
40-
if len(conditions[condition]) > 1:
41-
new_then = []
42-
new_else = []
43-
for sub_then, sub_else in conditions[node[i]["if"]]:
44-
if isinstance(sub_then, list):
45-
new_then.extend(sub_then)
46-
else:
47-
assert sub_then is not None
48-
new_then.append(sub_then)
49-
if isinstance(sub_else, list):
50-
new_else.extend(sub_else)
51-
elif sub_else is not None:
52-
new_else.append(sub_else)
53-
node[i]["then"] = new_then
54-
if new_else:
55-
# TODO: preserve inline "else" instead of converting it to a list?
56-
node[i]["else"] = new_else
57-
else:
58-
assert "else" not in node[i]
59-
# remove it from the dict, so we don't output it again
60-
del conditions[condition]
61-
62-
# drop the repeated conditions
63-
for i in reversed(to_drop):
64-
del node[i]
45+
# iterate in reverse order, so we can remove elements on the fly
46+
# start at index 1, since we can only fold to the previous node
47+
for i in reversed(range(1, len(node))):
48+
if is_same_condition(node[i], node[i - 1]):
49+
fold_branch(node[i], node[i - 1], "then")
50+
fold_branch(node[i], node[i - 1], "else")
51+
del node[i]
6552

6653
# then we descend down the tree
6754
if isinstance(node, dict):

0 commit comments

Comments
 (0)