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

macos-11.0: scipy build fails #31326

Closed
mkoeppe opened this issue Feb 2, 2021 · 39 comments
Closed

macos-11.0: scipy build fails #31326

mkoeppe opened this issue Feb 2, 2021 · 39 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Feb 2, 2021

(from #31227)

Affected configurations (From ​https://groups.google.com/g/sage-release/c/KdSKg6RdZok/m/GXfB1rW1AgAJ)

      File "/Users/buildbot-sage/slave/sage_git/build/local/lib/python3.9/site-packages/numpy/distutils/ccompiler.py", line 90, in <lambda>
        m = lambda self, *args, **kw: func(self, *args, **kw)
      File "/Users/buildbot-sage/slave/sage_git/build/local/lib/python3.9/site-packages/numpy/distutils/ccompiler.py", line 657, in CCompiler_get_version
        version = matcher(output)
      File "/Users/buildbot-sage/slave/sage_git/build/local/lib/python3.9/site-packages/numpy/distutils/fcompiler/gnu.py", line 278, in version_match
        v = self.gnu_version_match(version_string)
      File "/Users/buildbot-sage/slave/sage_git/build/local/lib/python3.9/site-packages/numpy/distutils/fcompiler/gnu.py", line 80, in gnu_version_match
        raise ValueError(err + version_string)
    ValueError: A valid Fortran version was not found in this string:

see also https://github.com/mkoeppe/sage/runs/2103782381

CC: @jhpalmieri @zlscherr @dimpase @kliem @isuruf

Component: porting

Author: Zachary Scherr

Branch/Commit: 4cc8c4d

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/31326

@mkoeppe mkoeppe added this to the sage-9.3 milestone Feb 2, 2021
@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 15, 2021

comment:3

It seems like numpy.distutils gets confused by extra whitespace in the result of gfortran -dumpversion. This might be related to the use of zsh as the shell.

This will need investigation by someone who has already made the switch to Big Sur...

@zlscherr
Copy link

comment:4

just want to point out that this problem exists on bash as well. For anyone wanting to test you can, after configuring, do:

make toolchain
make gfortran
FC="local/bin/gfortran" make numpy

to see the error.

@zlscherr
Copy link

comment:5

I haven't tested the full homebrew-macos-11.0-xcode-minimal build, but I'm guessing it's related to MACOSX_DEPLOYMENT_TARGET.

As I noted above, I can recreate the error with numpy by using sage's gfortran 9.2.0 on my machine with homebrew. As per usual I think this is because python was built with MACOSX_DEPLOYMENT_TARGET 11.0 and gfortran 9.2.0 can't recognize this value.

Now I know that at some point scipy's spkg-install.in file was changed to contain the lines:

if [ $MACOSX_VERSION -ge 20 ]; then
     export MACOSX_DEPLOYMENT_TARGET=11.0
fi

I'm not exactly sure what is in homebrew-macos-11.0-xcode-minimal, but if sage is building its own gfortran and its own python using a different MACOSX_DEPLOYMENT_TARGET then I would guess that this line might be causing the problems.

It's been a while since I've thought about this problem, but it's possible that the above export might not be needed anymore since homebrew patched GCC.

@zlscherr
Copy link

comment:6

Actually it probably shouldn't matter whether or not sage is building its own python. gfortran 9.2.0 just can't recognize MACOSX_DEPLOYMENT_TARGET=11.0.

@zlscherr
Copy link

comment:7

Sorry for the spam, but the ticket that introduced that if statement is #31183

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 15, 2021

comment:8

Could you check if the gcc upgrade in #29827 fixes this issue?

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 15, 2021

comment:9

Replying to @zlscherr:

I'm not exactly sure what is in homebrew-macos-11.0-xcode-minimal, but if sage is building its own gfortran

Yes, that's right. This configuration uses a minimal installation of homebrew, plus the packages listed in build/pkgs/_bootstrap/distros/homebrew.txt, namely gettext autoconf automake libtool pkg-config

@zlscherr
Copy link

comment:10

I also just saw that the error reported on top is in numpy and not in scipy. I'll take a look at #29827 when I get a chance, but I know that homebrew had to specifically patch GCC to avoid this sort of problem. A viable solution might be to track the legacy option to see if sage is building its own Fortran, and if so we set MACOSX_DEPLOYMENT_TARGET to 10.something

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 15, 2021

comment:11

No, it's an error building scipy -- which uses numpy.distutils, which you see in the lines of the log

@zlscherr
Copy link

comment:12

Ah okay. Also, do you know if the homebrew minimal test uses system for python? That might be responsible for why the deployment Target is set to 11, whereas when sage builds it's own python the deployment Target is set lower.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 15, 2021

comment:13

From https://groups.google.com/g/sage-release/c/KdSKg6RdZok/m/GXfB1rW1AgAJ: Runs in which scipy fails to build:

@jhpalmieri
Copy link
Member

comment:14

For what it's worth, if I do

% make distclean && ./configure --with-system-gfortran=no && make

then the build fails on numpy, not scipy, but with the same sort of error:

ValueError: A valid Fortran version was not found in this string:

9.2.0

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 15, 2021

comment:15

I think there are extra newlines in this version string, which confuses the numpy.distutils code

@zlscherr
Copy link

comment:16

It's actually worse than just extra newlines. I tried manually patching to strip all whitespace from both ends, but that didn't solve the problem. I dumped the contents of the version_string which is causing numpy to fail into a text file and it turned out to be

"gfortran: warning: couldn't understand version 11

9.3.0"

(I tested with gcc 9.3, but the same happens with 9.2)

I can get numpy and scipy to build by manually forcing MACOSX_DEPLOYMENT_TARGET to be 10.16 but it seems that 11 and 11.0 both cause problems.

Here is a proposal for how to deal with this:

  1. Remove the if statements from scipy's spkg-install to set MACOSX_DEPLOYMENT_TARGET to 11.0. I don't think this is needed anymore since Homebrew patched GCC 10 but I can do some testing on that.

  2. At some point in the build process we take a look at MACOSX_DEPLOYMENT_TARGET, which can be easily done with something like

python3 -c "import sysconfig; print(sysconfig.get_config_var('MACOSX_DEPLOYMENT_TARGET'))"

if we get back a value of 11 and yet the version of gfortran we are using is less than 10.2.0 then we change MACOSX_DEPLOYMENT_TARGET to 10.16 or something like that.

@zlscherr
Copy link

comment:17

But probably the second step is not necessary, it would only be needed if the user has python3 from Homebrew and yet gfortran from sage. I think just fixing up scipy's spkg-install should fix everything.

@zlscherr
Copy link

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 16, 2021

Commit: 4cc8c4d

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 16, 2021

Branch pushed to git repo; I updated commit sha1. New commits:

4cc8c4dReverted changes in scipy's spkg-install to unset MACOSX_DEPLOYMENT_TARGET to 11 on Big Sur

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 16, 2021

comment:21

Thanks for investigating!

To test this in various configurations, it would be enough to merge the branch of #31492 and then push a tag to your github fork of sage.

@zlscherr
Copy link

comment:22

I think I did that correctly. I'll report on what happens in the CI on my repo.

@zlscherr
Copy link

comment:23

I'm not sure if there is something I need to do to get the CI working, but some of the homebrew's are already failing because of an error like:

curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to homebrew.bintray.com:443

Is there something I need to do to avoid this?

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 16, 2021

comment:24

There are various ways how these CI runs can intermittently fail. It's nothing that we can fix on our side as far as I can tell.

By the way, if you want, you can remove the unnecessary runs (for linux, cygwin) by editing files in .github/workflows/. Also max-parallel can be edited so that more macOS jobs are run in parallel.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 16, 2021

comment:25

Replying to @mkoeppe:

@isuruf: Also this build using conda-forge is affected

@mkoeppe

This comment has been minimized.

@mkoeppe mkoeppe changed the title homebrew-macos-11.0-xcode-minimal: scipy build fails macos-11.0: scipy build fails Mar 16, 2021
@dimpase
Copy link
Member

dimpase commented Mar 20, 2021

comment:27

yes, my student also reports getting

[scipy-1.5.4]     clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11.0'

@zlscherr
Copy link

comment:28

I tried running on github CI, but it quit after a few days and only got through 10.15. I just took out 10.15 and am trying again...

@zlscherr
Copy link

comment:29

I tried to run the CI tests on 11.0 but I got the following error message:

"No runner matching the specified labels was found: macos-11.0"

Is there a different way I should get the tests to run on Big Sur?

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 21, 2021

comment:30

actions/runner-images#2486
"macOS 11.0 pools will be transited to private preview"

@zlscherr
Copy link

comment:31

gotcha. I've tried some local testing and the reversion seems to be fine, but I'll leave it to others to do more extensive testing.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 21, 2021

comment:32

Some of my recent runs in https://github.com/mkoeppe/sage/actions/workflows/tox.yml have used branches that merged this ticket and may contain some useful results for 11.0

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 21, 2021

Reviewer: Matthias Koeppe

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 21, 2021

comment:33

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 21, 2021

Author: Zachary Scherr

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 21, 2021

comment:34

Also

@jhpalmieri
Copy link
Member

comment:35

I agree it works with various Pythons on OS X 11. comment:14 has not been addressed, but I guess that's not for this ticket.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Mar 22, 2021

comment:36

Replying to @jhpalmieri:

comment:14 has not been addressed, but I guess that's not for this ticket.

Yes, to fix that we need to upgrade our gcc/gfortran - that's #29703.

@vbraun
Copy link
Member

vbraun commented Mar 23, 2021

Changed branch from u/gh-zlscherr/revert_scipy_MACOSX_DEPLOYMENT_TARGET to 4cc8c4d

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

No branches or pull requests

5 participants