Skip to content

Commit 0469832

Browse files
committed
alvistack/v2.9.2
git clean -xdf tar zcvf ../python-pybind11_2.9.2.orig.tar.gz --exclude=.git . debuild -uc -us cp python-pybind11.spec ../python-pybind11_2.9.2-2.spec mv ../python*-pybind11*2.9.2*.{gz,xz,spec,dsc} /osc/home\:alvistack/pybind-pybind11-2.9.2/ rm -rf ../*pybind11*2.9.2*.* See pybind#3923 Signed-off-by: Wong Hoi Sing Edison <hswong3i@pantarei-design.com>
1 parent 2a9d993 commit 0469832

20 files changed

+382
-101
lines changed

.github/workflows/ci.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
- '3.6'
3131
- '3.9'
3232
- '3.10'
33+
- '3.11-dev'
3334
- 'pypy-3.7'
3435
- 'pypy-3.8'
3536

@@ -200,8 +201,8 @@ jobs:
200201
- python-version: "3.9"
201202
python-debug: true
202203
valgrind: true
203-
# - python-version: "3.11-dev"
204-
# python-debug: false
204+
- python-version: "3.11-dev"
205+
python-debug: false
205206

206207
name: "🐍 ${{ matrix.python-version }}${{ matrix.python-debug && '-dbg' || '' }} (deadsnakes)${{ matrix.valgrind && ' • Valgrind' || '' }} • x64"
207208
runs-on: ubuntu-latest

.github/workflows/upstream.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414

1515
jobs:
1616
standard:
17-
name: "🐍 3.11 dev • ubuntu-latest • x64"
17+
name: "🐍 3.11 latest internals • ubuntu-latest • x64"
1818
runs-on: ubuntu-latest
1919
if: "contains(github.event.pull_request.labels.*.name, 'python dev')"
2020

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ pybind11Targets.cmake
4343
/pybind11/share/*
4444
/docs/_build/*
4545
.ipynb_checkpoints/
46+
.pybuild/
47+
obj-x86_64-linux-gnu/

debian/.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.substvars
2+
*debhelper*
3+
.debhelper
4+
files
5+
pybind11-dev
6+
python3-pybind11
7+
tmp

debian/changelog

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
python-pybind11 (100:2.9.2-2) UNRELEASED; urgency=medium
2+
3+
* https://github.com/pybind/pybind11/releases/tag/v2.9.2
4+
5+
-- Wong Hoi Sing Edison <hswong3i@gmail.com> Wed, 06 Jul 2022 06:35:48 +0000

debian/control

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Source: python-pybind11
2+
Section: libs
3+
Priority: optional
4+
Standards-Version: 4.5.0
5+
Maintainer: Wong Hoi Sing Edison <hswong3i@gmail.com>
6+
Homepage: https://github.com/pybind/pybind11/tags
7+
Vcs-Browser: https://github.com/alvistack/pybind-pybind11
8+
Vcs-Git: https://github.com/alvistack/pybind-pybind11.git
9+
Build-Depends:
10+
debhelper,
11+
debhelper-compat (= 10),
12+
dh-python,
13+
cmake (>= 3.4),
14+
fdupes,
15+
python3-dev,
16+
python3-setuptools,
17+
18+
Package: pybind11-dev
19+
Architecture: all
20+
Section: libdevel
21+
Description: seamless operability between C++11 and Python
22+
pybind11 is a lightweight header library that exposes C++ types in
23+
Python and vice versa, mainly to create Python bindings of existing C++
24+
code. Its goals and syntax are similar to the excellent Boost.Python
25+
library by David Abrahams: to minimize boilerplate code in traditional
26+
extension modules by inferring type information using compile-time
27+
introspection.
28+
.
29+
This package provides the header-only library.
30+
Depends:
31+
${misc:Depends},
32+
Recommends:
33+
libeigen3-dev,
34+
35+
Package: python3-pybind11
36+
Architecture: all
37+
Section: python
38+
Description: pybind11 helper module for Python 3
39+
pybind11 is a lightweight header library that exposes C++ types in
40+
Python and vice versa, mainly to create Python bindings of existing C++
41+
code. Its goals and syntax are similar to the excellent Boost.Python
42+
library by David Abrahams: to minimize boilerplate code in traditional
43+
extension modules by inferring type information using compile-time
44+
introspection.
45+
.
46+
This package provides pybind11 for Python 3.
47+
Depends:
48+
${misc:Depends},
49+
${python3:Depends},
50+
pybind11-dev (= ${source:Version}),
51+
Recommends:
52+
python3-numpy,

debian/copyright

Whitespace-only changes.

debian/pybind11-dev.install

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
usr/include
2+
usr/share/cmake usr/lib

debian/pybind11-dev.lintian-overrides

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pybind11-dev: copyright-without-copyright-notice
2+
pybind11-dev: initial-upload-closes-no-bugs
3+
pybind11-dev: zero-byte-file-in-doc-directory
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
python3-pybind11: copyright-without-copyright-notice
2+
python3-pybind11: initial-upload-closes-no-bugs
3+
python3-pybind11: no-manual-page
4+
python3-pybind11: zero-byte-file-in-doc-directory

debian/rules

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/make -f
2+
3+
SHELL := /bin/bash
4+
5+
export PYBUILD_NAME=pybind11
6+
7+
override_dh_auto_configure:
8+
dh_auto_configure -- \
9+
-DPYBIND11_INSTALL="ON" \
10+
-DPYBIND11_TEST="OFF"
11+
12+
override_dh_auto_build:
13+
dh_auto_build --buildsystem=pybuild
14+
dh_auto_build
15+
16+
override_dh_auto_install:
17+
dh_auto_install --buildsystem=pybuild
18+
dh_auto_install
19+
find debian/python3-pybind11/usr/lib/python*/*-packages -type f -name '*.pyc' -exec rm -rf {} \;
20+
fdupes -s debian/python3-pybind11/usr/lib/python*/*-packages
21+
22+
override_dh_auto_test:
23+
24+
override_dh_auto_clean:
25+
26+
%:
27+
dh $@ --buildsystem=cmake --with python3

debian/source/format

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0 (quilt)

debian/source/lintian-overrides

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-pybind11 source: no-debian-changes

include/pybind11/attr.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,10 @@ struct type_record {
345345

346346
bases.append((PyObject *) base_info->type);
347347

348-
if (base_info->type->tp_dictoffset != 0) {
349-
dynamic_attr = true;
350-
}
348+
dynamic_attr |= base_info->type->tp_dictoffset != 0;
349+
#if PY_VERSION_HEX >= 0x030B0000
350+
dynamic_attr |= (base_info->type->tp_flags & Py_TPFLAGS_MANAGED_DICT) != 0;
351+
#endif
351352

352353
if (caster) {
353354
base_info->implicit_casts.emplace_back(type, caster);

include/pybind11/detail/class.h

+4
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,12 @@ extern "C" inline int pybind11_clear(PyObject *self) {
547547
inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
548548
auto *type = &heap_type->ht_type;
549549
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
550+
#if PY_VERSION_HEX < 0x030B0000
550551
type->tp_dictoffset = type->tp_basicsize; // place dict at the end
551552
type->tp_basicsize += (ssize_t) sizeof(PyObject *); // and allocate enough space for it
553+
#else
554+
type->tp_flags |= Py_TPFLAGS_MANAGED_DICT;
555+
#endif
552556
type->tp_traverse = pybind11_traverse;
553557
type->tp_clear = pybind11_clear;
554558

include/pybind11/embed.h

+56-42
Original file line numberDiff line numberDiff line change
@@ -125,47 +125,6 @@ inline wchar_t *widen_chars(const char *safe_arg) {
125125
return widened_arg;
126126
}
127127

128-
/// Python 2.x/3.x-compatible version of `PySys_SetArgv`
129-
inline void set_interpreter_argv(int argc, const char *const *argv, bool add_program_dir_to_path) {
130-
// Before it was special-cased in python 3.8, passing an empty or null argv
131-
// caused a segfault, so we have to reimplement the special case ourselves.
132-
bool special_case = (argv == nullptr || argc <= 0);
133-
134-
const char *const empty_argv[]{"\0"};
135-
const char *const *safe_argv = special_case ? empty_argv : argv;
136-
if (special_case) {
137-
argc = 1;
138-
}
139-
140-
auto argv_size = static_cast<size_t>(argc);
141-
#if PY_MAJOR_VERSION >= 3
142-
// SetArgv* on python 3 takes wchar_t, so we have to convert.
143-
std::unique_ptr<wchar_t *[]> widened_argv(new wchar_t *[argv_size]);
144-
std::vector<std::unique_ptr<wchar_t[], wide_char_arg_deleter>> widened_argv_entries;
145-
widened_argv_entries.reserve(argv_size);
146-
for (size_t ii = 0; ii < argv_size; ++ii) {
147-
widened_argv_entries.emplace_back(widen_chars(safe_argv[ii]));
148-
if (!widened_argv_entries.back()) {
149-
// A null here indicates a character-encoding failure or the python
150-
// interpreter out of memory. Give up.
151-
return;
152-
}
153-
widened_argv[ii] = widened_argv_entries.back().get();
154-
}
155-
156-
auto *pysys_argv = widened_argv.get();
157-
#else
158-
// python 2.x
159-
std::vector<std::string> strings{safe_argv, safe_argv + argv_size};
160-
std::vector<char *> char_strings{argv_size};
161-
for (std::size_t i = 0; i < argv_size; ++i)
162-
char_strings[i] = &strings[i][0];
163-
char **pysys_argv = char_strings.data();
164-
#endif
165-
166-
PySys_SetArgvEx(argc, pysys_argv, static_cast<int>(add_program_dir_to_path));
167-
}
168-
169128
PYBIND11_NAMESPACE_END(detail)
170129

171130
/** \rst
@@ -195,9 +154,64 @@ inline void initialize_interpreter(bool init_signal_handlers = true,
195154
pybind11_fail("The interpreter is already running");
196155
}
197156

157+
#if PY_VERSION_HEX < 0x030B0000
158+
198159
Py_InitializeEx(init_signal_handlers ? 1 : 0);
199160

200-
detail::set_interpreter_argv(argc, argv, add_program_dir_to_path);
161+
// Before it was special-cased in python 3.8, passing an empty or null argv
162+
// caused a segfault, so we have to reimplement the special case ourselves.
163+
bool special_case = (argv == nullptr || argc <= 0);
164+
165+
const char *const empty_argv[]{"\0"};
166+
const char *const *safe_argv = special_case ? empty_argv : argv;
167+
if (special_case) {
168+
argc = 1;
169+
}
170+
171+
auto argv_size = static_cast<size_t>(argc);
172+
// SetArgv* on python 3 takes wchar_t, so we have to convert.
173+
std::unique_ptr<wchar_t *[]> widened_argv(new wchar_t *[argv_size]);
174+
std::vector<std::unique_ptr<wchar_t[], detail::wide_char_arg_deleter>> widened_argv_entries;
175+
widened_argv_entries.reserve(argv_size);
176+
for (size_t ii = 0; ii < argv_size; ++ii) {
177+
widened_argv_entries.emplace_back(detail::widen_chars(safe_argv[ii]));
178+
if (!widened_argv_entries.back()) {
179+
// A null here indicates a character-encoding failure or the python
180+
// interpreter out of memory. Give up.
181+
return;
182+
}
183+
widened_argv[ii] = widened_argv_entries.back().get();
184+
}
185+
186+
auto *pysys_argv = widened_argv.get();
187+
188+
PySys_SetArgvEx(argc, pysys_argv, static_cast<int>(add_program_dir_to_path));
189+
#else
190+
PyConfig config;
191+
PyConfig_InitIsolatedConfig(&config);
192+
config.install_signal_handlers = init_signal_handlers ? 1 : 0;
193+
194+
PyStatus status = PyConfig_SetBytesArgv(&config, argc, const_cast<char *const *>(argv));
195+
if (PyStatus_Exception(status)) {
196+
// A failure here indicates a character-encoding failure or the python
197+
// interpreter out of memory. Give up.
198+
PyConfig_Clear(&config);
199+
throw std::runtime_error(PyStatus_IsError(status) ? status.err_msg
200+
: "Failed to prepare CPython");
201+
}
202+
status = Py_InitializeFromConfig(&config);
203+
PyConfig_Clear(&config);
204+
if (PyStatus_Exception(status)) {
205+
throw std::runtime_error(PyStatus_IsError(status) ? status.err_msg
206+
: "Failed to init CPython");
207+
}
208+
if (add_program_dir_to_path) {
209+
PyRun_SimpleString("import sys, os.path; "
210+
"sys.path.insert(0, "
211+
"os.path.abspath(os.path.dirname(sys.argv[0])) "
212+
"if sys.argv and os.path.exists(sys.argv[0]) else '')");
213+
}
214+
#endif
201215
}
202216

203217
/** \rst

pybind11/commands.py

+2-12
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,7 @@
55

66

77
def get_include(user=False):
8-
# type: (bool) -> str
9-
installed_path = os.path.join(DIR, "include")
10-
source_path = os.path.join(os.path.dirname(DIR), "include")
11-
return installed_path if os.path.exists(installed_path) else source_path
12-
8+
return '/usr/include/pybind11'
139

1410
def get_cmake_dir():
15-
# type: () -> str
16-
cmake_installed_path = os.path.join(DIR, "share", "cmake", "pybind11")
17-
if os.path.exists(cmake_installed_path):
18-
return cmake_installed_path
19-
else:
20-
msg = "pybind11 not installed, installation required to access the CMake files"
21-
raise ImportError(msg)
11+
return '/usr/share/cmake/pybind11'

pyproject.toml

-41
This file was deleted.

0 commit comments

Comments
 (0)