Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.23.3 #4745

Merged
merged 10 commits into from
Dec 3, 2024
Merged
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,8 @@ jobs:
components: rust-src
- name: Install python3 standalone debug build with nox
run: |
PBS_RELEASE="20231002"
PBS_PYTHON_VERSION="3.12.0"
PBS_RELEASE="20241016"
PBS_PYTHON_VERSION="3.13.0"
PBS_ARCHIVE="cpython-${PBS_PYTHON_VERSION}+${PBS_RELEASE}-x86_64-unknown-linux-gnu-debug-full.tar.zst"
wget "https://github.com/indygreg/python-build-standalone/releases/download/${PBS_RELEASE}/${PBS_ARCHIVE}"
tar -I zstd -xf "${PBS_ARCHIVE}"
Expand All @@ -537,10 +537,10 @@ jobs:
PYO3_CONFIG_FILE=$(mktemp)
cat > $PYO3_CONFIG_FILE << EOF
implementation=CPython
version=3.12
version=3.13
shared=true
abi3=false
lib_name=python3.12d
lib_name=python3.13d
lib_dir=${{ github.workspace }}/python/install/lib
executable=${{ github.workspace }}/python/install/bin/python3
pointer_width=64
Expand Down
21 changes: 18 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ To see unreleased changes, please see the [CHANGELOG on the main branch guide](h

<!-- towncrier release notes start -->

## [0.23.3] - 2024-12-03

### Packaging

- Bump optional `python3-dll-a` dependency to 0.2.11. [#4749](https://github.com/PyO3/pyo3/pull/4749)

### Fixed

- Fix unresolved symbol link failures on Windows when compiling for Python 3.13t with `abi3` features enabled. [#4733](https://github.com/PyO3/pyo3/pull/4733)
- Fix unresolved symbol link failures on Windows when compiling for Python 3.13t using the `generate-import-lib` feature. [#4749](https://github.com/PyO3/pyo3/pull/4749)
- Fix compile-time regression in PyO3 0.23.0 where changing `PYO3_CONFIG_FILE` would not reconfigure PyO3 for the new interpreter. [#4758](https://github.com/PyO3/pyo3/pull/4758)


## [0.23.2] - 2024-11-25

### Added
Expand Down Expand Up @@ -145,6 +158,7 @@ Re-release of 0.23.0 with fixes to docs.rs build.
- Revert removal of private FFI function `_PyLong_NumBits` on Python 3.13 and later. [#4450](https://github.com/PyO3/pyo3/pull/4450)
- Fix `__traverse__` functions for base classes not being called by subclasses created with `#[pyclass(extends = ...)]`. [#4563](https://github.com/PyO3/pyo3/pull/4563)
- Fix regression in 0.22.3 failing compiles under `#![forbid(unsafe_code)]`. [#4574](https://github.com/PyO3/pyo3/pull/4574)
- Fix `create_exception` macro triggering lint and compile errors due to interaction with `gil-refs` feature. [#4589](https://github.com/PyO3/pyo3/pull/4589)
- Workaround possible use-after-free in `_borrowed` methods on `PyWeakRef` and `PyWeakrefProxy` by leaking their contents. [#4590](https://github.com/PyO3/pyo3/pull/4590)
- Fix crash calling `PyType_GetSlot` on static types before Python 3.10. [#4599](https://github.com/PyO3/pyo3/pull/4599)

Expand Down Expand Up @@ -175,7 +189,7 @@ Re-release of 0.23.0 with fixes to docs.rs build.
- Fix compile failure in declarative `#[pymodule]` under presence of `#![no_implicit_prelude]`. [#4328](https://github.com/PyO3/pyo3/pull/4328)
- Fix use of borrowed reference in `PyDict::get_item` (unsafe in free-threaded Python). [#4355](https://github.com/PyO3/pyo3/pull/4355)
- Fix `#[pyclass(eq)]` macro hygiene issues for structs and enums. [#4359](https://github.com/PyO3/pyo3/pull/4359)
- Fix hygiene/span issues of `'#[pyfunction]` and `#[pymethods]` generated code which affected expansion in `macro_rules` context. [#4382](https://github.com/PyO3/pyo3/pull/4382)
- Fix hygiene/span issues of `#[pyfunction]` and `#[pymethods]` generated code which affected expansion in `macro_rules` context. [#4382](https://github.com/PyO3/pyo3/pull/4382)
- Fix `unsafe_code` lint error in `#[pyclass]` generated code. [#4396](https://github.com/PyO3/pyo3/pull/4396)
- Fix async functions returning a tuple only returning the first element to Python. [#4407](https://github.com/PyO3/pyo3/pull/4407)
- Fix use of borrowed reference in `PyList::get_item` (unsafe in free-threaded Python). [#4410](https://github.com/PyO3/pyo3/pull/4410)
Expand Down Expand Up @@ -209,7 +223,7 @@ Re-release of 0.23.0 with fixes to docs.rs build.
### Fixed

- Return `NotImplemented` instead of raising `TypeError` from generated equality method when comparing different types. [#4287](https://github.com/PyO3/pyo3/pull/4287)
- Handle full-path `#[pyo3::prelude::pymodule]` and similar for `#[pyclass]` and `#[pyfunction]` in declarative modules.[#4288](https://github.com/PyO3/pyo3/pull/4288)
- Handle full-path `#[pyo3::prelude::pymodule]` and similar for `#[pyclass]` and `#[pyfunction]` in declarative modules. [#4288](https://github.com/PyO3/pyo3/pull/4288)
- Fix 128-bit int regression on big-endian platforms with Python <3.13. [#4291](https://github.com/PyO3/pyo3/pull/4291)
- Stop generating code that will never be covered with declarative modules. [#4297](https://github.com/PyO3/pyo3/pull/4297)
- Fix invalid deprecation warning for trailing optional on `#[setter]` function. [#4304](https://github.com/PyO3/pyo3/pull/4304)
Expand Down Expand Up @@ -2012,7 +2026,8 @@ Yanked

- Initial release

[Unreleased]: https://github.com/pyo3/pyo3/compare/v0.23.2...HEAD
[Unreleased]: https://github.com/pyo3/pyo3/compare/v0.23.3...HEAD
[0.23.3]: https://github.com/pyo3/pyo3/compare/v0.23.2...v0.23.3
[0.23.2]: https://github.com/pyo3/pyo3/compare/v0.23.1...v0.23.2
[0.23.1]: https://github.com/pyo3/pyo3/compare/v0.23.0...v0.23.1
[0.23.0]: https://github.com/pyo3/pyo3/compare/v0.22.5...v0.23.0
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyo3"
version = "0.23.2"
version = "0.23.3"
description = "Bindings to Python interpreter"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
readme = "README.md"
Expand All @@ -21,10 +21,10 @@ memoffset = "0.9"
once_cell = "1.13"

# ffi bindings to the python interpreter, split into a separate crate so they can be used independently
pyo3-ffi = { path = "pyo3-ffi", version = "=0.23.2" }
pyo3-ffi = { path = "pyo3-ffi", version = "=0.23.3" }

# support crates for macros feature
pyo3-macros = { path = "pyo3-macros", version = "=0.23.2", optional = true }
pyo3-macros = { path = "pyo3-macros", version = "=0.23.3", optional = true }
indoc = { version = "2.0.1", optional = true }
unindent = { version = "0.2.1", optional = true }

Expand Down Expand Up @@ -66,7 +66,7 @@ static_assertions = "1.1.0"
uuid = {version = "1.10.0", features = ["v4"] }

[build-dependencies]
pyo3-build-config = { path = "pyo3-build-config", version = "=0.23.2", features = ["resolve-config"] }
pyo3-build-config = { path = "pyo3-build-config", version = "=0.23.3", features = ["resolve-config"] }

[features]
default = ["macros"]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ name = "string_sum"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.23.2", features = ["extension-module"] }
pyo3 = { version = "0.23.3", features = ["extension-module"] }
```

**`src/lib.rs`**
Expand Down Expand Up @@ -140,7 +140,7 @@ Start a new project with `cargo new` and add `pyo3` to the `Cargo.toml` like th

```toml
[dependencies.pyo3]
version = "0.23.2"
version = "0.23.3"
features = ["auto-initialize"]
```

Expand Down
1 change: 1 addition & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "pyo3-examples"
version = "0.0.0"
publish = false
edition = "2021"
rust-version = "1.63"

[dev-dependencies]
pyo3 = { path = "..", features = ["auto-initialize", "extension-module"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/decorator/.template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable::set("PYO3_VERSION", "0.23.2");
variable::set("PYO3_VERSION", "0.23.3");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::rename(".template/pyproject.toml", "pyproject.toml");
file::delete(".template");
2 changes: 1 addition & 1 deletion examples/maturin-starter/.template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable::set("PYO3_VERSION", "0.23.2");
variable::set("PYO3_VERSION", "0.23.3");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::rename(".template/pyproject.toml", "pyproject.toml");
file::delete(".template");
2 changes: 1 addition & 1 deletion examples/plugin/.template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable::set("PYO3_VERSION", "0.23.2");
variable::set("PYO3_VERSION", "0.23.3");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::rename(".template/plugin_api/Cargo.toml", "plugin_api/Cargo.toml");
file::delete(".template");
2 changes: 1 addition & 1 deletion examples/setuptools-rust-starter/.template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable::set("PYO3_VERSION", "0.23.2");
variable::set("PYO3_VERSION", "0.23.3");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::rename(".template/setup.cfg", "setup.cfg");
file::delete(".template");
2 changes: 1 addition & 1 deletion examples/word-count/.template/pre-script.rhai
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
variable::set("PYO3_VERSION", "0.23.2");
variable::set("PYO3_VERSION", "0.23.3");
file::rename(".template/Cargo.toml", "Cargo.toml");
file::rename(".template/pyproject.toml", "pyproject.toml");
file::delete(".template");
4 changes: 2 additions & 2 deletions guide/src/class.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ create_interface!(FloatClass, String);
#### Must be thread-safe

Python objects are freely shared between threads by the Python interpreter. This means that:
- Python objects may be created and destroyed by different Python threads; therefore #[pyclass]` objects must be `Send`.
- Python objects may be accessed by multiple python threads simultaneously; therefore `#[pyclass]` objects must be `Sync`.
- Python objects may be created and destroyed by different Python threads; therefore `#[pyclass]` objects must be `Send`.
- Python objects may be accessed by multiple Python threads simultaneously; therefore `#[pyclass]` objects must be `Sync`.

For now, don't worry about these requirements; simple classes will already be thread-safe. There is a [detailed discussion on thread-safety](./class/thread-safety.md) later in the guide.

Expand Down
7 changes: 4 additions & 3 deletions pyo3-build-config/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyo3-build-config"
version = "0.23.2"
version = "0.23.3"
description = "Build configuration for the PyO3 ecosystem"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
keywords = ["pyo3", "python", "cpython", "ffi"]
Expand All @@ -9,14 +9,15 @@ repository = "https://github.com/pyo3/pyo3"
categories = ["api-bindings", "development-tools::ffi"]
license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.63"

[dependencies]
once_cell = "1"
python3-dll-a = { version = "0.2.6", optional = true }
python3-dll-a = { version = "0.2.11", optional = true }
target-lexicon = "0.12.14"

[build-dependencies]
python3-dll-a = { version = "0.2.6", optional = true }
python3-dll-a = { version = "0.2.11", optional = true }
target-lexicon = "0.12.14"

[features]
Expand Down
64 changes: 53 additions & 11 deletions pyo3-build-config/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#[path = "import_lib.rs"]
mod import_lib;

#[cfg(test)]
use std::cell::RefCell;
use std::{
collections::{HashMap, HashSet},
env,
Expand All @@ -15,8 +17,7 @@ use std::{
io::{BufRead, BufReader, Read, Write},
path::{Path, PathBuf},
process::{Command, Stdio},
str,
str::FromStr,
str::{self, FromStr},
};

pub use target_lexicon::Triple;
Expand All @@ -41,6 +42,11 @@ const MINIMUM_SUPPORTED_VERSION_GRAALPY: PythonVersion = PythonVersion {
/// Maximum Python version that can be used as minimum required Python version with abi3.
pub(crate) const ABI3_MAX_MINOR: u8 = 12;

#[cfg(test)]
thread_local! {
static READ_ENV_VARS: RefCell<Vec<String>> = const { RefCell::new(Vec::new()) };
}

/// Gets an environment variable owned by cargo.
///
/// Environment variables set by cargo are expected to be valid UTF8.
Expand All @@ -54,6 +60,12 @@ pub fn env_var(var: &str) -> Option<OsString> {
if cfg!(feature = "resolve-config") {
println!("cargo:rerun-if-env-changed={}", var);
}
#[cfg(test)]
{
READ_ENV_VARS.with(|env_vars| {
env_vars.borrow_mut().push(var.to_owned());
});
}
env::var_os(var)
}

Expand Down Expand Up @@ -420,7 +432,7 @@ print("gil_disabled", get_config_var("Py_GIL_DISABLED"))
/// The `abi3` features, if set, may apply an `abi3` constraint to the Python version.
#[allow(dead_code)] // only used in build.rs
pub(super) fn from_pyo3_config_file_env() -> Option<Result<Self>> {
cargo_env_var("PYO3_CONFIG_FILE").map(|path| {
env_var("PYO3_CONFIG_FILE").map(|path| {
let path = Path::new(&path);
println!("cargo:rerun-if-changed={}", path.display());
// Absolute path is necessary because this build script is run with a cwd different to the
Expand Down Expand Up @@ -554,8 +566,17 @@ print("gil_disabled", get_config_var("Py_GIL_DISABLED"))
if self.lib_dir.is_none() {
let target = target_triple_from_env();
let py_version = if self.abi3 { None } else { Some(self.version) };
self.lib_dir =
import_lib::generate_import_lib(&target, self.implementation, py_version)?;
let abiflags = if self.is_free_threaded() {
Some("t")
} else {
None
};
self.lib_dir = import_lib::generate_import_lib(
&target,
self.implementation,
py_version,
abiflags,
)?;
}
Ok(())
}
Expand Down Expand Up @@ -1122,11 +1143,7 @@ impl BuildFlags {
Self(
BuildFlags::ALL
.iter()
.filter(|flag| {
config_map
.get_value(flag.to_string())
.map_or(false, |value| value == "1")
})
.filter(|flag| config_map.get_value(flag.to_string()) == Some("1"))
.cloned()
.collect(),
)
Expand Down Expand Up @@ -1525,6 +1542,7 @@ fn default_cross_compile(cross_compile_config: &CrossCompileConfig) -> Result<In
.implementation
.unwrap_or(PythonImplementation::CPython),
py_version,
None,
)?;
}

Expand Down Expand Up @@ -1653,7 +1671,7 @@ fn default_lib_name_windows(
// CPython bug: linking against python3_d.dll raises error
// https://github.com/python/cpython/issues/101614
Ok(format!("python{}{}_d", version.major, version.minor))
} else if abi3 && !(implementation.is_pypy() || implementation.is_graalpy()) {
} else if abi3 && !(gil_disabled || implementation.is_pypy() || implementation.is_graalpy()) {
if debug {
Ok(WINDOWS_ABI3_DEBUG_LIB_NAME.to_owned())
} else {
Expand Down Expand Up @@ -1893,6 +1911,7 @@ pub fn make_interpreter_config() -> Result<InterpreterConfig> {
&host,
interpreter_config.implementation,
py_version,
None,
)?;
}

Expand Down Expand Up @@ -2548,6 +2567,21 @@ mod tests {
.unwrap(),
"python313t",
);
assert_eq!(
super::default_lib_name_windows(
PythonVersion {
major: 3,
minor: 13
},
CPython,
true, // abi3 true should not affect the free-threaded lib name
false,
false,
true,
)
.unwrap(),
"python313t",
);
assert_eq!(
super::default_lib_name_windows(
PythonVersion {
Expand Down Expand Up @@ -3048,4 +3082,12 @@ mod tests {
"
));
}

#[test]
fn test_from_pyo3_config_file_env_rebuild() {
READ_ENV_VARS.with(|vars| vars.borrow_mut().clear());
let _ = InterpreterConfig::from_pyo3_config_file_env();
// it's possible that other env vars were also read, hence just checking for contains
READ_ENV_VARS.with(|vars| assert!(vars.borrow().contains(&"PYO3_CONFIG_FILE".to_string())));
}
}
2 changes: 2 additions & 0 deletions pyo3-build-config/src/import_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub(super) fn generate_import_lib(
target: &Triple,
py_impl: PythonImplementation,
py_version: Option<PythonVersion>,
abiflags: Option<&str>,
) -> Result<Option<String>> {
if target.operating_system != OperatingSystem::Windows {
return Ok(None);
Expand Down Expand Up @@ -50,6 +51,7 @@ pub(super) fn generate_import_lib(
ImportLibraryGenerator::new(&arch, &env)
.version(py_version.map(|v| (v.major, v.minor)))
.implementation(implementation)
.abiflags(abiflags)
.generate(&out_lib_dir)
.context("failed to generate python3.dll import library")?;

Expand Down
5 changes: 3 additions & 2 deletions pyo3-ffi/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyo3-ffi"
version = "0.23.2"
version = "0.23.3"
description = "Python-API bindings for the PyO3 ecosystem"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
keywords = ["pyo3", "python", "cpython", "ffi"]
Expand All @@ -10,6 +10,7 @@ categories = ["api-bindings", "development-tools::ffi"]
license = "MIT OR Apache-2.0"
edition = "2021"
links = "python"
rust-version = "1.63"

[dependencies]
libc = "0.2.62"
Expand Down Expand Up @@ -41,7 +42,7 @@ generate-import-lib = ["pyo3-build-config/python3-dll-a"]
paste = "1"

[build-dependencies]
pyo3-build-config = { path = "../pyo3-build-config", version = "=0.23.2", features = ["resolve-config"] }
pyo3-build-config = { path = "../pyo3-build-config", version = "=0.23.3", features = ["resolve-config"] }

[lints]
workspace = true
Loading
Loading