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

NumPy does not install on Python 3.12.0b1 #23808

Closed
bersbersbers opened this issue May 25, 2023 · 44 comments
Closed

NumPy does not install on Python 3.12.0b1 #23808

bersbersbers opened this issue May 25, 2023 · 44 comments
Labels
32 - Installation Problems installing or compiling NumPy component: build

Comments

@bersbersbers
Copy link

bersbersbers commented May 25, 2023

Describe the issue:

Related:
pypa/pip#11501 (comment)
pypa/setuptools#3935

https://github.com/numpy/numpy/blob/cc0abd768575d7f9e862de0b4912af27f6e9690d/pyproject.toml#LL7C6-L7C16

Reproduce the code example:

pip install numpy

Error message:

pip install numpy
Collecting numpy
  Using cached numpy-1.24.3.tar.gz (10.9 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      Traceback (most recent call last):
        File "C:\Users\bers\.pyenv-win-venv\envs\project_3.12\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\bers\.pyenv-win-venv\envs\project_3.12\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\bers\.pyenv-win-venv\envs\project_3.12\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 112, in get_requires_for_build_wheel
          backend = _build_backend()
                    ^^^^^^^^^^^^^^^^
        File "C:\Users\bers\.pyenv-win-venv\envs\project_3.12\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 77, in _build_backend
          obj = import_module(mod_path)
                ^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\bers\.pyenv\pyenv-win\versions\3.12.0b1\Lib\importlib\__init__.py", line 90, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<frozen importlib._bootstrap>", line 1293, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1266, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1216, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 400, in _call_with_frames_removed
        File "<frozen importlib._bootstrap>", line 1293, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1266, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1237, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 841, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 994, in exec_module
        File "<frozen importlib._bootstrap>", line 400, in _call_with_frames_removed
        File "C:\Users\bers\AppData\Local\Temp\pip-build-env-8dt1uf4c\overlay\Lib\site-packages\setuptools\__init__.py", line 16, in <module>
          import setuptools.version
        File "C:\Users\bers\AppData\Local\Temp\pip-build-env-8dt1uf4c\overlay\Lib\site-packages\setuptools\version.py", line 1, in <module>
          import pkg_resources
        File "C:\Users\bers\AppData\Local\Temp\pip-build-env-8dt1uf4c\overlay\Lib\site-packages\pkg_resources\__init__.py", line 2172, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

Runtime information:

Cannot install numpy :)
Python 3.12.0b1 on Windows 10 21H2

Context for the issue:

No response

@mattip
Copy link
Member

mattip commented May 28, 2023

We deliberately pin setuptools to work around other problems with numpy.distutils. The plan for python 3.12 is to move to the meson build system, and to deprecate use of setuptools. You can try out the meson build using python3.12 -m pip install -r build_requirements.txt; python3.12 -m spin build.

@bersbersbers
Copy link
Author

Thanks, understood!

I just came across https://numpy.org/devdocs/reference/distutils_status_migration.html, which reads

It may be beneficial to wait with migrating until there are examples from other projects to follow

I agree in principle, but I feel that this approach may deadlock if many other projects depend on numpy :) for example, matplotlib does not install on 3.12.0b1 because it depends on numpy at build time, and then that dependency is carried further to all projects depending on matplotlib.

@mattip
Copy link
Member

mattip commented May 28, 2023

That advice could use an update, especially before the 1.25 release freezes the documentation. SciPy has migrated to meson-python, and NumPy should migrate soon. Rather than trying to get setuptools to work with python3.12, we should start testing the CPython 3.12b1 with meson.

@charris
Copy link
Member

charris commented May 28, 2023

That advice could use an update, especially before the 1.25 release freezes the documentation.

Could you open an issue for that? I am going to release 1.25.0rc1 without it, but there will still be time before the final.

@mattip
Copy link
Member

mattip commented May 28, 2023

matplotlib does not install on 3.12.0b1 because it depends on numpy at build time,

Maybe we should be uploading pre-release wheels to https://anaconda.org/scientific-python-nightly-wheels/numpy. It seems cibuildwheel has a option for this

@rgommers
Copy link
Member

I think now that 1.25.x has branched, we can make the switch to Meson by default in main. That will make pip install . & co work with Python 3.12 beta's (module any crashes due to incompatibilities between CPython, NumPy and Cython of course - and we know we have one of those right now: gh-23766). WDYT?

Re uploading a nightly: let's consider it once NumPy actually passes its test suite with a CPython beta? It seems too early now, we don't even run it in our own CI yet.

@mattip
Copy link
Member

mattip commented May 29, 2023

We need SIMD testing to work to make the transition.

@rgommers
Copy link
Member

We need SIMD testing to work to make the transition.

That can still be done with python setup.py install, as is already done in armv7_simd_test.

@rgommers
Copy link
Member

rgommers commented Jun 8, 2023

I think now that 1.25.x has branched, we can make the switch to Meson by default in main. That will make pip install . & co work with Python 3.12 beta's (module any crashes due to incompatibilities between CPython, NumPy and Cython of course

This is being done in gh-23838 - which is close, but needs working through some CI failures. Until it is merged, one can either use the branch from which I made that PR, or follow the instructions at https://github.com/numpy/numpy/blob/main/building_with_meson.md#pip-install.

Questions about this continue to come in, so I'll pin this issue.

@rgommers rgommers pinned this issue Jun 8, 2023
@rgommers rgommers added component: build 32 - Installation Problems installing or compiling NumPy and removed 00 - Bug labels Jun 8, 2023
@rgommers rgommers changed the title BUG: numpy does not install on Python 3.12.0b1 NumPy does not install on Python 3.12.0b1 Jun 8, 2023
@EwoutH
Copy link
Contributor

EwoutH commented Jun 19, 2023

Congratulations on getting #23838 in!

What are the next steps in Python 3.12 support?

@rgommers
Copy link
Member

What are the next steps in Python 3.12 support?

Uploading nightlies to https://anaconda.org/scientific-python-nightly-wheels, so other projects can use those. PR for that is up, I'll update here once they're available.

@rgommers
Copy link
Member

Wheels for Python 312 x86-64 (macOS, Windows, manylinux and musllinux) are up on https://anaconda.org/scientific-python-nightly-wheels/numpy/files. The rest (arm64/aarch64) should land as well by tomorrow when the next scheduled wheel build on Cirrus CI runs.

@lithomas1
Copy link
Collaborator

lithomas1 commented Jun 20, 2023

Is there any recommendation for how downstream(e.g. pandas) should build Python 3.12 wheels?

We can't build with the tarball of numpy 1.25 since that uses an ancient setuptools not compatible with Python 3.12, and I don't like the sound of building wheels using a random numpy nightly.

If numpy 2.0 (or whatever the next version is) comes a couple months before Python 3.12 final, I guess it's no big deal, but if not, maybe it might be good to backport #23838?

truhanen added a commit to gird-dev/gird that referenced this issue Oct 30, 2023
- Limited NumPy version to at least 1.26.0 to fix an error with Python 3.12,
  numpy/numpy#23808.
- Updated poetry.lock.
truhanen added a commit to gird-dev/gird that referenced this issue Oct 30, 2023
- Run tests on CI on Python 3.12.
- Limited NumPy version to at least 1.26.0 to fix an error with Python 3.12,
  numpy/numpy#23808.
- Updated poetry.lock.
jaraco added a commit to jaraco/zipp that referenced this issue Dec 16, 2023
jaraco added a commit to jaraco/zipp that referenced this issue Dec 16, 2023
ghislainv added a commit to ghislainv/forestatrisk that referenced this issue Dec 18, 2023
amorenoz added a commit to amorenoz/bbva2pandas that referenced this issue Jan 2, 2024
Numpy 1.24 build is broken on Python 3.12 [1]. 1.26.2 seems to be the
first version that fixes it.

[1] numpy/numpy#23808

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
clrpackages pushed a commit to clearlinux-pkgs/pypi-zipp that referenced this issue Mar 19, 2024
…n 3.18.1

Bartosz Sławecki (1):
      Tweak coverage configuration for type checking (jaraco/skeleton#97)

Christian Clauss (2):
      Upgrade GitHub Actions checkout (jaraco/skeleton#94)
      GitHub Actions: Combine tox jobs diffcov and docs (jaraco/skeleton#95)

Dimitri Papadopoulos Orfanos (2):
      Use the ruff formatter (jaraco/skeleton#99)
      ruff: extended-ignore → ignore (jaraco/skeleton#105)

Jason R. Coombs (36):
      Limit sphinxlint jobs to 1. Workaround for sphinx-contrib/sphinx-lint#83.
      Remove news fragment after allowing time to be processed downstream.
      Suppress deprecation warning in dateutil. Workaround for dateutil/dateutil#1284.
      Update Github Actions badge per actions/starter-workflows#1525.
      Separate collateral jobs on different lines for easier override/extension.
      Revert "Disable tests on Windows due to numpy doesn't install. Ref numpy/numpy#23808"
      Revert "Grab later build of numpy; workaround for numpy/numpy#23808."
      Add support for newlines and fullmatch in glob.translate to match behavior in fnmatch.translate.
      Add support for arbitrary separators in glob.Translator, defaulting to os.sep + os.altsep.
      Prevent ** from appearing as anything but a full path segment for alignment with glob.
      Prevent * from matching an empty segment
      Fix initializer so it actually honors the parameter.
      Add tests for invalid separators.
      Update changelog.
      Drop minimum requirement on pytest-mypy as most environments are already running much later. Closes jaraco/skeleton#96.
      Remove sole entry for branches-ignore. Workaround for and closes jaraco/skeleton#103.
      Bump year on badge
      Remove build and dist from excludes. It appears they are not needed and their presence blocks the names of packages like 'builder' and 'distutils'. Ref pypa/distutils#224.
      Exclude docs and tests directories properly per Setuptools behavior.
      Rely on default discovery for good heuristics for finding packages.
      Enable preview to enable preserving quotes.
      Use latest versions in RTD boilerplate.
      Remove Sphinx pin. Ref sphinx-doc/sphinx#11662.
      Include deps from the base config in diffcov.
      Enable complexity check and pycodestyle warnings. Closes jaraco/skeleton#110.
      Use 'extend-select' to avoid disabling the default config. Ref jaraco/skeleton#110.
      Moved compatibility module to compat package.
      Fix name generator for width=1
      Add another test at another magnitude.
      Add special accounting for pypy when computing the stack level for text encoding warnings.
      Bypass ZipFile.namelist in glob. Closes #106.
      Add news fragment.
      Finalize
      Move changelog entry, saved to the wrong location :(
      Merge changelog into last release.
      Finalize

Sviatoslav Sydorenko (1):
      Enable testing merge queues @ GitHub Actions CI/CD (jaraco/skeleton#93)
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
32 - Installation Problems installing or compiling NumPy component: build
Projects
None yet
Development

No branches or pull requests

17 participants