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

Update SciPy version #949

Merged
merged 9 commits into from Sep 10, 2023
Merged

Update SciPy version #949

merged 9 commits into from Sep 10, 2023

Conversation

pasdeloup
Copy link
Contributor

@pasdeloup pasdeloup commented Aug 31, 2023

A small step forward for #648 , I could update the existing patch and reach SciPy 1.6.3
Tested with Python 3.9 and arm64-v8a ABI

@pasdeloup pasdeloup changed the title Update SciPy to 1.5.4 Update SciPy version Aug 31, 2023
@pasdeloup
Copy link
Contributor Author

Trying to go further, 1.6.3 version seems reachable!

@pasdeloup
Copy link
Contributor Author

For versions 1.7.x and 1.8.x I still have issues with numpy

@mhsmith
Copy link
Member

mhsmith commented Aug 31, 2023

I put quotation marks around all the version numbers to prevent things like 0.10 being parsed as 0.1, so I've merged that into this PR. This also picks up all the changes mentioned in #648 (comment), so please let me know if that causes any trouble.

@pasdeloup
Copy link
Contributor Author

Still working for me, I just had to reinstall requirements to get pypi_simple (and maybe others).

@pasdeloup
Copy link
Contributor Author

Sorry, tests are not passing with 1.6.3 because of requirements:
Requires-Dist: numpy (<1.23.0,>=1.16.5)
but we build with numpy 1.23.3

@pasdeloup
Copy link
Contributor Author

Ok now tests OK

@pasdeloup
Copy link
Contributor Author

Or maybe better to downgrade numpy to a <1.23.0,>=1.16.5 version, but which one ? We also need to provide it

@mhsmith
Copy link
Member

mhsmith commented Sep 4, 2023

Or maybe better to downgrade numpy to a <1.23.0,>=1.16.5 version

Yes, it's probably best to respect the limits declared by the package, even if they added them for questionable reasons.

Or maybe better to downgrade numpy to a <1.23.0,>=1.16.5 version, but which one ? We also need to provide it

1.19.5 is the obvious choice:

  • We already have it for Python 3.8, and it'll probably be the last version we release for 3.8 because of #570.
  • It didn't require any patch changes when we last updated the version, so building it for Python 3.9 shouldn't be a problem.
  • It's not compatible with Python 3.10 or later, but neither is SciPy 1.6.3.

@pasdeloup
Copy link
Contributor Author

Seemed obvious at first but can't make it build with 1.19.5, not sure why... :(

And as this version is not built yet for Python 3.9 (and still need some patch-fixing because of 52cef01 ) we are free to use another.

I propose 1.20.3 for Python 3.9
Seems a good choice according to https://docs.scipy.org/doc/scipy/dev/toolchain.html

And tests are passing

@pasdeloup
Copy link
Contributor Author

By the way, to build numpy 1.20.3, just need to remove last update from the patch.
Could be great to allow keeping multiple patches, one per version.

@mhsmith
Copy link
Member

mhsmith commented Sep 5, 2023

Was this the error you received when building NumPy 1.19.5 for Python 3.9? I got this on x86 and armeabi-v7a, but not on x86_64 and arm64-v8a, which built successfully. So it's probably a 32 vs 64-bit issue.

And unfortunately it looks like 1.20.3 has the same problem.

building extension "numpy.core._multiarray_umath" sources
Traceback (most recent call last):
  File "/home/smith/.venv/pypi/lib/python3.8/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
    main()
  File "/home/smith/.venv/pypi/lib/python3.8/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/home/smith/.venv/pypi/lib/python3.8/site-packages/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
    return _build_backend().build_wheel(wheel_directory, config_settings,
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/env/lib/python3.9/site-packages/setuptools/build_meta.py", line 211, in build_wheel
    return self._build_with_temp_dir(['bdist_wheel'], '.whl',
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/env/lib/python3.9/site-packages/setuptools/build_meta.py", line 197, in _build_with_temp_dir
    self.run_setup()
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/env/lib/python3.9/site-packages/setuptools/build_meta.py", line 248, in run_setup
    super(_BuildMetaLegacyBackend,
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/env/lib/python3.9/site-packages/setuptools/build_meta.py", line 142, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 512, in <module>
    setup_package()
  File "setup.py", line 504, in setup_package
    setup(**metadata)
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/src/numpy/distutils/core.py", line 169, in setup
    return old_setup(**new_attr)
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/env/lib/python3.9/site-packages/setuptools/__init__.py", line 165, in setup
    return distutils.core.setup(**attrs)
  File "/home/smith/.pyenv/versions/3.9.12/lib/python3.9/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/smith/.pyenv/versions/3.9.12/lib/python3.9/distutils/dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "/home/smith/.pyenv/versions/3.9.12/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/env/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 290, in run
    self.run_command('build')
  File "/home/smith/.pyenv/versions/3.9.12/lib/python3.9/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/home/smith/.pyenv/versions/3.9.12/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/src/numpy/distutils/command/build.py", line 40, in run
    old_build.run(self)
  File "/home/smith/.pyenv/versions/3.9.12/lib/python3.9/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/home/smith/.pyenv/versions/3.9.12/lib/python3.9/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/home/smith/.pyenv/versions/3.9.12/lib/python3.9/distutils/dist.py", line 985, in run_command
    cmd_obj.run()
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/src/numpy/distutils/command/build_src.py", line 144, in run
    self.build_sources()
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/src/numpy/distutils/command/build_src.py", line 161, in build_sources
    self.build_extension_sources(ext)
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/src/numpy/distutils/command/build_src.py", line 318, in build_extension_sources
    sources = self.generate_sources(sources, ext)
  File "/home/smith/git/chaquo/chaquopy/server/pypi/packages/numpy/build/1.19.5/cp39-cp39-android_21_x86/src/numpy/distutils/command/build_src.py", line 378, in generate_sources
    source = func(extension, build_dir)
  File "numpy/core/setup.py", line 436, in generate_config_h
    moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
  File "numpy/core/setup.py", line 47, in check_types  
    out = check_types(*a, **kw)
  File "numpy/core/setup.py", line 292, in check_types 
    raise SystemError(
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.

@pasdeloup
Copy link
Contributor Author

Nope, numpy 1.19.5 is building, but Scipy is not when using this version as a dependency
I will check 32 bits ABIs

@pasdeloup
Copy link
Contributor Author

pasdeloup commented Sep 6, 2023

Numpy 1.23.3 doesn't build anymore either on armeabi-v7a
The issue is due to 52cef01
We can build both 1.23.3 and 1.20.3 when reverting it

@pasdeloup
Copy link
Contributor Author

Ok found, my mistake : we should not remove last patch, but alter it temporarily to build 1.20.3, the error is due to setuptools version

--- src-original/pyproject.toml	2022-09-09 13:36:30.619459000 +0000
+++ src/pyproject.toml	2023-08-31 11:38:08.304445745 +0000
@@ -1,7 +1,8 @@
 [build-system]
 # Minimum requirements for the build system to execute.
 requires = [
-    "setuptools<49.2.0",
+    # Chaquopy: was 59.2.0, which failed to detect modf and frexp for some reason.
+    "setuptools==63.0.0",
     "wheel<=0.35.1",
     "Cython>=0.29.21,<3.0",  # Note: keep in sync with tools/cythonize.py
 ]

So Numpy 1.23.3 is still building on armeabi-v7a with the existing patch.

@mhsmith
Copy link
Member

mhsmith commented Sep 9, 2023

Thanks, I'll try that now.

Could be great to allow keeping multiple patches, one per version.

Yes, but I'd prefer not to invest time into replicating yet another conda-build feature, because our long-term plan is to migrate to using conda-build directly.

@mhsmith mhsmith mentioned this pull request Sep 9, 2023
@mhsmith
Copy link
Member

mhsmith commented Sep 9, 2023

I've built and released NumPy 1.20.3 for Python 3.9, and saved the recipe in #957. But now SciPy 1.6.3 is also failing on the 32-bit ABIs, with the error:

creating build/temp.linux_i686-3.9/scipy/special
creating build/temp.linux_i686-3.9/scipy/special/cephes
compile options: '-I/home/smith/git/chaquo/chaquopy/server/pypi/packages/scipy/build/1.6.3/cp39-cp39-android_21_x86/src/scipy/special -I/home/smith/git/chaquo/chaquopy/server/pypi/packages/scipy/build/1.6.3/cp39-cp39-android_21_x
86/requirements/numpy/core/include -I/home/smith/.pyenv/versions/3.9.12/include/python3.9 -Iscipy/_lib -Iscipy/_build_utils/src -I/home/smith/git/chaquo/chaquopy/server/pypi/packages/scipy/build/1.6.3/cp39-cp39-android_21_x86/req
uirements/numpy/core/include -Ibuild/src.linux_i686-3.9/numpy/distutils/include -c'
extra options: '-msse -msse2'
i686-linux-android21-clang: scipy/special/cephes/airy.c
i686-linux-android21-clang: scipy/special/cephes/dawsn.c
In file included from scipy/special/cephes/airy.c:52:  
In file included from scipy/special/cephes/mconf.h:56: 
In file included from /home/smith/.pyenv/versions/3.9.12/include/python3.9/Python.h:50:
/home/smith/.pyenv/versions/3.9.12/include/python3.9/pyport.h:741:2: error: "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
...
error: Command "/home/smith/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android21-clang -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -I/home/smith/git/chaquo/chaquopy/server/pypi/packages/scipy/build/1.6.3/cp39-cp39-android_21_x86/requirements/chaquopy/include -idirafter /home/smith/git/chaquo/chaquopy/server/pypi/packages/scipy/build/1.6.3/cp39-cp39-android_21_x86/requirements/chaquopy/include/python3.9 -fPIC -I/home/smith/git/chaquo/chaquopy/server/pypi/packages/scipy/build/1.6.3/cp39-cp39-android_21_x86/src/scipy/special -I/home/smith/git/chaquo/chaquopy/server/pypi/packages/scipy/build/1.6.3/cp39-cp39-android_21_x86/requirements/numpy/core/include -I/home/smith/.pyenv/versions/3.9.12/include/python3.9 -Iscipy/_lib -Iscipy/_build_utils/src -I/home/smith/git/chaquo/chaquopy/server/pypi/packages/scipy/build/1.6.3/cp39-cp39-android_21_x86/requirements/numpy/core/include -Ibuild/src.linux_i686-3.9/numpy/distutils/include -c scipy/special/cephes/airy.c -o build/temp.linux_i686-3.9/scipy/special/cephes/airy.o -MMD -MF build/temp.linux_i686-3.9/scipy/special/cephes/airy.o.d -msse -msse2" failed with exit status 1

I think I know how to fix this, so I'll look into it tomorrow.

@mhsmith
Copy link
Member

mhsmith commented Sep 10, 2023

I think both of the 32-bit failures were caused by the fact that the monkey patches in sitecustomize.py, which were supposed to filter out include and library paths from outside of the build directory, didn't work on the older versions of setuptools which were requested by the pyproject.toml files of these NumPy and SciPy versions.

#935, which involved a newer version of setuptools, was probably caused by the same thing.

So I've moved these directory filters into a compiler wrapper script instead. This means it'll take effect on all build systems, both Python and non-Python.

However, for Python packages, it would still be a good idea to look into using crossenv, so the invalid paths don't get put on the command line in the first place. This should also allow one of the remaining monkey patches in sitecustomize.py to be removed.

@mhsmith
Copy link
Member

mhsmith commented Sep 10, 2023

I've removed a couple of things from the patch which weren't needed anymore, and reordered the files so they're still in alphabetical order.

SciPy 1.6.3 is now in the public repository for Python 3.9. Thanks again!

@mhsmith mhsmith merged commit d1f3567 into chaquo:master Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants