Closed josch closed 5 months ago
In the top-level CMakeLists.txt, the src/python
directory should only be included if PYTHON
is set, so without that setting, the bindings should be ignored already:
if (PYTHON OR PYBIND11)
add_subdirectory(src/python)
endif()
Could the problem be that the PYTHON
variable is setting set in your build unintentionally? Admittedly, the naming is unnecessarily generic, it would be safer if named something specific to Imath, like IMATH_PYTHON
.
The Debian imath package explicitly wants to build the python binding. This is desirable (in Debian, we build source packages with all available features enabled) and not what I propose to change. For that reason, the Debian imath package sets -DPYTHON=ON
when building imath:
https://sources.debian.org/src/imath/3.1.9-3/debian/rules/#L21
But I'm not talking about making the python bindings optional when building imath. I'm talking about making them optional when installing everything and then building a package that uses imath via cmake. This is why this affects all the other packages I listed above. It is about building software that requires imath not about building imath itself. Through the EXPORT
statement, software that wants imath automatically also requires the python binding. That's the thing that I think should be different. None of the 134 software packages that directly or indirectly need imath to build fail to build after making the python bindings optional.
Ah, that makes sense, I was thinking only of the build. If you're confident that removing the EXPORT solves the problem and isn't otherwise necessary, please do submit a PR. As you point out, we should also clarify the wording in the README.md to state that the bindings are optional at build time.
Hi,
the second paragraph of the
README.md
states:The python bindings though, are in fact (as of the time i'm writing this) not optional. If one tries to build a project that requires imath using cmake one gets the following error output during configuration if the python bindings are not installed:
What makes the python bindings not optional is the
EXPORT
line insrc/python/config/ModuleDefine.cmake
. The following patch fixes the problem and makes the python bindings indeed optional as stated in the readme:To make sure, that this does not break anything, I obtained a list of all source packages in Debian unstable which directly or indirectly use imath. The full list is:
Out of those packages, the following packages fail with above error if the python imath module is not installed:
After removing the
EXPORT
line, these build successfully again. Credit goes to @jspricke for finding theEXPORT
line as the culprit.Would you like me to file a pull request with the change proposed above?
The practical problem that removing the hard python requirement solves is, that otherwise packages that directly or indirectly require imath will pull in the host architecture python which makes the cross-build dependencies unsatisfiable for the long list of packages above.
Thanks!