-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(cmake): support DEBUG_POSTFIX correctly #4761
Conversation
Into suffix and debug postfix. Pybind11 is currently treating both as suffix, which is problematic when something else defines the DEBUG_POSTFIX because they will be concatenated. pybind11_extension sets SUFFIX to _d.something and if DEBUG_POSTFIX is set to _d. _d + _d.something = _d_d.something The issue has been reported at: pybind#4699
This only fixes the |
Thanks @henryiii, would you be able to elaborate on this? As far as I can see, we are making a generic fix for the suffix and debug postfix independently from FindPythonInterp and FindPython? As far as I know, FindPythonInterp does not deal with suffix related things - it is a standalone find module that only invoked python for version information. How is this related to FindPythonInterp and FindPython? Apologies if I am missing something fundamental. Update: do you mean fixes in this file? https://github.com/pybind/pybind11/blob/master/tools/FindPythonLibsNew.cmake? E.g.: https://github.com/pybind/pybind11/blob/master/tools/FindPythonLibsNew.cmake#L175? I have personally not hit issues in that file, but that is likely because I have not used it myself, so it would be challenging for me to fix that without being able to test it. |
Ahh, due to the classic style naming, I think I had it backwards, but in general If you use FindPython before pybind11, or set PYBIND11_FINDPYTHON, you get the new one, otherwise you get the old one. |
Ahh, okay, slightly less worried about it since it's the old one. I can try to make the same change there in a couple of days (remind me if not). |
Having had a quick look, to me, it looks like So, as far as I can see, at least, we are OK. |
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
@henryiii Thanks for the update. All looks great. Ready to go merge? |
@henryiii You asked me to follow up in a couple of days. How is it going? Ready to merge? |
Trying to get at least one more set of eyes on it, just in case. :) |
@friendlyanon already had an eye in the original ticket? Would you like specifically another maintainer? |
Ideally I'd like another maintainer to okay it; according to our convention, since I didn't make the PR, my approval technically would be enough to merge it, but since I was involved in pushing to it, I'd like another maintainer just in case. :) Thought someone else aware of the situation (and able to test it!) would be great. I don't have any way to test it, and our CI doesn't cover it, which is another reason a set of eyes looking at it that didn't write it would be nice. |
@@ -172,13 +172,20 @@ _pybind11_get_if_undef(_PYTHON_VALUES 0 _PYTHON_VERSION_LIST) | |||
_pybind11_get_if_undef(_PYTHON_VALUES 1 PYTHON_PREFIX) | |||
_pybind11_get_if_undef(_PYTHON_VALUES 2 PYTHON_INCLUDE_DIR) | |||
_pybind11_get_if_undef(_PYTHON_VALUES 3 PYTHON_SITE_PACKAGES) | |||
_pybind11_get_if_undef(_PYTHON_VALUES 4 PYTHON_MODULE_EXTENSION) | |||
_pybind11_get_if_undef(_PYTHON_VALUES 5 PYTHON_IS_DEBUG) | |||
_pybind11_get_if_undef(_PYTHON_VALUES 6 PYTHON_SIZEOF_VOID_P) | |||
_pybind11_get_if_undef(_PYTHON_VALUES 7 PYTHON_LIBRARY_SUFFIX) | |||
_pybind11_get_if_undef(_PYTHON_VALUES 8 PYTHON_LIBDIR) | |||
_pybind11_get_if_undef(_PYTHON_VALUES 9 PYTHON_MULTIARCH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed the banner comment at the top of the file is very much out of date considering all the variables that are set in this file. Not relevant here, just something to look out for.
_pybind11_get_if_undef(_PYTHON_VALUES 5 PYTHON_IS_DEBUG) | ||
_pybind11_get_if_undef(_PYTHON_VALUES 6 PYTHON_SIZEOF_VOID_P) | ||
_pybind11_get_if_undef(_PYTHON_VALUES 7 PYTHON_LIBRARY_SUFFIX) | ||
_pybind11_get_if_undef(_PYTHON_VALUES 8 PYTHON_LIBDIR) | ||
_pybind11_get_if_undef(_PYTHON_VALUES 9 PYTHON_MULTIARCH) | ||
|
||
list(GET _PYTHON_VALUES 4 _PYTHON_MODULE_EXT_SUFFIX) | ||
if(PYBIND11_PYTHONLIBS_OVERWRITE OR NOT DEFINED PYTHON_MODULE_DEBUG_POSTFIX) | ||
get_filename_component(PYTHON_MODULE_DEBUG_POSTFIX "${_PYTHON_MODULE_EXT_SUFFIX}" NAME_WE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is indeed more convenient doing the same thing than my original suggestion. Nice :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were you able to test this change? If so, I think it's safe to go in, though ideally another maintainer will review just for completeness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but I don't write a ton of CMake.
It is unit tested locally against the original change. And it's cleaner, simpler, and implemented in both required places, instead of just one. I don't want a half-working change. I'd rather take it slow and get it right. I'm sure another maintainer will have a look shortly. Pybind11 has been used by thousands of projects over many years. I think waiting a couple more days for a small fix is okay. |
* fix: Use lowercase builtin collection names (pybind#4833) * Update render for buffer sequence and handle (pybind#4831) * fix: Add capitalize render name of `py::buffer` and `py::sequence` * fix: Render `py::handle` same way as `py::object` * tests: Fix tests `handle` -> `object` * tests: Test capitaliation of `py::sequence` and `py::buffer` * style: pre-commit fixes * fix: Render `py::object` as `Any` * Revert "fix: Render `py::object` as `Any`" This reverts commit 7861dcf. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com> * fix: Missing typed variants of `iterator` and `iterable` (pybind#4832) * Fix small bug introduced with PR pybind#4735 (pybind#4845) * Bug fix: `result[0]` called if `result.empty()` * Add unit test that fails without the fix. * fix(cmake): correctly detect FindPython policy and better warning (pybind#4806) * fix(cmake): support DEBUG_POSTFIX correctly (pybind#4761) * cmake: split extension Into suffix and debug postfix. Pybind11 is currently treating both as suffix, which is problematic when something else defines the DEBUG_POSTFIX because they will be concatenated. pybind11_extension sets SUFFIX to _d.something and if DEBUG_POSTFIX is set to _d. _d + _d.something = _d_d.something The issue has been reported at: pybind#4699 * style: pre-commit fixes * fix(cmake): support postfix for old FindPythonInterp mode too Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner <henryschreineriii@gmail.com> * Avoid copy in iteration by using const auto & (pybind#4861) This change is fixing a Coverity AUTO_CAUSES_COPY issues. * Add 2 missing `throw error_already_set();` (pybind#4863) Fixes oversights in PR pybind#4570. * MAINT: Include `numpy._core` imports (pybind#4857) * MAINT: Include numpy._core imports * style: pre-commit fixes * Apply review comments * style: pre-commit fixes * Add no-inline attribute * Select submodule name based on numpy version * style: pre-commit fixes * Update pre-commit check * Add error_already_set and simplify if statement * Update .pre-commit-config.yaml Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Ralf W. Grosse-Kunstleve <rwgkio@gmail.com> * MAINT: Remove np.int_ (pybind#4867) * chore(deps): update pre-commit hooks (pybind#4868) * chore(deps): update pre-commit hooks updates: - [github.com/psf/black-pre-commit-mirror: 23.7.0 → 23.9.1](psf/black-pre-commit-mirror@23.7.0...23.9.1) - [github.com/astral-sh/ruff-pre-commit: v0.0.287 → v0.0.292](astral-sh/ruff-pre-commit@v0.0.287...v0.0.292) - [github.com/codespell-project/codespell: v2.2.5 → v2.2.6](codespell-project/codespell@v2.2.5...v2.2.6) - [github.com/shellcheck-py/shellcheck-py: v0.9.0.5 → v0.9.0.6](shellcheck-py/shellcheck-py@v0.9.0.5...v0.9.0.6) - [github.com/PyCQA/pylint: v3.0.0a7 → v3.0.0](pylint-dev/pylint@v3.0.0a7...v3.0.0) * Update .pre-commit-config.yaml * style: pre-commit fixes * Update .pre-commit-config.yaml --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> --------- Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com> Co-authored-by: Sergei Izmailov <sergei.a.izmailov@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com> Co-authored-by: László Papp <108480845+lpapp-foundry@users.noreply.github.com> Co-authored-by: Oleksandr Pavlyk <oleksandr.pavlyk@intel.com> Co-authored-by: Mateusz Sokół <8431159+mtsokol@users.noreply.github.com>
Into suffix and debug postfix. Pybind11 is currently treating both as suffix, which is problematic when something else defines the DEBUG_POSTFIX because they will be concatenated.
pybind11_extension sets SUFFIX to _d.something and if DEBUG_POSTFIX is set to _d.
The issue has been reported at:
#4699
Description
Suggested changelog entry: