From 41823b37323bda4efd0f86c815af7d108993c282 Mon Sep 17 00:00:00 2001 From: David Hewitt <1939362+davidhewitt@users.noreply.github.com> Date: Sat, 6 Aug 2022 07:51:18 +0100 Subject: [PATCH] Add support for wasm32-unknown-emscripten via Pyodide --- CHANGELOG.md | 3 +++ setuptools_rust/build.py | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73b85384..3e9b75ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## Unreleased +### Added +- Add support for extension modules built for wasm32-unknown-emscripten with Pyodide. + ### Changed - 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) - Fix RustBin build without wheel. [#273](https://github.com/PyO3/setuptools-rust/pull/273) diff --git a/setuptools_rust/build.py b/setuptools_rust/build.py index 699c1337..e19697ce 100644 --- a/setuptools_rust/build.py +++ b/setuptools_rust/build.py @@ -3,7 +3,6 @@ import glob import json import os -import pkg_resources import platform import shutil import subprocess @@ -20,6 +19,7 @@ from pathlib import Path from typing import Dict, Iterable, List, NamedTuple, Optional, Set, Tuple, cast +import pkg_resources from setuptools.command.build import build as CommandBuild # type: ignore[import] from setuptools.command.build_ext import build_ext as CommandBuildExt from setuptools.command.build_ext import get_abi3_suffix @@ -200,6 +200,12 @@ def build_extension( # the cdylib, see https://github.com/rust-lang/cargo/issues/10143 rustflags.append("-Ctarget-feature=-crt-static") + elif (rustc_cfgs.get("target_arch"), rustc_cfgs.get("target_os")) == ( + "wasm32", + "emscripten", + ): + rustc_args.append(["-C", f"link-args=-sSIDE_MODULE=2 -sWASM_BIGINT"]) + command = [ self.cargo, "rustc",