question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] wrong EXT_SUFFIX on python 3.7 on Windows

See original GitHub issue

setuptools version

>=61

Python version

3.7

OS

Windows

Additional environment information

No response

Description

This setuptools commit changed the bundled distutils.sysconfig to transparently forward get_config_var to the interpreter builtin sysconfig: https://github.com/pypa/setuptools/commit/4b313f0d8600e8957736df7d0ffb795d187ab955

However, as mentioned in this python bug, sysconfig is (was) broken and returns a bad EXT_SUFFIX on python >=3.7. The issue was fixed in 3.10, with a backport into 3.8 and 3.9, however 3.7 was completely left behind.

This problem was mentioned on the setuptools issue tracker in the past, but the knowledge seems to since have slipped the collective mind.

Since setuptools hijacks import distutils by default, this means that anyone using python 3.7, or an older 3.8 or 3.9 installation, will suddenly start getting a wrong EXT_SUFFIX by simply updating to setuptools>=61, and the only way to get back the correct behavior is to set SETUPTOOLS_USE_DISTUTILS=stdlib to prevent the hijacking. Given this overarching impact I believe it’s unfair to impose such a breaking change on users unsuspectingly using older python versions.

Notably, this completely breaks CMake builds of extension modules with FindPython when using affected python versions, since they use distutils.sysconfig to determine the required EXT_SUFFIX.

Expected behavior

Return proper EXT_SUFFIX on any python version >=3.7 (e.g. .cp37-win_amd64.pyd)

How to Reproduce

  1. Install setuptools>=61
  2. py -3.7 -c "from distutils import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"

Output

.pyd

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
axnsan12commented, Apr 11, 2022

Yep, seems good!

> py -3.7 -c "from distutils import sysconfig; import setuptools; print(setuptools.__version__); from setuptools._distutils import sysconfig as st_sysconfig; print(sysconfig is st_sysconfig); print(sysconfig.get_config_var('EXT_SUFFIX'))"
62.1.0
True
.cp37-win_amd64.pyd

Thanks to everyone for the fix!

1reaction
abravalhericommented, Mar 31, 2022

Hi @axnsan12, I am not familiar with the procedure to merge distutils, but usually Jason (the main developer behind setuptools and distutils) does it very frequently. So I am sure this change will be available soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Windows] Python 3.7 initializes LC_CTYPE locale at startup ...
The `isdigit` function is from the UCRT. The `parsers` Cython/C extension is part of the pandas wheel on PyPI. The context for this...
Read more >
EXT_SUFFIX inconsistent between sysconfig and distutils ...
On Windows, Python 3.7.6 and 3.8.1: ``` >>> import sysconfig ... answer is probably wrong (the ABI-qualified extension '.cp38-win_amd64.pyd' ...
Read more >
Changelog — Python 3.7.15 documentation
bpo-40196: Fix a bug in the symtable module that was causing incorrectly report global variables as local. Patch by Pablo Galindo. bpo-40126: Fixed...
Read more >
What's New In Python 3.7 — Python 3.11.1 documentation
This article explains the new features in Python 3.7, compared to 3.6. ... On Windows the default for close_fds was changed from False...
Read more >
Changelog — Python 3.11.1 documentation
gh-74044: Fixed bug where inspect.signature() reported incorrect arguments ... Python Launcher for Windows when argv[0] does not include a file extension.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found