Skip to content

Commit

Permalink
update maturin to 1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mbway committed Jun 16, 2024
1 parent 55b8111 commit d62bb57
Show file tree
Hide file tree
Showing 18 changed files with 69 additions and 55 deletions.
3 changes: 3 additions & 0 deletions src/maturin_import_hook/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class MaturinDevelopSettings(MaturinSettings):
"""settings for `maturin develop`."""

extras: Optional[list[str]] = None
uv: bool = False
skip_install: bool = False

@staticmethod
Expand All @@ -132,6 +133,8 @@ def to_args(self) -> list[str]:
if self.extras is not None:
args.append("--extras")
args.append(",".join(self.extras))
if self.uv:
args.append("--uv")
if self.skip_install:
args.append("--skip-install")
args.extend(super().to_args())
Expand Down
2 changes: 2 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ To update maturin:
- update the submodule to the maturin commit you want to update to
- re-run the `package_resolver` to update `resolved.json` (see `package_resolver/README.md` for instructions)
- update `requirements.txt` to match the packages and versions used by the maturin ci (`.github/workflows.test.yml`)
- check the `uniffi` package version listed in the `Cargo.toml` of any of the `uniffi-*`
test crates and update `uniffi-bindgen` in `requirements.txt` to match.
- check that no crates have been added to `test-crates` that should be excluded from the import hook tests.
If so, add them to `IGNORED_TEST_CRATES` in `common.py`
- update the version check in the import hook to ensure it allows using the new version
Expand Down
2 changes: 1 addition & 1 deletion tests/maturin
Submodule maturin updated 121 files
18 changes: 9 additions & 9 deletions tests/package_resolver/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-e ..
virtualenv
maturin==1.5.0
uv
maturin==1.6.0
pytest
junit2html
uniffi-bindgen==0.26.0
uniffi-bindgen==0.27.0
cffi

# required for pyo3-mixed
Expand Down
2 changes: 1 addition & 1 deletion tests/resolved.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commit": "7d711f0c4a7c052608dc2e16d5c6721b9666d076",
"commit": "894231c644c2d7a9a31349c86b3f3c431b74d615",
"crates": {
"cffi-mixed": {
"cargo_manifest_path": "Cargo.toml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use pyo3::prelude::*;
fn get_num() -> usize { 10 }

#[pymodule]
fn my_script(_py: Python, m: &PyModule) -> PyResult<()> {
fn my_script(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_num))?;
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn get_num() -> usize { 20 }
fn get_other_num() -> usize { 100 }

#[pymodule]
fn my_script(_py: Python, m: &PyModule) -> PyResult<()> {
fn my_script(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_num))?;
m.add_wrapped(wrap_pyfunction!(get_other_num))?;
Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn get_num() -> usize {
}

#[pymodule]
fn my_script(_py: Python, m: &PyModule) -> PyResult<()> {
fn my_script(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_num))?;
Ok(())
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;

#[pyfunction]
pub fn do_something(a: usize, b: usize) -> PyResult<usize> {
Ok(a + b)
}

#[pymodule]
pub fn my_rust_module(_py: Python, m: &PyModule) -> PyResult<()> {
pub fn my_rust_module(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(do_something))?;
Ok(())
}
18 changes: 9 additions & 9 deletions tests/test_import_hook/file_importer_helpers/reload_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Integer {
}

fn __richcmp__(&self, other: &Self, op: CompareOp, py: Python<'_>) -> PyResult<bool> {
let logging = PyModule::import(py, "logging")?;
let logging = PyModule::import_bound(py, "logging")?;
let message = format!(
"comparing Integer instances {} and {}",
self.name, other.name
Expand All @@ -66,7 +66,7 @@ impl PicklableInteger {
}

fn __richcmp__(&self, other: &Self, op: CompareOp, py: Python<'_>) -> PyResult<bool> {
let logging = PyModule::import(py, "logging")?;
let logging = PyModule::import_bound(py, "logging")?;
let message = format!(
"comparing PicklableInteger instances {} and {}",
self.name, other.name
Expand All @@ -88,15 +88,15 @@ fn get_str() -> String {
string
}

fn register_child_module(py: Python<'_>, parent_module: &PyModule) -> PyResult<()> {
let child_module = PyModule::new(py, "child")?;
fn register_child_module(py: Python<'_>, parent_module: &Bound<'_, PyModule>) -> PyResult<()> {
let child_module = PyModule::new_bound(py, "child")?;
child_module.add_wrapped(wrap_pyfunction!(get_str))?;
parent_module.add_submodule(child_module)?;
parent_module.add_submodule(&child_module)?;
Ok(())
}

#[pymodule]
fn my_module(py: Python, m: &PyModule) -> PyResult<()> {
fn my_module(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_num))?;
m.add_wrapped(wrap_pyfunction!(get_global_num))?;
m.add_wrapped(wrap_pyfunction!(set_global_num))?;
Expand All @@ -105,19 +105,19 @@ fn my_module(py: Python, m: &PyModule) -> PyResult<()> {

register_child_module(py, m)?;

let data = PyDict::new(py);
let data = PyDict::new_bound(py);
data.set_item("foo", 123)?;
m.add("data", data)?;

if !m.hasattr("data_init_once")? {
let data = PyDict::new(py);
let data = PyDict::new_bound(py);
data.set_item("foo", 123)?;
m.add("data_init_once", data)?;
}

m.add("data_str", "foo")?;

let logging = PyModule::import(py, "logging")?;
let logging = PyModule::import_bound(py, "logging")?;
logging
.getattr("info")?
.call1(("my_module extension module initialised",))?;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2021"
description = ""

[dependencies]
pyo3 = { version = "0.20.2", features = ["extension-module"] }
pyo3 = { version = "0.21.2", features = ["extension-module"] }

[lib]
crate-type = ["cdylib"]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use pyo3::prelude::*;

#[pymodule]
fn blank_project(_py: Python, _m: &PyModule) -> PyResult<()> {
fn blank_project(_m: &Bound<'_, PyModule>) -> PyResult<()> {
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn get_num() -> usize {
}

#[pymodule]
fn my_project(_py: Python, m: &PyModule) -> PyResult<()> {
fn my_project(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_num))?;
Ok(())
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Integer {
}

fn __richcmp__(&self, other: &Self, op: CompareOp, py: Python<'_>) -> PyResult<bool> {
let logging = PyModule::import(py, "logging")?;
let logging = PyModule::import_bound(py, "logging")?;
let message = format!(
"comparing Integer instances {} and {}",
self.name, other.name
Expand All @@ -66,7 +66,7 @@ impl PicklableInteger {
}

fn __richcmp__(&self, other: &Self, op: CompareOp, py: Python<'_>) -> PyResult<bool> {
let logging = PyModule::import(py, "logging")?;
let logging = PyModule::import_bound(py, "logging")?;
let message = format!(
"comparing PicklableInteger instances {} and {}",
self.name, other.name
Expand All @@ -88,15 +88,15 @@ fn get_str() -> String {
string
}

fn register_child_module(py: Python<'_>, parent_module: &PyModule) -> PyResult<()> {
let child_module = PyModule::new(py, "child")?;
fn register_child_module(py: Python<'_>, parent_module: &Bound<'_, PyModule>) -> PyResult<()> {
let child_module = PyModule::new_bound(py, "child")?;
child_module.add_wrapped(wrap_pyfunction!(get_str))?;
parent_module.add_submodule(child_module)?;
parent_module.add_submodule(&child_module)?;
Ok(())
}

#[pymodule]
fn my_project(py: Python, m: &PyModule) -> PyResult<()> {
fn my_project(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(get_num))?;
m.add_wrapped(wrap_pyfunction!(get_global_num))?;
m.add_wrapped(wrap_pyfunction!(set_global_num))?;
Expand All @@ -105,19 +105,19 @@ fn my_project(py: Python, m: &PyModule) -> PyResult<()> {

register_child_module(py, m)?;

let data = PyDict::new(py);
let data = PyDict::new_bound(py);
data.set_item("foo", 123)?;
m.add("data", data)?;

if !m.hasattr("data_init_once")? {
let data = PyDict::new(py);
let data = PyDict::new_bound(py);
data.set_item("foo", 123)?;
m.add("data_init_once", data)?;
}

m.add("data_str", "foo")?;

let logging = PyModule::import(py, "logging")?;
let logging = PyModule::import_bound(py, "logging")?;
logging
.getattr("info")?
.call1(("my_project extension module initialised",))?;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_import_hook/test_project_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ def _install_editable(project_dir: Path) -> None:
assert maturin_path is not None
env = os.environ.copy()
env["VIRTUAL_ENV"] = sys.exec_prefix
subprocess.check_call([maturin_path, "develop"], cwd=project_dir, env=env)
subprocess.check_call([maturin_path, "develop", "--uv"], cwd=project_dir, env=env)


def _install_non_editable(project_dir: Path) -> None:
Expand Down
Loading

0 comments on commit d62bb57

Please sign in to comment.