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

Apply numpy 2 migrations for _ types in tests #61

Merged
merged 6 commits into from
Jun 21, 2024
Merged

Apply numpy 2 migrations for _ types in tests #61

merged 6 commits into from
Jun 21, 2024

Conversation

cbkerr
Copy link
Member

@cbkerr cbkerr commented Jun 20, 2024

Description

Makes tests pass for numpy 2.0. Tests still pass with 1.26 too.

Applies these changes to update float_ and complex_ types
https://numpy.org/doc/stable//numpy_2_0_migration_guide.html#changes-to-namespaces

Motivation and Context

Prepare for numpy 2.0

Checklist:

@cbkerr cbkerr requested review from a team as code owners June 20, 2024 16:57
@cbkerr cbkerr requested review from mikemhenry and removed request for a team June 20, 2024 16:57
@cbkerr
Copy link
Member Author

cbkerr commented Jun 20, 2024

Error message for failing test on macos, 3.8, oldest
Run pip install -r .github/workflows/ci-oldest-reqs.txt
Collecting coverage==5.3.1 (from -r .github/workflows/ci-oldest-reqs.txt (line 1))
  Downloading coverage-5.3.1.tar.gz (684 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 684.5/684.5 kB 20.9 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Collecting numpy==1.19.0 (from -r .github/workflows/ci-oldest-reqs.txt (line 2))
  Downloading numpy-1.19.0.zip (7.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.3/7.3 MB 80.8 MB/s eta 0:00:00
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [54 lines of output]
      
      Error compiling Cython file:
      ------------------------------------------------------------
      ...
                  self.rng_state.ctr.v[i] = counter[i]
      
              self._reset_state_variables()
      
              self._bitgen.state = <void *>&self.rng_state
              self._bitgen.next_uint64 = &philox_uint64
                                         ^
      ------------------------------------------------------------
      
      _philox.pyx:195:35: Cannot assign type 'uint64_t (*)(void *) except? -1 nogil' to 'uint64_t (*)(void *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to the type of the value being assigned.
      /private/var/folders/b3/2xm02wpd21qgrpkck5q1c6k40000gn/T/pip-install-n7iqo4lo/numpy_52542ff7e8a141d58676ab78eea8d7fe/tools/cythonize.py:73: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        required_version = LooseVersion('0.29.14')
      /private/var/folders/b3/2xm02wpd21qgrpkck5q1c6k40000gn/T/pip-install-n7iqo4lo/numpy_52542ff7e8a141d58676ab78eea8d7fe/tools/cythonize.py:75: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        if LooseVersion(cython_version) < required_version:
      Processing numpy/random/_bounded_integers.pxd.in
      Processing numpy/random/_philox.pyx
      Traceback (most recent call last):
        File "/private/var/folders/b3/2xm02wpd21qgrpkck5q1c6k40000gn/T/pip-install-n7iqo4lo/numpy_52542ff7e8a141d58676ab78eea8d7fe/tools/cythonize.py", line 235, in <module>
          main()
        File "/private/var/folders/b3/2xm02wpd21qgrpkck5q1c6k40000gn/T/pip-install-n7iqo4lo/numpy_52542ff7e8a141d58676ab78eea8d7fe/tools/cythonize.py", line 231, in main
          find_process_files(root_dir)
        File "/private/var/folders/b3/2xm02wpd21qgrpkck5q1c6k40000gn/T/pip-install-n7iqo4lo/numpy_52542ff7e8a141d58676ab78eea8d7fe/tools/cythonize.py", line 222, in find_process_files
          process(root_dir, fromfile, tofile, function, hash_db)
        File "/private/var/folders/b3/2xm02wpd21qgrpkck5q1c6k40000gn/T/pip-install-n7iqo4lo/numpy_52542ff7e8a141d58676ab78eea8d7fe/tools/cythonize.py", line 188, in process
          processor_function(fromfile, tofile)
        File "/private/var/folders/b3/2xm02wpd21qgrpkck5q1c6k40000gn/T/pip-install-n7iqo4lo/numpy_52542ff7e8a141d58676ab78eea8d7fe/tools/cythonize.py", line 77, in process_pyx
          subprocess.check_call(
        File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/subprocess.py", line 364, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['/Library/Frameworks/Python.framework/Versions/3.8/bin/python', '-m', 'cython', '-3', '--fast-fail', '-o', '_philox.c', '_philox.pyx']' returned non-zero exit status 1.
      Running from numpy source directory.
      <string>:460: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
      Cythonizing sources
      Traceback (most recent call last):
        File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/private/var/folders/b3/2xm02wpd21qgrpkck5q1c6k40000gn/T/pip-build-env-vyemly7i/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 368, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "/private/var/folders/b3/2xm02wpd21qgrpkck5q1c6k40000gn/T/pip-build-env-vyemly7i/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 497, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/private/var/folders/b3/2xm02wpd21qgrpkck5q1c6k40000gn/T/pip-build-env-vyemly7i/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 489, in <module>
        File "<string>", line 469, in setup_package
        File "<string>", line 274, in generate_cython
      RuntimeError: Running cythonize failed!
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Notice:  A new release of pip is available: 21.1.1 -> 24.0
Notice:  To update, run: python -m pip install --upgrade pip
Error: Process completed with exit code 1.

@cbkerr cbkerr requested a review from joaander June 20, 2024 17:07
tests/synced_collection_test.py Outdated Show resolved Hide resolved
tests/synced_collection_test.py Outdated Show resolved Hide resolved
@bdice
Copy link
Member

bdice commented Jun 20, 2024

@cbkerr For the “oldest” tests, feel free to update the NumPy pinning to the oldest version for which wheels exist for all supported platforms / Python versions. We don’t want to have to compile NumPy from a source dist to run tests.

Also it is okay to drop Python 3.8, if 3.8 presents any challenges here. It has been dropped by NEP 29 / SPEC 0 and will only get security updates through October 2024.

@cbkerr
Copy link
Member Author

cbkerr commented Jun 21, 2024

I update the oldest numpy to 1.21.0, which is the first one that has an arm build that supports macos 11+.

@cbkerr cbkerr requested a review from bdice June 21, 2024 16:31
@cbkerr cbkerr merged commit 6d6c83d into main Jun 21, 2024
16 checks passed
@cbkerr cbkerr deleted the fix/numpy-2 branch June 21, 2024 19:08
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 this pull request may close these issues.

2 participants