Skip to content

Commit a0e5c20

Browse files
committed
Add support for wasm32-unknown-emscripten via Pyodide
1 parent 97fe8e9 commit a0e5c20

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22

33
## Unreleased
4+
### Added
5+
- Add support for extension modules built for wasm32-unknown-emscripten with Pyodide.
6+
47
### Changed
58
- Locate cdylib artifacts by handling messages from cargo instead of searching target dir (fixes build on MSYS2). [#267](https://github.com/PyO3/setuptools-rust/pull/267)
69
- Fix RustBin build without wheel. [#273](https://github.com/PyO3/setuptools-rust/pull/273)

noxfile.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
import nox
99

10-
import nox
11-
1210

1311
@nox.session(name="test-examples", venv_backend="none")
1412
def test_examples(session: nox.Session):
@@ -92,7 +90,7 @@ def test_examples_emscripten(session: nox.Session):
9290
"nightly",
9391
external=True,
9492
)
95-
examples_dir = Path("examples")
93+
examples_dir = Path("examples").absolute()
9694
test_crates = [
9795
examples_dir / "html-py-ever",
9896
examples_dir / "namespace_package",

setuptools_rust/build.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import glob
44
import json
55
import os
6-
import pkg_resources
76
import platform
87
import shutil
98
import subprocess
@@ -20,6 +19,7 @@
2019
from pathlib import Path
2120
from typing import Dict, Iterable, List, NamedTuple, Optional, Set, Tuple, cast
2221

22+
import pkg_resources
2323
from setuptools.command.build import build as CommandBuild # type: ignore[import]
2424
from setuptools.command.build_ext import build_ext as CommandBuildExt
2525
from setuptools.command.build_ext import get_abi3_suffix
@@ -184,7 +184,7 @@ def build_extension(
184184
]
185185

186186
# OSX requires special linker arguments
187-
if sys.platform == "darwin":
187+
if rustc_cfgs.get("target_os") == "macos":
188188
ext_basename = os.path.basename(self.get_dylib_ext_path(ext, ext.name))
189189
rustc_args.extend(
190190
[
@@ -200,6 +200,12 @@ def build_extension(
200200
# the cdylib, see https://github.com/rust-lang/cargo/issues/10143
201201
rustflags.append("-Ctarget-feature=-crt-static")
202202

203+
elif (rustc_cfgs.get("target_arch"), rustc_cfgs.get("target_os")) == (
204+
"wasm32",
205+
"emscripten",
206+
):
207+
rustc_args.extend(["-C", f"link-args=-sSIDE_MODULE=2 -sWASM_BIGINT"])
208+
203209
command = [
204210
self.cargo,
205211
"rustc",

0 commit comments

Comments
 (0)