Open ilya-lavrenov opened 1 week ago
This appears to be another distlib limitation. py-build-cmake uses distlib.util.get_platform()
.
Tools like cibuildwheel set the _PYTHON_HOST_PLATFORM
environment variable, e.g. _PYTHON_HOST_PLATFORM='macosx-11.0-arm64'
, which does get respected.
I'll have a look at implementing some MACOSX_DEPLOYMENT_TARGET
-awareness in py-build-cmake.
I'll have a look at implementing some MACOSX_DEPLOYMENT_TARGET-awareness in py-build-cmake.
Would be great to support it.
Overall, most of tickets I create - respect actual build env in wheel meta info / file name 😺
BTW, one of the benefits I see in py-build-cmake
is that we don't need to specify _PYTHON_HOST_PLATFORM
, which in case of cross-compilation leads to installation of build requirements for host system. And hence, cmake
installed as host requirement, cannot be run on build platform.
The main problem here is that py-build-cmake can only try to make a guess: Having MACOSX_DEPLOYMENT_TARGET
set in the environment provides no guarantee whatsoever that the package will actually run on such a target. For example, some of the dependencies may be compiled with later versions of macOS, or MACOSX_DEPLOYMENT_TARGET
may not have been set during a previous CMake run, and the cached object files with the wrong version are re-used.
Given this situation, I feel like the only safe thing that py-build-cmake can do is simply use the current interpreter's value of distlib.util.get_platform()
and ignore any environment variables that may or may not have been set while the code and/or dependencies were built.
Either that, or the user should tell py-build-cmake explicitly what the correct platform tag should be, and then all the onus is on the user (or on a tool cibuildwheel).
What are your thoughts on this?
What are your thoughts on this?
My thought is that as an user, I don't want to think that internally some packages like distlib
provide wrong values and don't respect my environment.
When I compile python extension with a given MACOSX_DEPLOYMENT_TARGET
value, I want all build stack to respect it. But currently, compiler respects this value, while packaging tool does not do it. And, hence, I need to perform post-processing of resulting wheel package or set the same information multiple time (I mean --config-settings=override=cross.arch="macosx_11_0_arm64").
IMO, MACOSX_DEPLOYMENT_TARGET
is a well-known standard on macOS and should be respected by all the tool.
For example, some of the dependencies may be compiled with later versions of macOS
Why should we consider weird cases (when non-experienced developers mix wrong binaries) as default case? Default case - out of box convenience.
Even now, users can build on macOS 12 with some dependences from macOS 14 and platform tag will be detected as macosx_12_0_arm64
.
Command to build project:
Logs and final package:
It can be overridden via extra option
--config-settings=override=cross.arch="macosx_11_0_arm64"
But some other projects like
scikit-build-core
respect this option