Skip to content

Commit

Permalink
Bump PyO3 to 0.23, drop Python 3.8 support (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro authored Nov 24, 2024
1 parent 6e3c2c8 commit e493e75
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 22 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ jobs:
os: [ubuntu, macos, windows]
rust-version: [stable, '1.72']
python-version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- 'pypy3.8'
# NOTE: gha setup-python doesn't support 3.13t yet
# (https://github.com/actions/setup-python/pull/973)
# - '3.13t'
- 'pypy3.9'
- 'pypy3.10'
exclude:
Expand Down Expand Up @@ -218,7 +219,10 @@ jobs:
with:
target: ${{ matrix.target }}
manylinux: ${{ matrix.manylinux || 'auto' }}
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.8 3.9 3.10 3.11 3.12 3.13' }}
# NOTE: gha setup-python doesn't support 3.13t yet
# (https://github.com/actions/setup-python/pull/973)
# args: --release --out dist --interpreter ${{ matrix.interpreter || '3.9 3.10 3.11 3.12 3.13 3.13t' }}
args: --release --out dist --interpreter ${{ matrix.interpreter || '3.9 3.10 3.11 3.12 3.13' }}

- name: build pypy wheels
if: ${{ matrix.pypy }}
Expand Down
20 changes: 10 additions & 10 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ rust-version = "1.63"
[dependencies]
crossbeam-channel = "0.5.12"
notify = {git = "https://github.com/samuelcolvin/notify.git", branch = "keep-io-error"}
pyo3 = { version = "0.22.2", features = ["extension-module", "generate-import-lib"] }
pyo3 = { version = "=0.23", features = ["extension-module", "generate-import-lib"] }

[lib]
name = "_rust_notify"
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = 'maturin'

[project]
name = 'watchfiles'
requires-python = '>=3.8'
requires-python = '>=3.9'
description = 'Simple, modern and high performance file watching and code reload in python.'
authors = [
{name ='Samuel Colvin', email = 's@muelcolvin.com'},
Expand All @@ -18,7 +18,6 @@ classifiers = [
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
Expand Down
20 changes: 14 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl RustNotify {
Ok(_) => (),
Err(_) => {
slf.borrow().clear();
return Ok(intern!(py, "signal").into_py(py));
return Ok(intern!(py, "signal").as_any().to_owned().unbind());
}
};

Expand All @@ -302,7 +302,7 @@ impl RustNotify {
eprintln!("stop event set, stopping...");
}
slf.borrow().clear();
return Ok(intern!(py, "stop").into_py(py));
return Ok(intern!(py, "stop").as_any().to_owned().unbind());
}
}

Expand All @@ -324,11 +324,19 @@ impl RustNotify {
} else if let Some(max_time) = max_timeout_time {
if SystemTime::now() > max_time {
slf.borrow().clear();
return Ok(intern!(py, "timeout").into_py(py));
return Ok(intern!(py, "timeout").as_any().to_owned().unbind());
}
}
}
let py_changes = slf.borrow().changes.lock().unwrap().to_object(py);
let py_changes = slf
.borrow()
.changes
.lock()
.unwrap()
.to_owned()
.into_pyobject(py)?
.into_any()
.unbind();
slf.borrow().clear();
Ok(py_changes)
}
Expand Down Expand Up @@ -357,7 +365,7 @@ impl RustNotify {
}
}

#[pymodule]
#[pymodule(gil_used = false)]
fn _rust_notify(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
let mut version = env!("CARGO_PKG_VERSION").to_string();
// cargo uses "1.0-alpha1" etc. while python uses "1.0.0a1", this is not full compatibility,
Expand All @@ -369,7 +377,7 @@ fn _rust_notify(py: Python, m: &Bound<PyModule>) -> PyResult<()> {
m.add("__version__", version)?;
m.add(
"WatchfilesRustInternalError",
py.get_type_bound::<WatchfilesRustInternalError>(),
py.get_type::<WatchfilesRustInternalError>(),
)?;
m.add_class::<RustNotify>()?;
Ok(())
Expand Down

0 comments on commit e493e75

Please sign in to comment.