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

set MACOSX_DEPLOYMENT_TARGET for all stages? #563

Closed
minrk opened this issue Jan 26, 2021 · 3 comments · Fixed by #590
Closed

set MACOSX_DEPLOYMENT_TARGET for all stages? #563

minrk opened this issue Jan 26, 2021 · 3 comments · Fixed by #590

Comments

@minrk
Copy link
Contributor

minrk commented Jan 26, 2021

I recently adopted cibuildwheel (it is wonderful, thank you!), and made a broken release on older macs. The mistake I made was failing to set MACOSX_DEPLOYMENT_TARGET for the CIBW_BEFORE_ALL stage. I was surprised to see that CIBW has the feature to set MACOSX_DEPLOYMENT_TARGET, but doesn't do it for all stages.

#306 sets MACOSX_DEPLOYMENT_TARGET for python commands, but I was building a library dependency in CIBW_BEFORE_ALL.

My wheels are roughly:

  • CIBW_BEFORE_ALL compiles and installs a library
  • build my wheel that links the library
  • repair (auditwheel/delocate/delvewheel) bundles the library in the wheel

So my question is: should I have built the library in a different stage, or does it make sense to set the default MACOSX_DEPLOYMENT_TARGET for all commands, not just the python environment?

Fixing it was easy enough (set MACOSX_DEPLOYMENT_TARGET in global env)

@joerick
Copy link
Contributor

joerick commented Jan 26, 2021

Ah, I see. Yes the BEFORE_ALL commands on macOS and Windows run outside of a cibuildwheel Python environment, so we haven't set our environment variables yet.

Your workflow sounds sensible to me. (The only snag I can think of will be that once universal2 is supported (#484), you'll have to build your shared lib as universal2, also. But I think delocate should be able to handle it)

I'm not sure that we've built-in the assumption that BEFORE_ALL is for building dependencies exactly, but, it does seem pretty harmless to add env.setdefault('MACOSX_DEPLOYMENT_TARGET', '10.9') there. The other question we could consider, is 'should we run the macos BEFORE_ALL inside one of our Python environments, rather than in the system environment?' We do that on Linux, but that was only because the system Python on manylinux was 2.6 or something ancient.

But it's probably easier to do the simple thing - adding env.setdefault('MACOSX_DEPLOYMENT_TARGET', '10.9') before calling BEFORE_ALL.

@henryiii
Copy link
Contributor

henryiii commented Feb 1, 2021

env.setdefault('MACOSX_DEPLOYMENT_TARGET', '10.9') would still provide strange behavior if someone set CIBW_ENVIRONMENT: MACOSX_DEPLOYMENT_TARGET=10.14 (say, for C++17 support)? Seems like the correct thing would be to match Linux on Windows/macOS and make the environment affect all steps, since it already does that on Linux? We need to be careful not to override MACOSX_DEPLOYMENT_TARGET - most projects should be setting it, really, for constancy and control, but many don't.

@vegardjervell
Copy link

Just in case anyone comes looking here (like me) and doesn't immediately know how to "set MACOS_DEPLOYMENT_TARGET in the global env", what you want is to add the step

- name: Set macOS deployment target
  run: echo "MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion | cut -d '.' -f 1-2)" >> $GITHUB_ENV

before your cibuildwheel step, where the command sw_vers -productVersion | cut -d '.' -f 1-2 is used to detect the runners macOS version (if you're building for several versions, if not just specify it explicitly). To check that it was set correctly, you can use

- name: Check macOS deployment target
  run: echo "Deployment target version is ${{ env.MACOSX_DEPLOYMENT_TARGET }} / ${MACOSX_DEPLOYMENT_TARGET}"

where ${{ env.MACOSX_DEPLOYMENT_TARGET }} and ${MACOSX_DEPLOYMENT_TARGET} should be the same value.

basnijholt added a commit to basnijholt/pfapack that referenced this issue Dec 3, 2024
basnijholt added a commit to basnijholt/pfapack that referenced this issue Dec 4, 2024
* Use `pypa/cibuildwheel` to build wheels

* Set `meson_version: '>= 1.1.0'`

* Add dynamic versio

* Bump pypa/[email protected]

* Make pfapack/_version.py executable

* install pkg-config

* setup fortran in wheel build

* Set MACOSX_DEPLOYMENT_TARGET pypa/cibuildwheel#563

* Install with yum

* rm pkg-config

* add macos-14

* Use CIBW_TEST_EXTRAS

* only MACOSX_DEPLOYMENT_TARGET on mac

* yum pkgconfig

* use openblas-devel

* no lapack

* setup python

* setup python

* try openblas first

* Try manylinux_2_28

* env vars in pyproject.toml

* test cmd

* openblas finding

* skip

* Skip 32 bit Windows

* skip more

* skip -musllinux

* Skip all that scipy skips too
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

Successfully merging a pull request may close this issue.

4 participants