Skip to content

Commit ebe83b9

Browse files
authored
Set wheel tag of cpython_module to cp312-cp312-pyodide_2025_0_wasm32 (#133)
We were tagging them py3-none-any which is not correct.
1 parent f294e20 commit ebe83b9

File tree

6 files changed

+86
-3
lines changed

6 files changed

+86
-3
lines changed

pyodide_build/common.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,18 @@ def modify_wheel(wheel: Path) -> Iterator[Path]:
362362
pack_wheel(wheel_dir, wheel.parent)
363363

364364

365-
def retag_wheel(wheel_path: Path, platform: str) -> Path:
365+
def retag_wheel(
366+
wheel_path: Path,
367+
platform: str,
368+
*,
369+
python: str | None = None,
370+
abi: str | None = None,
371+
) -> Path:
372+
extra_flags = []
373+
if python:
374+
extra_flags += ["--python-tag", python]
375+
if abi:
376+
extra_flags += ["--abi-tag", abi]
366377
result = subprocess.run(
367378
[
368379
sys.executable,
@@ -373,6 +384,7 @@ def retag_wheel(wheel_path: Path, platform: str) -> Path:
373384
"--platform-tag",
374385
platform,
375386
"--remove",
387+
*extra_flags,
376388
],
377389
check=False,
378390
encoding="utf-8",

pyodide_build/recipe/builder.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
get_build_environment_vars,
2525
get_build_flag,
2626
get_pyodide_root,
27+
get_pyversion_major,
28+
get_pyversion_minor,
2729
pyodide_tags,
2830
replace_so_abi_tags,
2931
wheel_platform,
@@ -555,7 +557,10 @@ def _package_wheel(
555557
+ "\n".join(f.name for f in self.src_dist_dir.glob("*.whl"))
556558
)
557559

558-
if "emscripten" in wheel.name:
560+
if self.package_type == "cpython_module":
561+
abi = f"cp{get_pyversion_major()}{get_pyversion_minor()}"
562+
wheel = retag_wheel(wheel, wheel_platform(), python=abi, abi=abi)
563+
elif "emscripten" in wheel.name:
559564
# Retag platformed wheels to pyodide
560565
wheel = retag_wheel(wheel, wheel_platform())
561566

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package:
2+
name: pydecimal
3+
version: 1.0.0 # Nonsense
4+
tag:
5+
- always
6+
top-level:
7+
- _pydecimal
8+
source:
9+
path: src
10+
build:
11+
type: cpython_module
12+
about:
13+
license: PSF
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("hi!")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[project]
2+
name = "pydecimal"
3+
authors = [
4+
{ name= "Pyodide" },
5+
]
6+
description = "Unvendored pydecimal for Pyodide"
7+
version = "1.0.0"
8+
9+
[build-system]
10+
requires = ["hatchling"]
11+
build-backend = "hatchling.build"
12+
13+
[tool.hatch.build.targets.sdist]
14+
ignore-vcs = true
15+
16+
[tool.hatch.build.targets.wheel]
17+
ignore-vcs = true
18+
include = [
19+
"_pydecimal.py",
20+
]
21+
exclude = [
22+
"Python-*",
23+
]

pyodide_build/tests/test_cli.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_build_recipe_plain(tmp_path, dummy_xbuildenv, mock_emscripten):
8383
"pkg_test_graph3": {},
8484
}
8585

86-
pkgs_to_build = pkgs.keys() | {p for v in pkgs.values() for p in v}
86+
pkgs_to_build = pkgs.keys() | {p for v in pkgs.values() for p in v} | {"pydecimal"}
8787

8888
for build_dir in RECIPE_DIR.rglob("build"):
8989
shutil.rmtree(build_dir)
@@ -551,3 +551,32 @@ def run(srcdir, outdir, exports, config_settings):
551551
"--key3": "",
552552
"--key4": "--value4",
553553
}
554+
555+
556+
def test_build_cpython_module(tmp_path, dummy_xbuildenv, mock_emscripten):
557+
for build_dir in RECIPE_DIR.rglob("build"):
558+
shutil.rmtree(build_dir)
559+
560+
app = typer.Typer()
561+
app.command()(build_recipes.build_recipes_no_deps)
562+
563+
pkg = "pydecimal"
564+
for recipe in RECIPE_DIR.glob("**/meta.yaml"):
565+
recipe.touch()
566+
result = runner.invoke(
567+
app,
568+
[
569+
pkg,
570+
"--recipe-dir",
571+
str(RECIPE_DIR),
572+
],
573+
)
574+
assert_runner_succeeded(result)
575+
576+
assert f"Succeeded building package {pkg}" in result.stdout
577+
578+
dist_dir = RECIPE_DIR / pkg / "dist"
579+
results = list(dist_dir.glob("*.whl"))
580+
assert len(results) == 1
581+
result = results[0]
582+
assert result.name == "pydecimal-1.0.0-cp312-cp312-pyodide_2024_0_wasm32.whl"

0 commit comments

Comments
 (0)