diff --git a/Makefile.envs b/Makefile.envs index e9b1e96fd8c..d5861fdc120 100644 --- a/Makefile.envs +++ b/Makefile.envs @@ -11,8 +11,8 @@ export PYTHON_ARCHIVE_SHA256=d01ec6a33bc10009b09c17da95cc2759af5a580a7316b3a446e # to your fork to test the changes are working as expected. # v0.27.3 -export PYODIDE_BUILD_COMMIT=fac0109aa2acf14469320b049d710dd42639bf94 -export PYODIDE_BUILD_REPO=https://github.com/pyodide/pyodide-build +export PYODIDE_BUILD_COMMIT=e6928ea61533989063f4ca97138a5dc684144b3d +export PYODIDE_BUILD_REPO=https://github.com/hoodmane/pyodide-build ifdef CPYTHON_DEBUG export CPYTHON_ABI_FLAGS=d diff --git a/packages/rust-abi-test/meta.yaml b/packages/rust-abi-test/meta.yaml new file mode 100644 index 00000000000..6448c8b259c --- /dev/null +++ b/packages/rust-abi-test/meta.yaml @@ -0,0 +1,10 @@ +package: + name: rust-abi-test + version: "1.0" +source: + path: src +requirements: + executable: + - rustup +about: + license: MPL-2.0 diff --git a/packages/rust-abi-test/src/Cargo.toml b/packages/rust-abi-test/src/Cargo.toml new file mode 100644 index 00000000000..1bb5af63722 --- /dev/null +++ b/packages/rust-abi-test/src/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "rust-abi-test" +version = "0.1.0" +edition = "2018" +publish = false + +[dependencies] +pyo3 = { version = "0.22.3" } + +[features] +extension-module = ["pyo3/extension-module"] +default = ["extension-module"] + +[lib] +crate-type = ["cdylib"] + +[profile.release] +lto = "thin" +overflow-checks = true diff --git a/packages/rust-abi-test/src/pyproject.toml b/packages/rust-abi-test/src/pyproject.toml new file mode 100644 index 00000000000..8619d8784c5 --- /dev/null +++ b/packages/rust-abi-test/src/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel", "setuptools-rust"] +build-backend = "setuptools.build_meta" diff --git a/packages/rust-abi-test/src/setup.py b/packages/rust-abi-test/src/setup.py new file mode 100644 index 00000000000..3392ca2d02a --- /dev/null +++ b/packages/rust-abi-test/src/setup.py @@ -0,0 +1,12 @@ +from setuptools import setup +from setuptools_rust import Binding, RustExtension + +setup( + name="rust_abi_test", + version="1.0", + rust_extensions=[ + RustExtension("rust_abi_test", "Cargo.toml", binding=Binding.PyO3) + ], + # rust extensions are not zip safe, just like C-extensions. + zip_safe=False, +) diff --git a/packages/rust-abi-test/src/src/lib.rs b/packages/rust-abi-test/src/src/lib.rs new file mode 100644 index 00000000000..451e44cd8a8 --- /dev/null +++ b/packages/rust-abi-test/src/src/lib.rs @@ -0,0 +1,17 @@ +use std::fs; +use pyo3::prelude::*; + + +#[pyfunction] +fn get_file_length(data: &str) -> PyResult { + let metadata = fs::metadata(data)?; + Ok(metadata.len()) +} + + + +#[pymodule] +fn rust_abi_test(m: &Bound<'_, PyModule>) -> pyo3::PyResult<()> { + m.add_function(wrap_pyfunction!(get_file_length, m)?)?; + Ok(()) +} diff --git a/packages/rust-abi-test/test_rust_abi.py b/packages/rust-abi-test/test_rust_abi.py new file mode 100644 index 00000000000..60b35be2eca --- /dev/null +++ b/packages/rust-abi-test/test_rust_abi.py @@ -0,0 +1,11 @@ +from pytest_pyodide import run_in_pyodide + +@run_in_pyodide(packages=["rust-abi-test"]) +def test_rust_abi(selenium): + from pathlib import Path + from rust_abi_test import get_file_length + + contents = "this is the contents of the file\n" * 4 + Path("/test.txt").write_text(contents) + assert get_file_length("/test.txt") == len(contents) + \ No newline at end of file diff --git a/packages/rust-panic-test/src/Cargo.lock b/packages/rust-panic-test/src/Cargo.lock deleted file mode 100644 index e7cecae9fc8..00000000000 --- a/packages/rust-panic-test/src/Cargo.lock +++ /dev/null @@ -1,7 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "hello-world" -version = "0.1.0"