Skip to content

pip install fails after NumPy 1.24 #273

@michaelcdevin

Description

@michaelcdevin

Our WEC optimization tool includes Capytaine as a dependency. When running the package's CI testing suite, Capytaine has begun to encounter an exception when compiling the Fortran binaries when installing from pip:

Run python3 -m pip install --upgrade pip
Requirement already satisfied: pip in /opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages (22.3.1)
Processing /home/runner/work/WecOptTool/WecOptTool
  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'
  Installing backend dependencies: started
  Installing backend dependencies: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Collecting meshio
  Downloading meshio-5.3.4-py3-none-any.whl (167 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 167.7/167.7 kB 3.1 MB/s eta 0:00:00
Collecting scipy
  Downloading scipy-1.9.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (33.7 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 33.7/33.7 MB 53.7 MB/s eta 0:00:00
Collecting capytaine>=1.4
  Downloading capytaine-1.5.post1.tar.gz (129 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 129.0/129.0 kB 33.4 MB/s eta 0:00:00
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [86 lines of output]
      /opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
        warnings.warn(
      WARNING: The wheel package is not available.
      /tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/setup.py:9: DeprecationWarning:
      
        `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
        of the deprecation of `distutils` itself. It will be removed for
        Python >= 3.12. For older Python versions it will remain present.
        It is recommended to use `setuptools < 60.0` for those Python versions.
        For more details, see:
          https://numpy.org/devdocs/reference/distutils_status_migration.html
      
      
        from numpy.distutils.core import Extension, setup
      running egg_info
      running build_src
      INFO: build_src
      INFO: building extension "capytaine.green_functions.libs.Delhommeau_float32" sources
      INFO: f2py options: []
      INFO: f2py:> build/src.linux-x86_64-3.10/capytaine/green_functions/libs/Delhommeau_float32module.c
      creating build
      creating build/src.linux-x86_64-3.10
      creating build/src.linux-x86_64-3.10/capytaine
      creating build/src.linux-x86_64-3.10/capytaine/green_functions
      creating build/src.linux-x86_64-3.10/capytaine/green_functions/libs
      Traceback (most recent call last):
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/f2py/crackfortran.py", line 393, in readfortrancode
          l = fin.readline()
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/fileinput.py", line 312, in readline
          line = self._readline()
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/fileinput.py", line 392, in _readline
          return self._readline()
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/encodings/ascii.py", line 26, in decode
          return codecs.ascii_decode(input, self.errors)[0]
      UnicodeDecodeError: 'ascii' codec can't decode byte 0xcf in position 326: ordinal not in range(128)
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/setup.py", line 64, in <module>
          setup(name=about["__title__"],
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/distutils/core.py", line 169, in setup
          return old_setup(**new_attr)
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 968, in run_commands
          self.run_command(cmd)
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/distutils/command/egg_info.py", line 24, in run
          self.run_command("build_src")
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 987, in run_command
          cmd_obj.run()
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/distutils/command/build_src.py", line 144, in run
          self.build_sources()
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/distutils/command/build_src.py", line 161, in build_sources
          self.build_extension_sources(ext)
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/distutils/command/build_src.py", line 321, in build_extension_sources
          sources = self.f2py_sources(sources, ext)
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/distutils/command/build_src.py", line 562, in f2py_sources
          numpy.f2py.run_main(f2py_options + ['--lower',
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/f2py/f2py2e.py", line 441, in run_main
          postlist = callcrackfortran(files, options)
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/f2py/f2py2e.py", line 342, in callcrackfortran
          postlist = crackfortran.crackfortran(files)
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/f2py/crackfortran.py", line 3298, in crackfortran
          readfortrancode(files, crackline)
        File "/tmp/pip-install-aepkxx2m/capytaine_d3c28c827dcd47229059e564ad1b04bc/.eggs/numpy-1.24.0-py3.10-linux-x86_64.egg/numpy/f2py/crackfortran.py", line 395, in readfortrancode
          raise Exception(
      Exception: readfortrancode: reading capytaine/green_functions/libDelhommeau/src/constants.f90#7 failed with
      'ascii' codec can't decode byte 0xcf in position 326: ordinal not in range(128).
      It is likely that installing chardet package will help f2py determine the input file encoding correctly.
      Reading fortran codes...
          Reading file 'capytaine/green_functions/libDelhommeau/src/float32.f90' (format:free)
      [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.
Error: Process completed with exit code 1.

Other parts of the the CI use the conda install instead, which is still working without issue.

Based on the stacktrace, my guess is this may be caused by NumPy 1.24 (released just a few days ago), which features changes to f2py. Limiting our package dependency to numpy <1.24 does not resolve the issue since Capytaine appears to have an explicit numpy build requirement.

cc @cmichelenstrofer @ryancoe

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions