Skip to content

Commit

Permalink
alvistack/v2.9.2
Browse files Browse the repository at this point in the history
    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>
  • Loading branch information
hswong3i committed Jul 18, 2022
1 parent 2a9d993 commit cf6ed06
Show file tree
Hide file tree
Showing 20 changed files with 382 additions and 101 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- '3.6'
- '3.9'
- '3.10'
- '3.11-dev'
- 'pypy-3.7'
- 'pypy-3.8'

Expand Down Expand Up @@ -200,8 +201,8 @@ jobs:
- python-version: "3.9"
python-debug: true
valgrind: true
# - python-version: "3.11-dev"
# python-debug: false
- python-version: "3.11-dev"
python-debug: false

name: "🐍 ${{ matrix.python-version }}${{ matrix.python-debug && '-dbg' || '' }} (deadsnakes)${{ matrix.valgrind && ' • Valgrind' || '' }} • x64"
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:

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

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ pybind11Targets.cmake
/pybind11/share/*
/docs/_build/*
.ipynb_checkpoints/
.pybuild/
obj-x86_64-linux-gnu/
7 changes: 7 additions & 0 deletions debian/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.substvars
*debhelper*
.debhelper
files
pybind11-dev
python3-pybind11
tmp
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
python-pybind11 (100:2.9.2-2) UNRELEASED; urgency=medium

* https://github.com/pybind/pybind11/releases/tag/v2.9.2

-- Wong Hoi Sing Edison <hswong3i@gmail.com> Wed, 06 Jul 2022 06:35:48 +0000
52 changes: 52 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Source: python-pybind11
Section: libs
Priority: optional
Standards-Version: 4.5.0
Maintainer: Wong Hoi Sing Edison <hswong3i@gmail.com>
Homepage: https://github.com/pybind/pybind11/tags
Vcs-Browser: https://github.com/alvistack/pybind-pybind11
Vcs-Git: https://github.com/alvistack/pybind-pybind11.git
Build-Depends:
debhelper,
debhelper-compat (= 10),
dh-python,
cmake (>= 3.4),
fdupes,
python3-dev,
python3-setuptools,

Package: pybind11-dev
Architecture: all
Section: libdevel
Description: seamless operability between C++11 and Python
pybind11 is a lightweight header library that exposes C++ types in
Python and vice versa, mainly to create Python bindings of existing C++
code. Its goals and syntax are similar to the excellent Boost.Python
library by David Abrahams: to minimize boilerplate code in traditional
extension modules by inferring type information using compile-time
introspection.
.
This package provides the header-only library.
Depends:
${misc:Depends},
Recommends:
libeigen3-dev,

Package: python3-pybind11
Architecture: all
Section: python
Description: pybind11 helper module for Python 3
pybind11 is a lightweight header library that exposes C++ types in
Python and vice versa, mainly to create Python bindings of existing C++
code. Its goals and syntax are similar to the excellent Boost.Python
library by David Abrahams: to minimize boilerplate code in traditional
extension modules by inferring type information using compile-time
introspection.
.
This package provides pybind11 for Python 3.
Depends:
${misc:Depends},
${python3:Depends},
pybind11-dev (= ${source:Version}),
Recommends:
python3-numpy,
Empty file added debian/copyright
Empty file.
2 changes: 2 additions & 0 deletions debian/pybind11-dev.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
usr/include
usr/share/cmake usr/lib
3 changes: 3 additions & 0 deletions debian/pybind11-dev.lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pybind11-dev: copyright-without-copyright-notice
pybind11-dev: initial-upload-closes-no-bugs
pybind11-dev: zero-byte-file-in-doc-directory
4 changes: 4 additions & 0 deletions debian/python3-pybind11.lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
python3-pybind11: copyright-without-copyright-notice
python3-pybind11: initial-upload-closes-no-bugs
python3-pybind11: no-manual-page
python3-pybind11: zero-byte-file-in-doc-directory
27 changes: 27 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/make -f

SHELL := /bin/bash

export PYBUILD_NAME=pybind11

override_dh_auto_configure:
dh_auto_configure -- \
-DPYBIND11_INSTALL="ON" \
-DPYBIND11_TEST="OFF"

override_dh_auto_build:
dh_auto_build --buildsystem=pybuild
dh_auto_build

override_dh_auto_install:
dh_auto_install --buildsystem=pybuild
dh_auto_install
find debian/python3-pybind11/usr/lib/python*/*-packages -type f -name '*.pyc' -exec rm -rf {} \;
fdupes -qnrps debian/python3-pybind11/usr/lib/python*/*-packages

override_dh_auto_test:

override_dh_auto_clean:

%:
dh $@ --buildsystem=cmake --with python3
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
1 change: 1 addition & 0 deletions debian/source/lintian-overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python-pybind11 source: no-debian-changes
7 changes: 4 additions & 3 deletions include/pybind11/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,10 @@ struct type_record {

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

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

if (caster) {
base_info->implicit_casts.emplace_back(type, caster);
Expand Down
4 changes: 4 additions & 0 deletions include/pybind11/detail/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,12 @@ extern "C" inline int pybind11_clear(PyObject *self) {
inline void enable_dynamic_attributes(PyHeapTypeObject *heap_type) {
auto *type = &heap_type->ht_type;
type->tp_flags |= Py_TPFLAGS_HAVE_GC;
#if PY_VERSION_HEX < 0x030B0000
type->tp_dictoffset = type->tp_basicsize; // place dict at the end
type->tp_basicsize += (ssize_t) sizeof(PyObject *); // and allocate enough space for it
#else
type->tp_flags |= Py_TPFLAGS_MANAGED_DICT;
#endif
type->tp_traverse = pybind11_traverse;
type->tp_clear = pybind11_clear;

Expand Down
98 changes: 56 additions & 42 deletions include/pybind11/embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,47 +125,6 @@ inline wchar_t *widen_chars(const char *safe_arg) {
return widened_arg;
}

/// Python 2.x/3.x-compatible version of `PySys_SetArgv`
inline void set_interpreter_argv(int argc, const char *const *argv, bool add_program_dir_to_path) {
// Before it was special-cased in python 3.8, passing an empty or null argv
// caused a segfault, so we have to reimplement the special case ourselves.
bool special_case = (argv == nullptr || argc <= 0);

const char *const empty_argv[]{"\0"};
const char *const *safe_argv = special_case ? empty_argv : argv;
if (special_case) {
argc = 1;
}

auto argv_size = static_cast<size_t>(argc);
#if PY_MAJOR_VERSION >= 3
// SetArgv* on python 3 takes wchar_t, so we have to convert.
std::unique_ptr<wchar_t *[]> widened_argv(new wchar_t *[argv_size]);
std::vector<std::unique_ptr<wchar_t[], wide_char_arg_deleter>> widened_argv_entries;
widened_argv_entries.reserve(argv_size);
for (size_t ii = 0; ii < argv_size; ++ii) {
widened_argv_entries.emplace_back(widen_chars(safe_argv[ii]));
if (!widened_argv_entries.back()) {
// A null here indicates a character-encoding failure or the python
// interpreter out of memory. Give up.
return;
}
widened_argv[ii] = widened_argv_entries.back().get();
}

auto *pysys_argv = widened_argv.get();
#else
// python 2.x
std::vector<std::string> strings{safe_argv, safe_argv + argv_size};
std::vector<char *> char_strings{argv_size};
for (std::size_t i = 0; i < argv_size; ++i)
char_strings[i] = &strings[i][0];
char **pysys_argv = char_strings.data();
#endif

PySys_SetArgvEx(argc, pysys_argv, static_cast<int>(add_program_dir_to_path));
}

PYBIND11_NAMESPACE_END(detail)

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

#if PY_VERSION_HEX < 0x030B0000

Py_InitializeEx(init_signal_handlers ? 1 : 0);

detail::set_interpreter_argv(argc, argv, add_program_dir_to_path);
// Before it was special-cased in python 3.8, passing an empty or null argv
// caused a segfault, so we have to reimplement the special case ourselves.
bool special_case = (argv == nullptr || argc <= 0);

const char *const empty_argv[]{"\0"};
const char *const *safe_argv = special_case ? empty_argv : argv;
if (special_case) {
argc = 1;
}

auto argv_size = static_cast<size_t>(argc);
// SetArgv* on python 3 takes wchar_t, so we have to convert.
std::unique_ptr<wchar_t *[]> widened_argv(new wchar_t *[argv_size]);
std::vector<std::unique_ptr<wchar_t[], detail::wide_char_arg_deleter>> widened_argv_entries;
widened_argv_entries.reserve(argv_size);
for (size_t ii = 0; ii < argv_size; ++ii) {
widened_argv_entries.emplace_back(detail::widen_chars(safe_argv[ii]));
if (!widened_argv_entries.back()) {
// A null here indicates a character-encoding failure or the python
// interpreter out of memory. Give up.
return;
}
widened_argv[ii] = widened_argv_entries.back().get();
}

auto *pysys_argv = widened_argv.get();

PySys_SetArgvEx(argc, pysys_argv, static_cast<int>(add_program_dir_to_path));
#else
PyConfig config;
PyConfig_InitIsolatedConfig(&config);
config.install_signal_handlers = init_signal_handlers ? 1 : 0;

PyStatus status = PyConfig_SetBytesArgv(&config, argc, const_cast<char *const *>(argv));
if (PyStatus_Exception(status)) {
// A failure here indicates a character-encoding failure or the python
// interpreter out of memory. Give up.
PyConfig_Clear(&config);
throw std::runtime_error(PyStatus_IsError(status) ? status.err_msg
: "Failed to prepare CPython");
}
status = Py_InitializeFromConfig(&config);
PyConfig_Clear(&config);
if (PyStatus_Exception(status)) {
throw std::runtime_error(PyStatus_IsError(status) ? status.err_msg
: "Failed to init CPython");
}
if (add_program_dir_to_path) {
PyRun_SimpleString("import sys, os.path; "
"sys.path.insert(0, "
"os.path.abspath(os.path.dirname(sys.argv[0])) "
"if sys.argv and os.path.exists(sys.argv[0]) else '')");
}
#endif
}

/** \rst
Expand Down
14 changes: 2 additions & 12 deletions pybind11/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@


def get_include(user=False):
# type: (bool) -> str
installed_path = os.path.join(DIR, "include")
source_path = os.path.join(os.path.dirname(DIR), "include")
return installed_path if os.path.exists(installed_path) else source_path

return '/usr/include/pybind11'

def get_cmake_dir():
# type: () -> str
cmake_installed_path = os.path.join(DIR, "share", "cmake", "pybind11")
if os.path.exists(cmake_installed_path):
return cmake_installed_path
else:
msg = "pybind11 not installed, installation required to access the CMake files"
raise ImportError(msg)
return '/usr/share/cmake/pybind11'
41 changes: 0 additions & 41 deletions pyproject.toml

This file was deleted.

Loading

0 comments on commit cf6ed06

Please sign in to comment.