ucfopen / canvasapi

Python API wrapper for Instructure's Canvas LMS. Easily manage courses, users, gradebooks, and more.
https://pypi.python.org/pypi/canvasapi
MIT License
554 stars 173 forks source link

setuptools 71 w/ pytest: TypeError: canonicalize_version() unexpected keyword argument 'strip_trailing_zero' #658

Closed cbm755 closed 2 months ago

cbm755 commented 2 months ago

Describe the bug

When setuptools 71 came out several days ago, installing on systems with pytest also present fails. Not sure if its "their" fault or CanvasAPI's. Upstream issue is https://github.com/pypa/setuptools/issues/4496

To Reproduce

podman run -it --rm ubuntu:22.04 bash   # or docker
apt update
apt-get -y install python3-dev python3-pip 

apt-get -y install  python3-pytest    # works w/o, crashes with

pip install -U setuptools wheel pip
pip install canvasapi 

Then I get this error:

Collecting canvasapi
  Downloading canvasapi-3.2.0.tar.gz (87 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.0/87.0 kB 2.6 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [40 lines of output]
      running egg_info
      creating /tmp/pip-pip-egg-info-tslf153i/canvasapi.egg-info
      writing /tmp/pip-pip-egg-info-tslf153i/canvasapi.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-pip-egg-info-tslf153i/canvasapi.egg-info/dependency_links.txt
      writing requirements to /tmp/pip-pip-egg-info-tslf153i/canvasapi.egg-info/requires.txt
      writing top-level names to /tmp/pip-pip-egg-info-tslf153i/canvasapi.egg-info/top_level.txt
      writing manifest file '/tmp/pip-pip-egg-info-tslf153i/canvasapi.egg-info/SOURCES.txt'
      reading manifest file '/tmp/pip-pip-egg-info-tslf153i/canvasapi.egg-info/SOURCES.txt'
      adding license file 'LICENSE'
      adding license file 'AUTHORS.md'
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-fw60eoal/canvasapi_d4c531a0ccc849589a4a737952018c5e/setup.py", line 20, in <module>
          setup(
        File "/usr/local/lib/python3.10/dist-packages/setuptools/__init__.py", line 108, in setup
          return distutils.core.setup(**attrs)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/core.py", line 184, in setup
          return run_commands(dist)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/core.py", line 200, in run_commands
          dist.run_commands()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/dist.py", line 970, in run_commands
          self.run_command(cmd)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/dist.py", line 974, in run_command
          super().run_command(command)
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/dist.py", line 989, in run_command
          cmd_obj.run()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/egg_info.py", line 321, in run
          self.find_sources()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/egg_info.py", line 329, in find_sources
          mm.run()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/egg_info.py", line 555, in run
          self.prune_file_list()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/command/egg_info.py", line 621, in prune_file_list
          base_dir = self.distribution.get_fullname()
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_core_metadata.py", line 266, in get_fullname
          return _distribution_fullname(self.get_name(), self.get_version())
        File "/usr/local/lib/python3.10/dist-packages/setuptools/_core_metadata.py", line 284, in _distribution_fullname
          canonicalize_version(version, strip_trailing_zero=False),
      TypeError: canonicalize_version() got an unexpected keyword argument 'strip_trailing_zero'
      [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.

Environment information

Ubuntu 22.04, as per container example above, also seen on Ubuntu 20.04

python3 --version

Python 3.10.12

cbm755 commented 2 months ago

Not sure if anything needs done in CanvasAPI about this or not, but I need to pip install -U packaging to get around this, when using setuptools >= 71. See upstream linked issues. Hope this helps someone, and feel free to close it not relevant.

Thetwam commented 2 months ago

If the issue is setuptools not correctly specifying its dependencies, I'm not sure that's something we can/should fix on our end. While we could add a minimum version of packaging as a requirement for canvasapi, I'm inclined to declare this one setuptools's problem, not canvasapi.

Thank you for making an issue, at least it should help some folks if they run into the same problem.