Skip to content

Commit

Permalink
Bump rust toolchain version (pyodide#5237)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanking13 authored Dec 7, 2024
1 parent e54b220 commit 9907f1c
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 7 deletions.
10 changes: 10 additions & 0 deletions packages/rust-abi-test/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package:
name: rust-abi-test
version: "1.0"
source:
path: src
requirements:
executable:
- rustup
about:
license: MPL-2.0
19 changes: 19 additions & 0 deletions packages/rust-abi-test/src/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions packages/rust-abi-test/src/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools-rust"]
build-backend = "setuptools.build_meta"
12 changes: 12 additions & 0 deletions packages/rust-abi-test/src/setup.py
Original file line number Diff line number Diff line change
@@ -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,
)
17 changes: 17 additions & 0 deletions packages/rust-abi-test/src/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use std::fs;
use pyo3::prelude::*;


#[pyfunction]
fn get_file_length(data: &str) -> PyResult<u64> {
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(())
}
14 changes: 14 additions & 0 deletions packages/rust-abi-test/test_rust_abi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest
from pytest_pyodide import run_in_pyodide


@pytest.mark.xfail(reason="TODO: Fix me")
@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)
7 changes: 0 additions & 7 deletions packages/rust-panic-test/src/Cargo.lock

This file was deleted.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ markers = [

[tool._pyodide]

[tool.pyodide.build]
rust_toolchain = "nightly-2024-12-01"

[tool.codespell]
ignore-words = 'tools/codespell_ignore_words.txt'
skip = 'benchmark/benchmarks/pystone_benchmarks/pystone.py,src/js/package-lock.json,tools/codespell_ignore_words.txt'

0 comments on commit 9907f1c

Please sign in to comment.