Skip to content

[BUG] module 'distutils' has no attribute 'ccompiler' #3583

@bashkirtsevich

Description

@bashkirtsevich

setuptools version

65.1.0+

Python version

3.9.2

OS

Linux docker (debian based)

Additional environment information

Docker official image python:3.9.2 (debian based)

Description

After upgrading setuptools to version 65.1.0 or higher I have an error:

AttributeError: module 'distutils' has no attribute 'ccompiler'

When I trying to install 3rd party libraries. Inside setup.py I have import like this:

from setuptools import distutils ...
...
distutils.ccompiler.CCompiler.compile = parallelCCompile

Before 2022 Sep 09 that's work fine.

Expected behavior

I expected:

python -c 'from setuptools import distutils; print(distutils.ccompiler)'
<module 'distutils.ccompiler' from '/usr/local/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py'>

This code finally working on 65.0.2 version (look below to console output)

How to Reproduce

Here is bug reproduction and test scenario (inside python:3.9.2 docker clear image):

root@5fcb34f417d3:/# pip install --upgrade setuptools==65.0.2
Collecting setuptools==65.0.2
  Using cached setuptools-65.0.2-py3-none-any.whl (1.2 MB)
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 65.1.0
    Uninstalling setuptools-65.1.0:
      Successfully uninstalled setuptools-65.1.0
Successfully installed setuptools-65.0.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@5fcb34f417d3:/# python -c 'from setuptools import distutils; print(distutils.ccompiler)'
<module 'distutils.ccompiler' from '/usr/local/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py'>
root@5fcb34f417d3:/# pip install --upgrade setuptools==65.1.0
Collecting setuptools==65.1.0
  Using cached setuptools-65.1.0-py3-none-any.whl (1.2 MB)
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 65.0.2
    Uninstalling setuptools-65.0.2:
      Successfully uninstalled setuptools-65.0.2
Successfully installed setuptools-65.1.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@5fcb34f417d3:/# python -c 'from setuptools import distutils; print(distutils.ccompiler)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'distutils' has no attribute 'ccompiler'
root@5fcb34f417d3:/# pip install --upgrade setuptools
Requirement already satisfied: setuptools in /usr/local/lib/python3.9/site-packages (65.1.0)
Collecting setuptools
  Downloading setuptools-65.3.0-py3-none-any.whl (1.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 5.2 MB/s eta 0:00:00
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 65.1.0
    Uninstalling setuptools-65.1.0:
      Successfully uninstalled setuptools-65.1.0
Successfully installed setuptools-65.3.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@5fcb34f417d3:/# python -c 'from setuptools import distutils; print(distutils.ccompiler)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'distutils' has no attribute 'ccompiler'

Output

python -c 'from setuptools import distutils; print(distutils.ccompiler)'

Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: module 'distutils' has no attribute 'ccompiler'

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions