Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,23 @@ jobs:


manylinux:
name: Manylinux on 🐍 3.14t
name: Manylinux on 🐍 ${{ matrix.python-version }} (${{ matrix.container }})
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
include:
- container: quay.io/pypa/manylinux_2_28_x86_64:latest
python-version: '3.13t'
- container: quay.io/pypa/musllinux_1_2_x86_64:latest
python-version: '3.13t'
- container: quay.io/pypa/manylinux_2_28_x86_64:latest
python-version: '3.14t'
- container: quay.io/pypa/musllinux_1_2_x86_64:latest
python-version: '3.14t'
runs-on: ubuntu-latest
timeout-minutes: 40
container: quay.io/pypa/musllinux_1_2_x86_64:latest
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v6
with:
Expand All @@ -254,7 +266,7 @@ jobs:
run: uv tool install ninja

- name: Configure via preset
run: cmake --preset venv -DPYBIND11_CREATE_WITH_UV=python3.14t
run: cmake --preset venv -DPYBIND11_CREATE_WITH_UV="${{ matrix.python-version }}"

- name: Build C++11
run: cmake --build --preset venv
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:

- name: Setup Boost (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install libboost-dev
run: sudo apt-get update && sudo apt-get install -y libboost-dev

- name: Setup Boost (macOS)
if: runner.os == 'macOS'
Expand Down
7 changes: 7 additions & 0 deletions include/pybind11/detail/internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ using instance_map = std::unordered_multimap<const void *, instance *>;
#ifdef Py_GIL_DISABLED
// Wrapper around PyMutex to provide BasicLockable semantics
class pymutex {
# if PY_VERSION_HEX >= 0x030E00C1 // 3.14.0rc1
friend class pycritical_section;
# endif
PyMutex mutex;

public:
Expand All @@ -239,6 +241,8 @@ class pymutex {
void unlock() { PyMutex_Unlock(&mutex); }
};

// PyCriticalSection_BeginMutex was added in Python 3.15.0a1 and backported to 3.14.0rc1
# if PY_VERSION_HEX >= 0x030E00C1 // 3.14.0rc1
class pycritical_section {
pymutex &mutex;
PyCriticalSection cs;
Expand All @@ -255,6 +259,9 @@ class pycritical_section {
pycritical_section(pycritical_section &&) = delete;
pycritical_section &operator=(pycritical_section &&) = delete;
};
# else
using pycritical_section = std::unique_lock<pymutex>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you go this route, you should also exclude the PYBIND11_LOCK_INTERNALS() at:

PYBIND11_LOCK_INTERNALS(get_internals());

with an #ifdef guard so that it's not included in PY_VERSION_HEX < 0x030E00C1. Otherwise, you'll have a deadlock.

# endif

// Instance map shards are used to reduce mutex contention in free-threaded Python.
struct instance_map_shard {
Expand Down
12 changes: 12 additions & 0 deletions tests/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
WIN = sys.platform.startswith("win32") or sys.platform.startswith("cygwin")
FREEBSD = sys.platform.startswith("freebsd")

MUSLLINUX = False
MANYLINUX = False
if LINUX:

def _is_musl() -> bool:
libc, _ = platform.libc_ver()
return libc == "musl" or (libc != "glibc" and libc != "")

MUSLLINUX = _is_musl()
MANYLINUX = not MUSLLINUX
del _is_musl

CPYTHON = platform.python_implementation() == "CPython"
PYPY = platform.python_implementation() == "PyPy"
GRAALPY = sys.implementation.name == "graalpy"
Expand Down
1 change: 1 addition & 0 deletions tests/test_multiple_interpreters.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ def test_import_in_subinterpreter_before_main():
@pytest.mark.skipif(
sys.platform.startswith("emscripten"), reason="Requires loadable modules"
)
@pytest.mark.xfail(env.MUSLLINUX, reason="Flaky on musllinux", strict=False)
@pytest.mark.skipif(not CONCURRENT_INTERPRETERS_SUPPORT, reason="Requires 3.14.0b3+")
def test_import_in_subinterpreter_concurrently():
"""Tests that importing a module in multiple subinterpreters concurrently works correctly"""
Expand Down
Loading