From 4fe0dc78443c9d829347883a137de6d0eaa1f49c Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Sat, 18 May 2024 19:00:51 -0700 Subject: [PATCH 1/4] python3-sys: port Py_3_12 changes from pyo3-ffi I looked at all Py_3_12 changes in pyo3-ffi/src/cpython and ported them back. Functions, structs, and fields in the code object not already defined in python3-sys are ignored. For PyUnicode_READY, I kept a dummy version so the cpython crate does not need change. --- python3-sys/src/code.rs | 7 ++++++- python3-sys/src/compile.rs | 13 +++++++++++++ python3-sys/src/initconfig.rs | 10 +++++++--- python3-sys/src/object.rs | 13 ++++++++++++- python3-sys/src/unicodeobject.rs | 24 ++++++++++++++++++------ 5 files changed, 56 insertions(+), 11 deletions(-) diff --git a/python3-sys/src/code.rs b/python3-sys/src/code.rs index 3b18d8e..d7c634a 100644 --- a/python3-sys/src/code.rs +++ b/python3-sys/src/code.rs @@ -23,18 +23,23 @@ pub struct PyCodeObject { pub co_names: *mut PyObject, pub co_exceptiontable: *mut PyObject, pub co_flags: c_int, + #[cfg(not(Py_3_12))] pub co_warmup: c_short, - co_linearray_entry_size: c_short, pub co_argcount: c_int, pub co_posonlyargcount: c_int, pub co_kwonlyargcount: c_int, pub co_stacksize: c_int, pub co_firstlineno: c_int, pub co_nlocalsplus: c_int, + #[cfg(Py_3_12)] + pub co_framesize: c_int, pub co_nlocals: c_int, + #[cfg(not(Py_3_12))] pub co_nplaincellvars: c_int, pub co_ncellvars: c_int, pub co_nfreevars: c_int, + #[cfg(Py_3_12)] + pub co_version: u32, pub co_localsplusnames: *mut PyObject, pub co_localspluskinds: *mut PyObject, pub co_filename: *mut PyObject, diff --git a/python3-sys/src/compile.rs b/python3-sys/src/compile.rs index 2b1888b..63d3418 100644 --- a/python3-sys/src/compile.rs +++ b/python3-sys/src/compile.rs @@ -7,12 +7,25 @@ use crate::object::PyObject; use crate::pyarena::*; use crate::pythonrun::*; +#[repr(C)] +#[derive(Copy, Clone)] +#[cfg(Py_3_12)] +pub struct _PyCompilerSrcLocation { + pub lineno: c_int, + pub end_lineno: c_int, + pub col_offset: c_int, + pub end_col_offset: c_int, +} + #[repr(C)] #[derive(Copy, Clone)] #[cfg(not(Py_LIMITED_API))] pub struct PyFutureFeatures { pub ff_features: c_int, + #[cfg(not(Py_3_12))] pub ff_lineno: c_int, + #[cfg(Py_3_12)] + pub ff_location: _PyCompilerSrcLocation, } // TODO: PyCF_MASK etc. constants diff --git a/python3-sys/src/initconfig.rs b/python3-sys/src/initconfig.rs index 24f1011..b4813ec 100644 --- a/python3-sys/src/initconfig.rs +++ b/python3-sys/src/initconfig.rs @@ -107,6 +107,8 @@ pub struct PyConfig { #[cfg(all(Py_3_9, not(Py_3_10)))] pub _use_peg_parser: c_int, pub tracemalloc: c_int, + #[cfg(Py_3_12)] + pub perf_profiling: c_int, pub import_time: c_int, #[cfg(Py_3_11)] pub code_debug_ranges: c_int, @@ -151,6 +153,8 @@ pub struct PyConfig { pub use_frozen_modules: c_int, #[cfg(Py_3_11)] pub safe_path: c_int, + #[cfg(Py_3_12)] + pub int_max_str_digits: c_int, // Path configuration inputs: pub pathconfig_warnings: c_int, #[cfg(Py_3_10)] @@ -180,12 +184,12 @@ pub struct PyConfig { // Private fields pub _install_importlib: c_int, pub _init_main: c_int, - #[cfg(Py_3_9)] + #[cfg(all(Py_3_9, not(Py_3_12)))] pub _isolated_interpreter: c_int, - #[cfg(all(Py_3_9, not(Py_3_10)))] - pub _orig_argv: PyWideStringList, #[cfg(Py_3_11)] pub _is_python_build: c_int, + #[cfg(all(Py_3_9, not(Py_3_10)))] + pub _orig_argv: PyWideStringList, } impl Default for PyConfig { diff --git a/python3-sys/src/object.rs b/python3-sys/src/object.rs index 40f1a85..40042b0 100644 --- a/python3-sys/src/object.rs +++ b/python3-sys/src/object.rs @@ -436,6 +436,8 @@ mod typeobject { pub tp_finalize: Option, #[cfg(Py_3_8)] pub tp_vectorcall: Option, + #[cfg(Py_3_12)] + pub tp_watched: c_char, #[cfg(all(Py_3_8, not(Py_3_9)))] pub tp_print: Option, #[cfg(all(py_sys_config = "COUNT_ALLOCS", not(Py_3_9)))] @@ -535,7 +537,16 @@ mod typeobject { } } - #[cfg(Py_3_9)] + #[cfg(Py_3_12)] + pub const PyTypeObject_INIT: PyTypeObject = py_type_object_init_with_count_allocs!( + tp_as_async: 0 as *mut PyAsyncMethods, + tp_vectorcall_offset: 0, + tp_vectorcall: None, + tp_finalize: None, + tp_watched: 0, + ); + + #[cfg(all(Py_3_9, not(Py_3_12)))] pub const PyTypeObject_INIT: PyTypeObject = py_type_object_init_with_count_allocs!( tp_as_async: 0 as *mut PyAsyncMethods, tp_vectorcall_offset: 0, diff --git a/python3-sys/src/unicodeobject.rs b/python3-sys/src/unicodeobject.rs index 310d956..cce802b 100644 --- a/python3-sys/src/unicodeobject.rs +++ b/python3-sys/src/unicodeobject.rs @@ -435,7 +435,7 @@ extern "C" { #[deprecated(since = "0.6.1", note = "Deprecated since Python 3.3; removed in 3.10")] pub fn PyUnicode_AsUnicodeCopy(unicode: *mut PyObject) -> *mut Py_UNICODE; - #[cfg(not(Py_LIMITED_API))] + #[cfg(not(any(Py_LIMITED_API, Py_3_12)))] fn _PyUnicode_Ready(o: *mut PyObject) -> c_int; } @@ -446,6 +446,7 @@ pub struct PyASCIIObject { pub length: Py_ssize_t, pub hash: Py_hash_t, pub state: u32, + #[cfg(not(Py_3_12))] pub wstr: *mut c_void, } @@ -455,6 +456,7 @@ pub struct PyCompactUnicodeObject { _base: PyASCIIObject, utf8_length: Py_ssize_t, utf8: *mut u8, + #[cfg(not(Py_3_12))] wstr_length: Py_ssize_t, } @@ -494,6 +496,7 @@ pub const PyUnicode_4BYTE_KIND: u32 = 4; #[inline] pub unsafe fn PyUnicode_KIND(o: *mut PyObject) -> u32 { debug_assert!(PyUnicode_Check(o) > 0); + #[cfg(not(Py_3_12))] debug_assert!(PyUnicode_IS_READY(o)); let state = (*(o as *mut PyASCIIObject)).state; (state >> 2) & 7 @@ -502,6 +505,7 @@ pub unsafe fn PyUnicode_KIND(o: *mut PyObject) -> u32 { #[cfg(not(Py_LIMITED_API))] pub unsafe fn PyUnicode_DATA(o: *mut PyObject) -> *mut c_void { debug_assert!(PyUnicode_Check(o) > 0); + #[cfg(not(Py_3_12))] debug_assert!(PyUnicode_IS_READY(o)); if PyUnicode_IS_COMPACT(o) { // fn _PyUnicode_COMPACT_DATA @@ -522,11 +526,12 @@ pub unsafe fn PyUnicode_DATA(o: *mut PyObject) -> *mut c_void { #[inline] pub unsafe fn PyUnicode_GET_LENGTH(o: *mut PyObject) -> Py_ssize_t { debug_assert!(PyUnicode_Check(o) > 0); + #[cfg(not(Py_3_12))] debug_assert!(PyUnicode_IS_READY(o)); (*(o as *mut PyASCIIObject)).length } -#[cfg(not(Py_LIMITED_API))] +#[cfg(not(any(Py_LIMITED_API, Py_3_12)))] #[inline] unsafe fn PyUnicode_IS_READY(o: *mut PyObject) -> bool { let ready_bit = 1 << 7; @@ -538,9 +543,16 @@ unsafe fn PyUnicode_IS_READY(o: *mut PyObject) -> bool { #[inline] pub unsafe fn PyUnicode_READY(o: *mut PyObject) -> c_int { debug_assert!(PyUnicode_Check(o) > 0); - if PyUnicode_IS_READY(o) { - 0 - } else { - _PyUnicode_Ready(o) + #[cfg(Py_3_12)] + { + return 0; + } + #[cfg(not(Py_3_12))] + { + if PyUnicode_IS_READY(o) { + 0 + } else { + _PyUnicode_Ready(o) + } } } From d4c8474701e1a758036383aee0604d33938654ef Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Mon, 1 Jul 2024 10:23:23 -0700 Subject: [PATCH 2/4] Resolve symbol errors with Python 3.12 Symbols missing in /opt/hostedtoolcache/Python/3.12.4/x64/lib/libpython3.12.so: PyCode_New PyCode_NewWithPosOnlyArgs PyUnicode_AsUnicode PyUnicode_AsUnicodeAndSize PyUnicode_FromUnicode _Py_GetAllocatedBlocks _Py_PackageContext Python 3.12/3.11 renamed/deprecated some APIs. Update code to skip them. This affects `linux (ubuntu-latest, 3.12, nightly)` CI. --- python3-sys/src/code.rs | 2 ++ python3-sys/src/modsupport.rs | 2 +- python3-sys/src/objimpl.rs | 2 +- python3-sys/src/unicodeobject.rs | 6 +++--- tests/check_symbols.py | 9 ++++++++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/python3-sys/src/code.rs b/python3-sys/src/code.rs index d7c634a..dc57ce4 100644 --- a/python3-sys/src/code.rs +++ b/python3-sys/src/code.rs @@ -152,6 +152,7 @@ pub const CO_MAXBLOCKS: usize = 20; extern "C" { pub static mut PyCode_Type: PyTypeObject; + #[cfg_attr(Py_3_12, link_name = "PyUnstable_Code_New")] pub fn PyCode_New( argcount: c_int, kwonlyargcount: c_int, @@ -175,6 +176,7 @@ extern "C" { ) -> *mut PyCodeObject; #[cfg(Py_3_8)] + #[cfg_attr(Py_3_12, link_name = "PyUnstable_Code_NewWithPosOnlyArgs")] pub fn PyCode_NewWithPosOnlyArgs( argcount: c_int, posonlyargcount: c_int, diff --git a/python3-sys/src/modsupport.rs b/python3-sys/src/modsupport.rs index 64cb5be..fa02ec9 100644 --- a/python3-sys/src/modsupport.rs +++ b/python3-sys/src/modsupport.rs @@ -133,7 +133,7 @@ pub unsafe fn PyModule_FromDefAndSpec(def: *mut PyModuleDef, spec: *mut PyObject ) } -#[cfg(not(Py_LIMITED_API))] +#[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))] #[cfg_attr(windows, link(name = "pythonXY"))] extern "C" { pub static mut _Py_PackageContext: *const c_char; diff --git a/python3-sys/src/objimpl.rs b/python3-sys/src/objimpl.rs index a731a54..5a8e302 100644 --- a/python3-sys/src/objimpl.rs +++ b/python3-sys/src/objimpl.rs @@ -21,7 +21,7 @@ extern "C" { #[cfg(all(py_sys_config = "Py_DEBUG", not(Py_3_4)))] pub fn _PyObject_DebugFree(arg1: *mut c_void); - #[cfg(all(not(Py_LIMITED_API), Py_3_4))] + #[cfg(all(not(Py_LIMITED_API), Py_3_4, not(Py_3_11)))] pub fn _Py_GetAllocatedBlocks() -> Py_ssize_t; pub fn PyObject_Init(arg1: *mut PyObject, arg2: *mut PyTypeObject) -> *mut PyObject; pub fn PyObject_InitVar( diff --git a/python3-sys/src/unicodeobject.rs b/python3-sys/src/unicodeobject.rs index cce802b..a0556b7 100644 --- a/python3-sys/src/unicodeobject.rs +++ b/python3-sys/src/unicodeobject.rs @@ -52,7 +52,7 @@ extern "C" { length: Py_ssize_t, fill_char: Py_UCS4, ) -> Py_ssize_t; - #[cfg(not(Py_LIMITED_API))] + #[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))] #[deprecated(since = "0.2.1", note = "Deprecated since Python 3.3 / PEP 393")] pub fn PyUnicode_FromUnicode(u: *const Py_UNICODE, size: Py_ssize_t) -> *mut PyObject; @@ -78,10 +78,10 @@ extern "C" { copy_null: c_int, ) -> *mut Py_UCS4; pub fn PyUnicode_AsUCS4Copy(unicode: *mut PyObject) -> *mut Py_UCS4; - #[cfg(not(Py_LIMITED_API))] + #[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))] #[deprecated(since = "0.2.1", note = "Deprecated since Python 3.3 / PEP 393")] pub fn PyUnicode_AsUnicode(unicode: *mut PyObject) -> *mut Py_UNICODE; - #[cfg(not(Py_LIMITED_API))] + #[cfg(all(not(Py_LIMITED_API), not(Py_3_12)))] #[deprecated(since = "0.2.1", note = "Deprecated since Python 3.3 / PEP 393")] pub fn PyUnicode_AsUnicodeAndSize( unicode: *mut PyObject, diff --git a/tests/check_symbols.py b/tests/check_symbols.py index b5746fd..e13f674 100755 --- a/tests/check_symbols.py +++ b/tests/check_symbols.py @@ -89,12 +89,19 @@ def match_braces(text): foreign_sections.append(asttree[:endpos]) asttree = asttree[endpos:] +renames = {} +if sys.version_info >= (3, 12): + # Those renames were declared by cfg_attr(Py_3_12, link_name = ...) but it's hard to parse them from AST. + renames.update({"PyCode_New": "PyUnstable_Code_New", "PyCode_NewWithPosOnlyArgs": "PyUnstable_Code_NewWithPosOnlyArgs"}) + for section in foreign_sections: lines = section.split('\n') for idx in range(len(lines)): line = lines[idx] if ('kind: Fn(' in line) or ('kind: Static(' in line): - foreign_symbols.add(re.sub(r'\s*ident: (.*)#[0-9]*,', r'\1', lines[idx-1])) + name = re.sub(r'\s*ident: (.*)#[0-9]*,', r'\1', lines[idx-1]) + name = renames.get(name) or name + foreign_symbols.add(name) assert 'PyList_Type' in foreign_symbols, "Failed getting statics from rustc -Z unpretty=ast-tree,expanded" assert 'PyList_New' in foreign_symbols, "Failed getting functions from rustc -Z unpretty=ast-tree,expanded" From 82a344ea2cbb97bc72d997ddd63b5264fe18cc58 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Mon, 1 Jul 2024 10:58:01 -0700 Subject: [PATCH 3/4] Update GitHub actions Drop Python 2.7, as it is no longer available: Warning: The support for python 2.7 will be removed on June 19. Related issue: https://github.com/actions/setup-python/issues/672 Version 2.7 was not found in the local cache Error: The version '2.7' with architecture 'x64' was not found for Ubuntu 22.04. The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json Add Python 3.12 as its support was just added. Fork macOS steps from Linux due to the ARM arch change: - Rust 1.41 does not have a `aarch64-apple-darwin` version. The first Rust version that supports `aarch64-apple-darwin` is 1.49.0. - Python 3.7 to 3.10 do not have a macOS ARM version in CI. - Rust < 1.54 will fail on CI. See also See https://github.com/rust-lang/rust/issues/107252: error: linking with `cc` failed: exit status: 1 | = note: "cc" "-arch" "arm64" "-L" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.0.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.1.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.10.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.11.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.12.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.13.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.14.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.15.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.2.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.3.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.4.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.5.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.6.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.7.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.8.rcgu.o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.build_script_build.f402nxks-cgu.9.rcgu.o" "-o" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/build/memchr-30eba211f26bbb03/build_script_build-30eba211f26bbb03.1dr67yq0qjg3o93v.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/runner/work/rust-cpython/rust-cpython/target/debug/deps" "-L" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd-dd5aba3397285ad0.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-cb187f1a5b379d1a.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libobject-d263574460ac0b7b.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-0a9a23101265d9a7.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgimli-e6457880b831342b.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-9590d4ced205b108.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-a1f4d95a4a2cc2a3.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-dbf1072a4ef077a4.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-7ff002204e919c46.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunwind-a2049ddc023c32b9.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-02cf13a7707ef825.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liblibc-e628929d2a4d215f.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-1f245a76196b996b.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-49a44db0ac13b7f4.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-a04810d031c48fa4.rlib" "/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-7cd54448073dfb2c.rlib" "-lSystem" "-lresolv" "-lc" "-lm" "-liconv" = note: ld: multiple errors: archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd-dd5aba3397285ad0.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libpanic_unwind-cb187f1a5b379d1a.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libobject-d263574460ac0b7b.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libaddr2line-0a9a23101265d9a7.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libgimli-e6457880b831342b.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libstd_detect-9590d4ced205b108.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_demangle-a1f4d95a4a2cc2a3.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libhashbrown-dbf1072a4ef077a4.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_alloc-7ff002204e919c46.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libunwind-a2049ddc023c32b9.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcfg_if-02cf13a7707ef825.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liblibc-e628929d2a4d215f.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/liballoc-1f245a76196b996b.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/librustc_std_workspace_core-49a44db0ac13b7f4.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcore-a04810d031c48fa4.rlib'; archive member 'lib.rmeta' not a mach-o file in '/Users/runner/.rustup/toolchains/1.53.0-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/lib/libcompiler_builtins-7cd54448073dfb2c.rlib' clang: error: linker command failed with exit code 1 (use -v to see invocation) --- .github/workflows/test.yml | 45 ++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b2b1f91..c5fdc27 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,13 +7,13 @@ on: branches: [ master ] jobs: - unix: + linux: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-latest ] - py: [ "2.7", "3.7", "3.8", "3.9", "3.10", "3.11" ] + os: [ ubuntu-latest ] + py: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ] rust: [ "1.41.1", "stable", "nightly" ] steps: @@ -44,13 +44,50 @@ jobs: run: | make test extensions + macos: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ macos-latest ] + py: [ "3.11", "3.12" ] + rust: [ "1.54.0", "stable", "nightly" ] + + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Setup Python ${{ matrix.py }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.py }} + - name: Setup Rust ${{ matrix.rust }} + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + - name: Check versions and paths + run: | + python -V ; rustc -V + echo "PATH=$PATH" + echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" + echo "LIBRARY_PATH=$LIBRARY_PATH" + PYTHON_LIB=$(python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))") + echo "PYTHON_LIB=$PYTHON_LIB" + echo "LIBRARY_PATH=$LIBRARY_PATH:$PYTHON_LIB" >> "$GITHUB_ENV" + - name: Remove Cargo.lock + if: ${{ matrix.rust == 'stable' || matrix.rust == 'nightly' }} + run: | + rm Cargo.lock + - name: Build and test + run: | + make test extensions + windows: runs-on: ${{ matrix.os }} strategy: matrix: os: [ windows-latest ] - py: [ "2.7", "3.7", "3.8", "3.9", "3.10", "3.11"] + py: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ] rust: [ "1.41.1", "stable" ] steps: From b2e095fbd09787fd407e5abecfa5da3db2783319 Mon Sep 17 00:00:00 2001 From: Jun Wu Date: Mon, 1 Jul 2024 10:59:06 -0700 Subject: [PATCH 4/4] Drop "Python 3.12 is not supported" from README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 61b4358..1d5df7d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ rust-cpython [![Build Status](https://travis-ci.org/dgrunwald/rust-cpython.svg?branch=master)](https://travis-ci.org/dgrunwald/rust-cpython) ==================== -Warning: this package is no longer actively maintained. Python 3.12 is not supported and likely will not be supported. +Warning: this package is no longer actively maintained. Please switch to [PyO3](https://github.com/PyO3/pyo3) instead. [Rust](http://www.rust-lang.org/) bindings for the [python](https://www.python.org/) interpreter. @@ -17,9 +17,9 @@ Python is licensed under the [Python License](https://docs.python.org/2/license. Supported Python versions: * Python 2.7 -* Python 3.7 to 3.11 +* Python 3.7 to 3.12 -Warning: this package is no longer actively maintained. Python 3.12 is not supported and likely will not be supported. +Warning: this package is no longer actively maintained. Please switch to [PyO3](https://github.com/PyO3/pyo3) instead. Requires Rust 1.41.1 or later.