Skip to content
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

MACOSX_DEPLOYMENT_TARGET should be controlled by settings in addition to an env variable #43

Closed
nickelpro opened this issue Feb 7, 2025 · 4 comments

Comments

@nickelpro
Copy link

nickelpro commented Feb 7, 2025

Until 0.4 I've been manually handling CMAKE_MACOSX_DEPLOYMENT_TARGET under [tool.py-build-cmake.mac.cmake.options] which lets it live nicely alongside all its other MacOS-specific options.

0.4 overrides this with it's own -D option, which can only be controlled by an associated environment variable.

This puts me in a pickle, I can control this with an environment variable that lives elsewhere in the build hierarchy, but that non-locality is confusing and is difficult to override in the same manner as other CMake options.

So this should be controlled by a setting too, something like

[tool.py-build-cmake.cmake]
osx_deployment_target = <VERSION> || "manual"

Maybe or maybe not having priority over the environment variable.

This way the version can be managed as a setting, or prevent py-build-cmake from overriding the option at all and allow the user to manually set the deployment target in their mac.cmake.options.

A similar approach should be considered for other platform-specific options, for example MSVC_RUNTIME_LIBRARY.

@tttapa
Copy link
Owner

tttapa commented Feb 7, 2025

I'm a bit hesitant to add build platform-specific options to py-build-cmake.cmake. I don't believe that MACOSX_DEPLOYMENT_TARGET should be set by the project (at least not unconditionally): if a user tries to build a project from source, it should use a sensible value for their system, not a value that was hardcoded by the project author. Specifically, if future versions of Xcode drop support for older versions of the SDK, a hardcoded value of, say, 10.9 would prevent users from building the project from source. On the other hand, allowing project authors to set the minimum value that is required by the project could be useful.

But this could be tricky, as it would probably interfere with the value of MACOSX_DEPLOYMENT_TARGET that is set by tools such as cibuildwheel, because it also affects the platform tag of the generated wheels.

What are your thoughts?


Possibly relevant discussion: scikit-build/scikit-build-core#977

@nickelpro
Copy link
Author

Thinking about it again, I think a minimum value is exactly what I'm looking for.

When building in CI to publish for general consumption it's sufficient and appropriate to set this as an env variable, because such settings are linked to the particulars of that specific instance of the build.

However it is also necessary that a project be able to say, "I need symbols that only become available at such-and-such version", and can error out early and with a specific error message if trying to be built in an environment where that's not available.

@nickelpro
Copy link
Author

Ehhh, at the same time the appropriate place to check that minimum is in the CML itself, not py-build-cmake which might be bypassed.

Closing this because I don't think it's a feature that py-build-cmake actually needs. Jumped the gun because my workflow broke.

@tttapa
Copy link
Owner

tttapa commented Feb 9, 2025

I've added checks for MACOSX_DEPLOYMENT_TARGET and CMAKE_OSX_DEPLOYMENT_TARGET that produce a warning when users try to set them in the configuration file. This will hopefully prevent others from encountering the same issue:

2b0a529

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants