Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BLD: Update to macos-11 for x86_64 wheels. #22534

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

Closed
wants to merge 6 commits into from

Conversation

charris
Copy link
Member

@charris charris commented Nov 4, 2022

The tests were already updated, but the wheels remained at macos-10.15. This updates the wheel builds as well and should avoid the warning that 10.15 will be removed in December 2022.

The tests were already updated, but the wheels remained at macos-10.15.
This updates the wheel builds as well and should avoid the warning that
10.15 will be removed in December 2022.
@charris charris added the 36 - Build Build related PR label Nov 4, 2022
@charris charris added this to the 1.24.0 release milestone Nov 4, 2022
@charris
Copy link
Member Author

charris commented Nov 4, 2022

@mattip @h-vetinari Ping. Note that the openblas libraries are still labeled 10.9.

@charris
Copy link
Member Author

charris commented Nov 4, 2022

There are Fortran problems. I assume something like

LIBRARY_PATH: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib

is needed here. @mattip ?

@mattip
Copy link
Member

mattip commented Nov 5, 2022

It seems something like that might be needed for the gfortran compiler.

@rgommers
Copy link
Member

rgommers commented Nov 5, 2022

See https://github.com/scipy/scipy/blob/1d80a2f254380d2b45733258ca42eb6b55c8755b/.github/workflows/wheels.yml#L82-L87 for more details on gfortran. Cc @andyfaff, who discovered the same issue when updating SciPy wheel builds.

@charris
Copy link
Member Author

charris commented Nov 5, 2022

Thanks Ralf. Makes me curious as to why macos-11 works on azure. In any case, I think we should put some effort into getting this working. Do you think macos-12 would be a better target? That seems to be what SciPy is using for the arm64 builds.

@rgommers
Copy link
Member

rgommers commented Nov 5, 2022

Do you think macos-12 would be a better target? That seems to be what SciPy is using for the arm64 builds.

macOS 11 has a bug that leads to a kernel panic when used with some functionality in sparse.linalg, that's why we're avoiding shipping wheels for macOS 11. For NumPy it's better to stay on 11.

@mattip
Copy link
Member

mattip commented Nov 5, 2022

Over at #22525 I am trying to get OpenBLAS 0.3.21 working. In PR MacPython/openblas-libs#89 I built the openblas libraries and updated the macOS image to mac-11 without updating the gfortran toolchain on macOS.

@andyfaff
Copy link
Member

andyfaff commented Nov 6, 2022

Here are my notes from fiddling around today when trying to build macosx_x86_64 wheels on my scipy fork:

  1. I changed the macOS image from macos-10.15 to macos-11. I also changed OpenBLAS to v0.3.21.
  2. When I do that the gfortran-4.9.0-Mavericks compiler can no longer be used to compile programs - it just doesn't work on macos-11.
  3. I then installed gfortran-11.2 for BigSur from fxcoudert instead of the ancient version of gfortran.
  4. When I use this compiler I get lots of
  ld: warning: dylib (/usr/local/gfortran/lib/libgfortran.dylib) was built for newer macOS version (11.5) than being linked (10.9)
  ld: warning: dylib (/usr/local/gfortran/lib/libquadmath.dylib) was built for newer macOS version (11.5) than being linked (10.9)
  1. If I try to set MACOSX_DEPLOYMENT_TARGET=10.15 I (obviously) still get the warnings. I therefore tried older compilers to see if I could go further back than 11.5.
  2. I then tried using gfortran-8.2 and set MACOSX_DEPLOYMENT_TARGET=10.15. This time when I build I no longer get the ld warnings from step 5.
  3. The build 'completes'. However, the delocate step fails:
/usr/local/gfortran/lib/libgfortran.3.dylib not found:
    Needed by: /usr/local/lib/libopenblas.0.dylib
ERROR:delocate.libsana:
  /usr/local/gfortran/lib/libgfortran.3.dylib not found:
    Needed by: /usr/local/lib/libopenblas.0.dylib

This is because OpenBLAS on anaconda is built against libgfortran.3.dylib, but gfortran-8 supplies libgfortran.5.dylib.
8. In order to get libgfortran.3.dylib you have to use gfortran <= 6.x. I didn't try gfortran-6.3 because it's quite old.

From discussions elsewhere it seems that there's a desire (at least in scipy) to update to at least gfortran-8. From my understanding of the above behaviour this would at least allow one to target 10.15. A deployment target of 10.9 doesn't seem sensible to me.

Perhaps we need to:

  1. Make gfortran-8 the minimum compiler (libgfortran.5.dylib)
  2. Update the deployment target to 10.15 across the board.
  3. Update the OpenBLAS multibuild on macos to reflect 1+2.
  4. On scipy can we bump to OpenBLAS v0.3.21?

Note: this only applies to the x86_64 builds, the arm64 gfortran compilers are much more modern.

@mattip, what gfortran compiler did you get to work on macos-11, that uses libgfortran.3.dylib (needed by the OpenBLAS on anaconda), that can also deploy against 10.9/10.14/10.15?

@mattip
Copy link
Member

mattip commented Nov 6, 2022

what gfortran compiler did you get to work

In #22525 I did not update the macos image at all.

@mattip
Copy link
Member

mattip commented Nov 6, 2022

Perhaps we need to: ...

These steps make sense to me. Would you like to submit a PR to MacPython/openblas-libs?

@rgommers
Copy link
Member

rgommers commented Nov 6, 2022

+1 to bumping to at least gfortran 8.

Regarding minimum macOS version: 10.15 is a bit too aggressive; the problem is that users on <=10.14 will then get builds from source, rather than an older wheel. 10.14 is about 4 years old, and I expect it's still around enough to be a problem in practice. I also had a quick browse around, currently Matplotlib uses 10.12 and PyArrow 10.14, those are the newest versions I found. I'd expect that 10.12 or 10.13 would be okay, 10.14 borderline, and 10.15 too new.

@andyfaff
Copy link
Member

andyfaff commented Nov 6, 2022

These steps make sense to me. Would you like to submit a PR to MacPython/openblas-libs?

Normally yes, but it's not quite clear to me where to even start.

@mattip
Copy link
Member

mattip commented Nov 6, 2022

Ok, let me try.

I then tried using gfortran-8.2 ...

I think this should replace the one in https://github.com/MacPython/gfortran-install/tree/master/archives, and the README updated appropriately

@mattip
Copy link
Member

mattip commented Nov 6, 2022

xref MacPython/openblas-libs#90

@charris
Copy link
Member Author

charris commented Nov 6, 2022

Will gfortran 8.2 for Mojave (macOS 10.14) actually install on macos 11?

@mattip
Copy link
Member

mattip commented Nov 6, 2022

There are now macos-10.11 builds of openblas 0.3.21 with the gfortran8 gfortran compiler on https://anaconda.org/multibuild-wheels-staging/openblas-libs/files. If we could easily update to 0.3.21, we could change the openblas suffix to 10_11 instead of 10_9. Unfortunately then using 0.3.21 will hit the windows build problems from #22525.

That compiler was built for macos 10.14, and there are ld warnings

ld: warning: dylib (/usr/local/gfortran/lib/libgfortran.dylib) was built for newer macOS version (10.14) than being linked (10.11)

Will that cause problems when targeting 10.11?

@charris
Copy link
Member Author

charris commented Nov 6, 2022

@mattip Why 10.11?

@mattip
Copy link
Member

mattip commented Nov 6, 2022

Why 10.11

If we are not going with 10.14, then 10.11 seemed like a good minimum version.

@h-vetinari
Copy link
Contributor

I think it would be a good time to retry the "repackage-gfortran-from-conda-forge" idea. Our gfortran is compatible all the way back to 10.9.

At the time it wasn't clear where to do the repackaging: MacPython/gfortran-install#7

CC @isuruf

@andyfaff
Copy link
Member

andyfaff commented Nov 6, 2022

Will gfortran 8.2 for Mojave (macOS 10.14) actually install on macos 11?

The installer package I linked to above is installable on the GH Actions macos-11 image (already tried that).

That compiler was built for macos 10.14, and there are ld warnings
ld: warning: dylib (/usr/local/gfortran/lib/libgfortran.dylib) was built for newer macOS version (10.14) than being linked (10.11)
Will that cause problems when targeting 10.11?

From what the warning says I would've thought so, perhaps the minimum macOS version we can target with that compiler becomes 10.14. I tried to search for the warning but get no clear guidance on whether binaries built with that would work on <10.14.

There may be compilers for gfortran-8 that were built for older macOS, but I can't find any immediately. This page has a gfortran-6 package for 10.11 and up.

@isuruf
Copy link
Contributor

isuruf commented Nov 6, 2022

I can repackage one from conda-forge for you until we figure out MacPython/gfortran-install#7

Which gfortran do you need? 9.5.0 or 10.4.0 or 11.3.0? They'll be compatible with macos 10.9 and later

@andyfaff
Copy link
Member

andyfaff commented Nov 6, 2022

Which gfortran do you need?

I can't speak for the exact gfortran version we need from a scipy POV (@rgommers will know) but the gfortran needs:

  • be usable/installable on macos-11 (e.g. GH Actions image)
  • compatibility with 10.9 is great.
  • for native x86_64 compilation

scipy then needs an OpenBLAS build with the above (either v0.3.18 or v0.3.21).

(Sorry if the above is stating the obvious).

@isuruf
Copy link
Contributor

isuruf commented Nov 6, 2022

@charris
Copy link
Member Author

charris commented Nov 7, 2022

I note that gfortran-8.2-Mojave.dmg has the wrong file name inside, we want gfortran, it has gfortran-8.2-Mojave. The original 4.9 version we were using was modified so that the internal file was gfortran. With that change, I suspect we could solve some of our problems.

@andyfaff
Copy link
Member

andyfaff commented Nov 7, 2022

I note that gfortran-8.2-Mojave.dmg has the wrong file name inside

The file inside the DMG has a funny name, but is macOS installer PKG. Once the installer has run it places a gfortran executable in the right place with the right name.

This will not solve the openblas problems, but perhaps the f2py
failures will go away.
@charris charris force-pushed the update-to-macos-11-for-wheels branch from c3f2d63 to 8aa8bb6 Compare November 7, 2022 01:00
@charris
Copy link
Member Author

charris commented Nov 7, 2022

but is macOS installer PKG

It doesn't have the .pkg extension, does that matter?

@andyfaff
Copy link
Member

andyfaff commented Nov 7, 2022

Sorry, the installer is within that folder, /Volumes/gfortran-8.2-Mojave/gfortran-8.2-Mojave/gfortran.pkg

@andyfaff
Copy link
Member

andyfaff commented Nov 7, 2022

I'm going to look into the solution posted by @isuruf this morning for scipy.

@charris
Copy link
Member Author

charris commented Nov 7, 2022

I'm going to look into the solution posted by @isuruf this morning for scipy.

The wheels build now, but fail during delocate because of OpenBLAS. @mattip What needs to be done to use the new OpenBLAS builds? Are they against gfortran 8.2?

EDIT: In particular, do they use libgfortran.5.dylib

@andyfaff
Copy link
Member

andyfaff commented Nov 7, 2022

There are a few intertwined factors here. We need to update to a newer version of gfortran because gfortran-4.9 doesn't work on macos-11. Whilst the gfortran-8.2 link gets through the compile stage ultimately this solution is not for us because:

  1. gfortran-8.2 uses libgfortran.5.dylib and the currently available OpenBLAS on anaconda needs libgfortran.3.dylib. This is causing the delocate step to fail.
  2. That gfortran-8.2 is designed to deploy on 10.14 and above. So even if OpenBLAS is rebuilt using that gfortran-8.2 we couldn't target macos-10.13 and below.

The good solution is probably to:

  1. Install the gfortran-11.3 compiler suggested by @isuruf in https://github.com/MacPython/gfortran-install/pull/11/files. The compiler can deploy against 10.9.
  2. Rebuild the OpenBLAS binaries using this gfortran-11.3.

@isuruf
Copy link
Contributor

isuruf commented Nov 7, 2022

@charris, you can fix that by changing https://github.com/numpy/numpy/blob/main/tools/openblas_support.py#L80 to
suffix = 'macosx_10_11_x86_64-gf_dd3e148.tar.gz'

@charris
Copy link
Member Author

charris commented Nov 7, 2022

Mac is working. This is all testing what needs changing right now. All we need is to

  • pick a compiler
  • compile OpenBLAS with it. Must work with windows
  • fix this up to use the new stuff.

@@ -77,7 +77,7 @@ def download_openblas(target, plat, ilp64):
suffix = f'manylinux{ml_ver}_{arch}.tar.gz'
typ = 'tar.gz'
elif plat == 'macosx-x86_64':
suffix = 'macosx_10_9_x86_64-gf_1becaaa.tar.gz'
suffix = 'macosx_10_11_x86_64-gf_dd3e148.tar.gz'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this OpenBLAS change means that you have to set MACOSX_DEPLOYMENT_TARGET=10.11. One needs to be making numpy-1.24.0.dev0-cp39-cp39-macosx_10_11_x86_64.whl instead of numpy-1.24.0.dev0-cp39-cp39-macosx_10_9_x86_64.whl.
Using https://github.com/MacPython/gfortran-install/pull/11/files may still allow macosx_10_9_x86_64-gf_1becaaa.tar.gz to be used, but that would require experimentation.

@charris
Copy link
Member Author

charris commented Nov 17, 2022

Closing in favor of #22525.

@charris charris closed this Nov 17, 2022
@charris charris deleted the update-to-macos-11-for-wheels branch November 17, 2022 14:10
@@ -75,7 +75,7 @@ jobs:
# https://github.com/github/feedback/discussions/7835#discussioncomment-1769026
buildplat:
- [ubuntu-20.04, manylinux_x86_64]
- [macos-10.15, macosx_*]
- [macos-11, macosx_*]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be done in #22525. Should I add it there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, too late. I'll just make a PR for that.

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

Successfully merging this pull request may close these issues.

6 participants