Skip to content

Conversation

@skarndev
Copy link
Contributor

@skarndev skarndev commented Jan 24, 2026

  • do not cascade install prefixes for a pure-C++ demo library (fixes Mac OS issues)
  • fixes for misleading RTTI on Clang with anonymous namespaces. namespace { struct Dummy {}; } in multiple translation units is treated as type redefinition by pybind11 on Clang (presumably due to mangling rules)
  • added tox.ini for running generation of test stubs locally.

… matrix by mapping the env name)

- do not cascade install prefixes for a pure-C++ demo library (fixes Mac OS issues)
- fixes for misleading RTTI on Clang with anonymous namespaces
@skarndev skarndev requested review from ax3l and virtuald January 26, 2026 19:16
@skarndev skarndev marked this pull request as ready for review January 26, 2026 19:17
@skarndev
Copy link
Contributor Author

skarndev commented Jan 26, 2026

I decided to leave the test matrix intact, and just reuse the .sh scripts in the tox.ini.
In order to run this locally, install requirements-dev.txt. UV can be used to install all of the Python interpreters we use to your system beforehand, e.g. uv install python 3.10.
The stub generation can be run like this: uv run tox

@ax3l
Copy link
Contributor

ax3l commented Jan 26, 2026

Thanks a lot for your work!

Do you mind adding the "how do I test and regenerate stub files" as a new section in the README file for now?

@ax3l ax3l added enhancement New feature or request documentation Incorrect, incomplete or missing documentation bug Something isn't working labels Jan 26, 2026
@skarndev
Copy link
Contributor Author

Thanks a lot for your work!

Do you mind adding the "how do I test and regenerate stub files" as a new section in the README file for now?

done

```shell
uv venv
source .venv/bin/activate
uv pip install -r requirements-dev.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be in the tox env only...

Suggested change
uv pip install -r requirements-dev.txt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But that includes tox itself?

Copy link
Contributor

Choose a reason for hiding this comment

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

The uv tool install tox --with tox-uv line should add that now.


During development, you may need to update the reference stubs in tests/stubs. This can be done locally using a convenience tox configuration. Ensure that all Python interpreters required by the test suite are available in your environment. For example, you can install them via uv:
```shell
uv python install 3.10 3.11 3.12 3.13
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
uv python install 3.10 3.11 3.12 3.13
uv python install -r --managed-python 3.10 3.11 3.12 3.13

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree on the --managed-python flag, even though it should not matter much for the workflow. why -r though?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I used -r/--reinstall to make sure it did a fresh install (of managed Pythons). Maybe not needed 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I think --managed-python is technically also the default of uv from what I saw in the docs.

flake8~=6.1.0
isort==5.10.1
numpy~=1.20
scipy~=1.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
scipy~=1.0
pip
scipy~=1.0

Comment on lines +6 to +8
py313-pb29-naa
py313-pb211-naa
py313-pb212-naa
Copy link
Contributor

Choose a reason for hiding this comment

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

The CMake logic in a few of these pybind versions is also a bit old and does not seem to work well with the tox/uv venvs -.-

Copy link
Contributor

@ax3l ax3l Jan 26, 2026

Choose a reason for hiding this comment

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

Hm, let's see if downgrading CMake a little from 3.31 helps... I see

      CMake Warning (dev) at /home/axel/src/pybind11-stubgen/tmp/pybind11-v2.13/install/share/cmake/pybind11/FindPythonLibsNew.cmake:101 (message):
        Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
        are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
        the cmake_policy command to set the policy and suppress this warning, or
        preferably upgrade to using FindPython, either by calling it explicitly
        before pybind11, or by setting PYBIND11_FINDPYTHON ON before pybind11.

Which was CMake 3.27+

Copy link
Contributor

Choose a reason for hiding this comment

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

Tried adding a cmake pin to 3.21 in requirements-dev.txt and in tox.ini, removed from allowlist_externals, but does not help.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am on cmake version 4.2.1, I do see the warnings though, but it builds. I am sure we can somehow pin a specific version of cmake per pybind11 version in tox.

@ax3l
Copy link
Contributor

ax3l commented Jan 26, 2026

I am a bit stuck, cannot get this to compile with all Pythons on Ubuntu...

#include <demo/sublibA/ConsoleColors.h>

namespace {
namespace aliases_detail {
Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to pull those C++ fixes into a separate PR while we continue to iterate on the tox uv setup..

@ax3l
Copy link
Contributor

ax3l commented Jan 26, 2026

@sizmailov @gentlegiantJGC how are you updating the silver stub files? I have a hard time to refresh all stubs on Ubuntu 24.04 LTS but someone must have a workflow that works :D

@skarndev
Copy link
Contributor Author

@sizmailov @gentlegiantJGC how are you updating the silver stub files? I have a hard time to refresh all stubs on Ubuntu 24.04 LTS but someone must have a workflow that works :D

I do have a VPS with exactly the same ubuntu version, I will test today there myself.

@skarndev
Copy link
Contributor Author

skarndev commented Jan 27, 2026

I am a bit stuck, cannot get this to compile with all Pythons on Ubuntu...

I was succesfully able to build this on Ubuntu 24.04 with a few extra steps, prior to install.
If you use uv to manage python versions, uv itself needs to be installed system-wide, not using pip into a venv. I used their official installer. (https://docs.astral.sh/uv/getting-started/installation/)

Eigen is needed to build the demo project. so apt install libeigen3-dev. Perhaps we need to include FetchContent/CPM thingy into the CMakeLists.txt, so that we do not depend on system-wide Eigen at build time. Not sure how this works on CI though.

cmake == 3.28.3

@sizmailov
Copy link
Collaborator

@ax3l When I were working on a feature/issue I was mostly focused on single set of stubs. I've made a CI step to produce set of patches on failure which I applied locally. Usually that was the last step on finalizing the PR. I think such setup works for a pet project but not for community-maintained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Incorrect, incomplete or missing documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants