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

Python 3.11 support #514

Merged
merged 13 commits into from
Sep 5, 2022
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [2.7.17, 2.7.18, 3.5.4, 3.5.9, 3.5.10, 3.6.7, 3.6.8, 3.6.9, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.7.1, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.7.10, 3.7.11, 3.7.12, 3.7.13, 3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.8.10, 3.8.11, 3.8.12, 3.8.13, 3.9.0, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7, 3.9.8, 3.9.9, 3.9.10, 3.9.11, 3.9.12, 3.9.13, 3.10.0, 3.10.1, 3.10.2, 3.10.3, 3.10.4, 3.10.5, 3.10.6]
python-version: [2.7.17, 2.7.18, 3.5.4, 3.5.9, 3.5.10, 3.6.7, 3.6.8, 3.6.9, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.7.1, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.7.10, 3.7.11, 3.7.12, 3.7.13, 3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.8.10, 3.8.11, 3.8.12, 3.8.13, 3.9.0, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7, 3.9.8, 3.9.9, 3.9.10, 3.9.11, 3.9.12, 3.9.13, 3.10.0, 3.10.1, 3.10.2, 3.10.3, 3.10.4, 3.10.5, 3.10.6, 3.11.0-beta.5]
# TODO: also test windows
os: [ubuntu-latest, macos-latest]
steps:
Expand Down
4 changes: 2 additions & 2 deletions ci/update_python_test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def get_github_python_versions():
versions_json = requests.get(_VERSIONS_URL).json()
raw_versions = [v["version"] for v in versions_json]
versions = []
for version_str in raw_versions:
if "-" in version_str:
for version_str in raw_versions:
if "-" in version_str and version_str != "3.11.0-beta.5":
continue

major, minor, patch = parse_version(version_str)
Expand Down
6 changes: 3 additions & 3 deletions generate_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ def extract_bindings(cpython_path, version, configure=False):

cat Include/Python.h > bindgen_input.h
cat Include/frameobject.h >> bindgen_input.h
cat Objects/dict-common.h >> bindgen_input.h
echo '#define Py_BUILD_CORE 1\n' >> bindgen_input.h
cat Include/internal/pycore_pystate.h >> bindgen_input.h
cat Include/internal/pycore_interp.h >> bindgen_input.h
cat Include/internal/pycore_frame.h >> bindgen_input.h

bindgen bindgen_input.h -o bindgen_output.rs \
--with-derive-default \
Expand All @@ -126,17 +126,17 @@ def extract_bindings(cpython_path, version, configure=False):
--whitelist-type PyASCIIObject \
--whitelist-type PyUnicodeObject \
--whitelist-type PyCompactUnicodeObject \
--whitelist-type PyStringObject \
--whitelist-type PyTupleObject \
--whitelist-type PyListObject \
--whitelist-type PyIntObject \
--whitelist-type PyLongObject \
--whitelist-type PyFloatObject \
--whitelist-type PyDictObject \
--whitelist-type PyDictKeysObject \
--whitelist-type PyDictKeyEntry \
--whitelist-type PyDictUnicodeEntry \
--whitelist-type PyObject \
--whitelist-type PyTypeObject \
--whitelist-type PyHeapTypeObject \
-- -I . -I ./Include -I ./Include/internal
""")
if ret:
Expand Down
25 changes: 16 additions & 9 deletions src/python_bindings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod v3_7_0;
pub mod v3_8_0;
pub mod v3_9_5;
pub mod v3_10_0;
pub mod v3_11_0;

// currently the PyRuntime struct used from Python 3.7 on really can't be
// exposed in a cross platform way using bindgen. PyRuntime has several mutex's
Expand Down Expand Up @@ -52,6 +53,7 @@ pub mod pyruntime {
}
},
Version{major: 3, minor: 8..=10, ..} => 32,
Version{major: 3, minor: 11, ..} => 40,
_ => 24
}
}
Expand All @@ -62,19 +64,20 @@ pub mod pyruntime {
#[cfg(target_os="macos")]
pub fn get_tstate_current_offset(version: &Version) -> Option<usize> {
match version {
Version{major: 3, minor: 7, patch: 0..=3, ..} => Some(1440),
Version{major: 3, minor: 7, ..} => Some(1528),
Version{major: 3, minor: 8, patch: 0, ..} => {
match version.release_flags.as_ref() {
Version{major: 3, minor: 7, patch: 0..=3, ..} => Some(1440),
Version{major: 3, minor: 7, ..} => Some(1528),
Version{major: 3, minor: 8, patch: 0, ..} => {
match version.release_flags.as_ref() {
"a1" => Some(1432),
"a2" => Some(888),
"a3" | "a4" => Some(1448),
_ => Some(1416),
}
},
Version{major: 3, minor: 8, ..} => { Some(1416) },
Version{major: 3, minor: 9..=10, ..} => { Some(616) },
_ => None
},
Version{major: 3, minor: 8, ..} => { Some(1416) },
Version{major: 3, minor: 9..=10, ..} => { Some(616) },
Version{major: 3, minor: 11, ..} => Some(624),
_ => None
}
}

Expand All @@ -101,7 +104,7 @@ pub mod pyruntime {
match version {
Version{major: 3, minor: 7, ..} => Some(828),
Version{major: 3, minor: 8, ..} => Some(804),
Version{major: 3, minor: 9..=10, ..} => Some(364),
Version{major: 3, minor: 9..=11, ..} => Some(364),
_ => None
}
}
Expand All @@ -113,6 +116,7 @@ pub mod pyruntime {
Version{major: 3, minor: 7, ..} => Some(1496),
Version{major: 3, minor: 8, ..} => Some(1384),
Version{major: 3, minor: 9..=10, ..} => Some(584),
Version{major: 3, minor: 11, ..} => Some(592),
_ => None
}
}
Expand All @@ -132,6 +136,7 @@ pub mod pyruntime {
},
Version{major: 3, minor: 8, ..} => Some(1368),
Version{major: 3, minor: 9..=10, ..} => Some(568),
Version{major: 3, minor: 11, ..} => Some(576),
_ => None
}
}
Expand All @@ -155,6 +160,7 @@ pub mod pyruntime {
},
Version{major: 3, minor: 8, ..} => Some(1296),
Version{major: 3, minor: 9..=10, ..} => Some(496),
Version{major: 3, minor: 11, ..} => Some(504),
_ => None
}
}
Expand All @@ -174,6 +180,7 @@ pub mod pyruntime {
},
Version{major: 3, minor: 8, ..} => Some(1224),
Version{major: 3, minor: 9..=10, ..} => Some(424),
Version{major: 3, minor: 11, ..} => Some(432),
_ => None
}
}
Expand Down
Loading