Skip to content

Commit

Permalink
Regenerate Python bindings (#6)
Browse files Browse the repository at this point in the history
* Remove unused import

* Update `all` versions in `generate_bindings.py`

* Update `whitelist` to `allowlist` for `bindgen`

* Add "v" prefix to python versions

* Generating bindings for latest Python minor versions

* Regenerate bindings for latest patch of each Python version

* Fix linux builds

* Remove unused import
  • Loading branch information
zanieb authored May 16, 2023
1 parent f3f3247 commit fa46b7a
Show file tree
Hide file tree
Showing 16 changed files with 9,947 additions and 651 deletions.
44 changes: 23 additions & 21 deletions generate_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,33 +110,35 @@ def extract_bindings(cpython_path, version, configure=False):
cat Include/Python.h > bindgen_input.h
cat Include/frameobject.h >> bindgen_input.h
echo '#define Py_BUILD_CORE 1\n' >> bindgen_input.h
# cat Include/internal/pystate.h >> 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
cat Objects/dict-common.h >> bindgen_input.h
bindgen bindgen_input.h -o bindgen_output.rs \
--with-derive-default \
--no-layout-tests --no-doc-comments \
--whitelist-type PyInterpreterState \
--whitelist-type PyFrameObject \
--whitelist-type PyThreadState \
--whitelist-type PyCodeObject \
--whitelist-type PyVarObject \
--whitelist-type PyBytesObject \
--whitelist-type PyASCIIObject \
--whitelist-type PyUnicodeObject \
--whitelist-type PyCompactUnicodeObject \
--whitelist-type PyTupleObject \
--whitelist-type PyListObject \
--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 \
--allowlist-type PyInterpreterState \
--allowlist-type PyFrameObject \
--allowlist-type PyThreadState \
--allowlist-type PyCodeObject \
--allowlist-type PyVarObject \
--allowlist-type PyBytesObject \
--allowlist-type PyASCIIObject \
--allowlist-type PyUnicodeObject \
--allowlist-type PyCompactUnicodeObject \
--allowlist-type PyTupleObject \
--allowlist-type PyListObject \
--allowlist-type PyLongObject \
--allowlist-type PyFloatObject \
--allowlist-type PyDictObject \
--allowlist-type PyDictKeysObject \
--allowlist-type PyDictKeyEntry \
--allowlist-type PyDictUnicodeEntry \
--allowlist-type PyObject \
--allowlist-type PyTypeObject \
--allowlist-type PyHeapTypeObject \
-- -I . -I ./Include -I ./Include/internal
""")
if ret:
Expand Down Expand Up @@ -190,7 +192,7 @@ def extract_bindings(cpython_path, version, configure=False):
sys.exit(1)

if args.all:
versions = ['v3.8.0b4', 'v3.7.0', 'v3.6.6', 'v3.5.5', 'v3.4.8', 'v3.3.7', 'v3.2.6', 'v2.7.15']
versions = ["v2.7.18", "v3.5.10", "v3.6.15", "v3.7.15", "v3.8.15", "v3.9.15", "v3.10.9", "v3.11.0"]
else:
versions = args.versions
if not versions:
Expand Down
12 changes: 6 additions & 6 deletions src/coredump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::binary_parser::{parse_binary, BinaryInfo};
use crate::config::Config;
use crate::dump::print_trace;
use crate::python_bindings::{
v2_7_15, v3_10_0, v3_11_0, v3_3_7, v3_5_5, v3_6_6, v3_7_0, v3_8_0, v3_9_5,
v2_7_15, v3_10_9, v3_11_0, v3_3_7, v3_5_5, v3_6_15, v3_7_15, v3_8_15, v3_9_15,
};
use crate::python_data_access::format_variable;
use crate::python_interpreters::InterpreterState;
Expand Down Expand Up @@ -288,21 +288,21 @@ impl PythonCoreDump {
} => self._get_stack::<v3_5_5::_is>(config),
Version {
major: 3, minor: 6, ..
} => self._get_stack::<v3_6_6::_is>(config),
} => self._get_stack::<v3_6_15::_is>(config),
Version {
major: 3, minor: 7, ..
} => self._get_stack::<v3_7_0::_is>(config),
} => self._get_stack::<v3_7_15::_is>(config),
Version {
major: 3, minor: 8, ..
} => self._get_stack::<v3_8_0::_is>(config),
} => self._get_stack::<v3_8_15::_is>(config),
Version {
major: 3, minor: 9, ..
} => self._get_stack::<v3_9_5::_is>(config),
} => self._get_stack::<v3_9_15::_is>(config),
Version {
major: 3,
minor: 10,
..
} => self._get_stack::<v3_10_0::_is>(config),
} => self._get_stack::<v3_10_9::_is>(config),
Version {
major: 3,
minor: 11,
Expand Down
6 changes: 6 additions & 0 deletions src/python_bindings/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
pub mod v2_7_15;
pub mod v2_7_18;
pub mod v3_10_0;
pub mod v3_10_9;
pub mod v3_11_0;
pub mod v3_3_7;
pub mod v3_5_5;
pub mod v3_6_15;
pub mod v3_6_6;
pub mod v3_7_0;
pub mod v3_7_15;
pub mod v3_8_0;
pub mod v3_8_15;
pub mod v3_9_15;
pub mod v3_9_5;

// currently the PyRuntime struct used from Python 3.7 on really can't be
Expand Down
Loading

0 comments on commit fa46b7a

Please sign in to comment.