aburrell / apexpy

A Python wrapper for Apex coordinates
MIT License
34 stars 25 forks source link

BUG: Installation fails due to setuptools distutils.log.Log bug #100

Closed ljlamarche closed 1 year ago

ljlamarche commented 1 year ago

Description It appear that apexpy is susceptible to https://github.com/pypa/setuptools/issues/3693 This looks to be a recent bug due to a recent release of setuptools removing the class distutils.log.Log and is effecting a number of projects (notably https://github.com/numpy/numpy/issues/22623). Attempting to pip install apexpy produces the following output:

Collecting apexpy
  Using cached apexpy-1.1.0.tar.gz (5.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
  ╰─> [23 lines of output]
      Traceback (most recent call last):
        File "/home/llamarche/venvs/vvels/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 351, in <module>
          main()
        File "/home/llamarche/venvs/vvels/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 333, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/home/llamarche/venvs/vvels/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File "/tmp/pip-build-env-qkupvvyg/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 338, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
        File "/tmp/pip-build-env-qkupvvyg/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
          self.run_setup()
        File "/tmp/pip-build-env-qkupvvyg/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 483, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/tmp/pip-build-env-qkupvvyg/overlay/lib/python3.9/site-packages/setuptools/build_meta.py", line 335, in run_setup
          exec(code, locals())
        File "<string>", line 13, in <module>
        File "/tmp/pip-build-env-qkupvvyg/overlay/lib/python3.9/site-packages/numpy/distutils/__init__.py", line 26, in <module>
          from . import ccompiler
        File "/tmp/pip-build-env-qkupvvyg/overlay/lib/python3.9/site-packages/numpy/distutils/ccompiler.py", line 20, in <module>
          from numpy.distutils import log
        File "/tmp/pip-build-env-qkupvvyg/overlay/lib/python3.9/site-packages/numpy/distutils/log.py", line 4, in <module>
          from distutils.log import Log as old_Log
      ImportError: cannot import name 'Log' from 'distutils.log' (/tmp/pip-build-env-qkupvvyg/overlay/lib/python3.9/site-packages/setuptools/_distutils/log.py)
      [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.

Steps to Reproduce

  1. Install numpy
    $ pip install numpy
  2. Install apexpy
    $ pip install apexpy
  3. Result is the same when using the --no-binary flag
    $ pip install --no-binary :apexpy: apexpy

Expected Behavior Successful installation of apexpy

Computer:

Comments This looks like something that should and will be handled by setuptools developers. Alternatively, I'm not confident about this, but the new build system might make this irrelevant?

smithara commented 1 year ago

See also https://github.com/spacepy/spacepy/issues/672:

As a quick remedy, setting

SETUPTOOLS_USE_DISTUTILS=stdlib

before calling the pip installation helps.

Required fixes, as suggested by the NumPy documentation:

1. Pin `setuptools` to a version < 60 in the package requirements as a quick fix.

2. Get rid of the deprecated `numpy.distutils` in the long run.

Confirming that this works providing fortran compiler is available and working:

export SETUPTOOLS_USE_DISTUTILS=stdlib
pip install apexpy

I see that the setuptools pinning is done in the current develop branch. Installing from that also works: pip install git+https://github.com/aburrell/apexpy.git@develop

ljlamarche commented 1 year ago

In addition to @smithara correct comment that pinning this has already been addressed in the develop branch, setuptools released a new version fixing this problem upstream (https://github.com/pypa/setuptools/releases/tag/v65.6.3). Closing this!