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

[BUG] AttributeError: module 'distutils.log' has no attribute 'warning' #3707

Closed
dmytro-returnbear opened this issue Nov 23, 2022 · 6 comments · Fixed by #3709
Closed

[BUG] AttributeError: module 'distutils.log' has no attribute 'warning' #3707

dmytro-returnbear opened this issue Nov 23, 2022 · 6 comments · Fixed by #3709
Labels

Comments

@dmytro-returnbear
Copy link

setuptools version

setuptools==65.6.2

Python version

Python 3.8.15

OS

macOS 12.5.1

Additional environment information

No response

Description

Installing a package kappa=0.6.0 doesn't work. I think it could be the issue on setuptools's side.

Expected behavior

Installing the package works.

How to Reproduce

$ python3.8 -m venv .venv
$ source .venv/bin/activate
$ pip install setuptools==65.6.2
$ pip install wheel
$ pip install kappa==0.6.0

Output

(.venv) dmytro@Dmytros-MacBook-Pro install_kappa % pip install kappa==0.6.0
Collecting kappa==0.6.0
  Using cached kappa-0.6.0.tar.gz (29 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/kv/zxwjm57d3jdgwyylrg2db6r80000gn/T/pip-install-xjv7l4bl/kappa_6f4dfc99aa59445e99fd8697c5e00cd7/setup.py", line 54, in <module>
          run_setup()
        File "/private/var/folders/kv/zxwjm57d3jdgwyylrg2db6r80000gn/T/pip-install-xjv7l4bl/kappa_6f4dfc99aa59445e99fd8697c5e00cd7/setup.py", line 18, in run_setup
          setup(
        File "/Users/dmytro/Tests/install_kappa/.venv/lib/python3.8/site-packages/setuptools/__init__.py", line 87, in setup
          return distutils.core.setup(**attrs)
        File "/Users/dmytro/Tests/install_kappa/.venv/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
        File "/Users/dmytro/Tests/install_kappa/.venv/lib/python3.8/site-packages/setuptools/dist.py", line 475, in __init__
          _Distribution.__init__(
        File "/Users/dmytro/Tests/install_kappa/.venv/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 258, in __init__
          getattr(self.metadata, "set_" + key)(val)
        File "/Users/dmytro/Tests/install_kappa/.venv/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 1242, in set_classifiers
          self.classifiers = _ensure_list(value, 'classifiers')
        File "/Users/dmytro/Tests/install_kappa/.venv/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 48, in _ensure_list
          log.warning(msg)
      AttributeError: module 'distutils.log' has no attribute 'warning'
      [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.
@dmytro-returnbear dmytro-returnbear added bug Needs Triage Issues that need to be evaluated for severity and status. labels Nov 23, 2022
@LiamCato
Copy link

LiamCato commented Nov 23, 2022

I've been experiencing the same issue on python 3.7.9, I think I've narrowed it down to the patching happening in setuptools.logging where a root logger at distutils.dist.log which has that attributed is overwritten by a seemingly broken logger from distutils.log which does not have the warning attribute.

I might suggest a very naive potential solution for the maintainers of this repo is to simply reverse the patch so the functional logger from distutuls.dist.log is the one that is used everywhere rather than the broken logger from distutils.log

My pull request with the above change:
#3708

@JacobCallahan
Copy link

JacobCallahan commented Nov 23, 2022

We're also hitting this in our github actions (py3.8/3.9) and locally (py3.11).

reproducer: pip install -U git+https://github.com/SatelliteQE/airgun.git@master#egg=airgun

failing actions against python 3.8 and 3.9:
https://github.com/SatelliteQE/robottelo/actions/runs/3534164190/jobs/5930929334

@jaraco it looks like this was an unintended consequence of #3674

Lauszus added a commit to Lauszus/pyblhost that referenced this issue Nov 23, 2022
Lauszus added a commit to Lauszus/pyblhost that referenced this issue Nov 23, 2022
Lauszus added a commit to Lauszus/pyblhost that referenced this issue Nov 23, 2022
@abravalheri
Copy link
Contributor

abravalheri commented Nov 23, 2022

I believe that the reason why the test suite did not catch this problem is because the conditions are somehow rare: the setup.py needs to use tuples for the classifiers or similar fields.

If the setup.py is using tuples, distutils will try to display a warning, which will cause the problem.

Regardless, I am working on a fix in #3709.

@abravalheri abravalheri removed the Needs Triage Issues that need to be evaluated for severity and status. label Nov 23, 2022
JacobCallahan added a commit to SatelliteQE/airgun that referenced this issue Nov 23, 2022
JacobCallahan added a commit to SatelliteQE/automation-tools that referenced this issue Nov 23, 2022
jyejare pushed a commit to SatelliteQE/airgun that referenced this issue Nov 24, 2022
jyejare added a commit to SatelliteQE/airgun that referenced this issue Nov 24, 2022
* Switch classifiers from a tuple to a list

Recommended by @abravalheri in pypa/setuptools#3707 (comment)

* Fix github URL for pycqa/flake8 precommit hook

Co-authored-by: jyejare <jyejare@redhat.com>
github-actions bot pushed a commit to SatelliteQE/airgun that referenced this issue Nov 24, 2022
* Switch classifiers from a tuple to a list

Recommended by @abravalheri in pypa/setuptools#3707 (comment)

* Fix github URL for pycqa/flake8 precommit hook

Co-authored-by: jyejare <jyejare@redhat.com>
(cherry picked from commit 8012321)
jyejare pushed a commit to SatelliteQE/automation-tools that referenced this issue Nov 24, 2022
jyejare pushed a commit to SatelliteQE/airgun that referenced this issue Nov 24, 2022
* Switch classifiers from a tuple to a list

Recommended by @abravalheri in pypa/setuptools#3707 (comment)

* Fix github URL for pycqa/flake8 precommit hook

Co-authored-by: jyejare <jyejare@redhat.com>
(cherry picked from commit 8012321)

Co-authored-by: Jake Callahan <jacob.callahan05@gmail.com>
@anilbey
Copy link

anilbey commented Nov 24, 2022

Hi, now that setuptools 65.6.3 is released, maybe you can yank (delete) the versions causing the bug (65.6.2 and 65.6.1) from pypi.

@abhinov-netapp
Copy link

We are currently running poetry to install packages based out of pyproject.toml file, one particular package: google-oauth (version 1.0.0) breaks while running 'poetry install' with below output:

setuptools version: 59.6.0
python version: 3.10

CalledProcessError

  Command '['/root/.cache/pypoetry/virtualenvs/whelk-xLPSQsjl-py3.10/bin/python', '/root/.local/share/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-21.0.1-py3-none-any.whl/pip', 'install', '--use-pep517', '--disable-pip-version-check', '--prefix', '/root/.cache/pypoetry/virtualenvs/whelk-xLPSQsjl-py3.10', '--no-deps', '/root/.cache/pypoetry/artifacts/03/af/eb/2a591ad20f9688/google-oauth-1.0.0.tar.gz']' returned non-zero exit status 1.

  at /usr/lib/python3.10/subprocess.py:524 in run
       520│             # We don't call process.wait() as .__exit__ does that for us.
       521│             raise
       522│         retcode = process.poll()
       523│         if check and retcode:
    →  524│             raise CalledProcessError(retcode, process.args,
       525│                                      output=stdout, stderr=stderr)
       526│     return CompletedProcess(process.args, retcode, stdout, stderr)
       527│ 
       528│ 

The following error occurred when trying to handle this error:


  EnvCommandError

  Command ['/root/.cache/pypoetry/virtualenvs/whelk-xLPSQsjl-py3.10/bin/python', '/root/.local/share/pypoetry/venv/lib/python3.10/site-packages/virtualenv/seed/wheels/embed/pip-21.0.1-py3-none-any.whl/pip', 'install', '--use-pep517', '--disable-pip-version-check', '--prefix', '/root/.cache/pypoetry/virtualenvs/whelk-xLPSQsjl-py3.10', '--no-deps', '/root/.cache/pypoetry/artifacts/03/af/eb/53c45f6e116b0b6a60a1e5421908aaa2aa0e614e0be92a591ad20f9688/google-oauth-1.0.0.tar.gz'] errored with the following return code 1, and output: 
  Looking in indexes: https://python.repo.eng.netapp.com/simple
  Processing /root/.cache/pypoetry/artifacts/03/af/eb/53c45f6e116b0b6a60a1e5421908aaa2aa0e614e0be92a591ad20f9688/google-oauth-1.0.0.tar.gz
    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 'error'
    ERROR: Command errored out with exit status 1:
     command: /root/.cache/pypoetry/virtualenvs/whelk-xLPSQsjl-py3.10/bin/python /tmp/tmp5wyd5g9v_in_process.py get_requires_for_build_wheel /tmp/tmpvgs7tvrm
         cwd: /tmp/pip-req-build-upw4n6bh
    Complete output (29 lines):
    Traceback (most recent call last):
      File "/tmp/tmp5wyd5g9v_in_process.py", line 280, in <module>
        main()
      File "/tmp/tmp5wyd5g9v_in_process.py", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/tmp/tmp5wyd5g9v_in_process.py", line 114, in get_requires_for_build_wheel
        return hook(config_settings)
      File "/tmp/pip-build-env-r6vw3w7x/overlay/lib/python3.10/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-r6vw3w7x/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in _get_build_requires
        self.run_setup()
      File "/tmp/pip-build-env-r6vw3w7x/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 484, in run_setup
        super(_BuildMetaLegacyBackend,
      File "/tmp/pip-build-env-r6vw3w7x/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 335, in run_setup
        exec(code, locals())
      File "<string>", line 11, in <module>
      File "/tmp/pip-build-env-r6vw3w7x/overlay/lib/python3.10/site-packages/setuptools/__init__.py", line 87, in setup
        return distutils.core.setup(**attrs)
      File "/tmp/pip-build-env-r6vw3w7x/overlay/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 147, in setup
        _setup_distribution = dist = klass(attrs)
      File "/tmp/pip-build-env-r6vw3w7x/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 475, in __init__
        _Distribution.__init__(
      File "/tmp/pip-build-env-r6vw3w7x/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 258, in __init__
        getattr(self.metadata, "set_" + key)(val)
      File "/tmp/pip-build-env-r6vw3w7x/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1242, in set_classifiers
        self.classifiers = _ensure_list(value, 'classifiers')
      File "/tmp/pip-build-env-r6vw3w7x/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 48, in _ensure_list
        log.warning(msg)
    AttributeError: module 'distutils.log' has no attribute 'warning'. Did you mean: 'warnings'?

Can you please suggest if setuptools latest version will solve the Attribute error ?

@abravalheri
Copy link
Contributor

Can you please suggest if setuptools latest version will solve the Attribute error ?

@abhinov-netapp I believe so:

$ virtualenv .venv
$ .venv/bin/python -m pip install -U pip wheel 'setuptools==65.6.3'
$ .venv/bin/python -m pip install --no-build-isolation 'google-oauth==1.0.0'
# ...
Successfully built google-oauth
Installing collected packages: urllib3, six, pycparser, idna, charset-normalizer, certifi, requests, cffi, cryptography, pyopenssl, google-oauth
Successfully installed certifi-2022.9.24 cffi-1.15.1 charset-normalizer-2.1.1 cryptography-38.0.3 google-oauth-1.0.0 idna-3.4 pycparser-2.21 pyopenssl-22.1.0 requests-2.28.1 six-1.16.0 urllib3-1.26.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants