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

setuptools.windows_support requires ctypes support even on non-Windows #2234

Closed
ronaldoussoren opened this issue Jul 5, 2020 · 4 comments
Closed

Comments

@ronaldoussoren
Copy link
Contributor

The module setuptools.windows_support unconditionally imports "ctypes", even though this module is only used when running on a Windows machine. The result of this is that setuptools is unusable on systems without ctypes (in my case because I'm running macOS on arm64 where the patches needed to get ctypes support haven't been merged yet).

Environment Details

  • Operating System and version: macOS 11, arm64
  • Python version: 3.10 (trunk)
  • Python installed how: Manually
  • Virtualenv version (if using virtualenv): n/a

Command(s) that triggered the warning/error (and output):

python setup.py install     # for a project using setuptools in its setup.py file 

Command(s) used to install setuptools (and output): Setuptools was installed when building python "make install".

Versions:

% pip list
Package    Version
---------- -------
pip        20.1.1
setuptools 47.1.0
@jaraco
Copy link
Member

jaraco commented Jul 5, 2020

Thanks for the report. That does sound like an inconvenience.

On one hand, this sounds like a defect lies with Python and will be fixed in Python. Indeed, this issue could be worked around by touch $PYTHON_LIB/ctypes.py.

Given that this issue is only affecting a non-final release and is likely to be fixed before that final release, I'm tempted to say a temporary workaround should be preferable to editing the setuptools source.

What do you think? Should Setuptools adjust for this temporarily degraded state?

@ronaldoussoren
Copy link
Contributor Author

My particular case is just an inconvenience that I worked around by patching setuptools.

Is ctypes essential enough to have a hard dependency on it regardless of the platform? I'd expect that all major platforms are supported by libffi and hence ctypes, but there may be obscure platforms that run Python without providing ctypes.

The hard dependency can be avoided by moving the import inside setuptools.windows_support.hidden_file.

I don't have a strong opinion either way.

@jaraco
Copy link
Member

jaraco commented Jul 7, 2020

Is ctypes essential enough to have a hard dependency on it regardless of the platform?

Not really. Surely the import could be made late, and already the import for ctypes.wintypes is tucked inside there as it's the only one until now that was reported as selectively available, but even that behavior is a bug. It seems to me that Python is advertising ctypes as always importable, so my preference would be to rely on that (somewhat implicit) guarantee in order to keep the code as simple and uniform as possible.

If on the other hand, Python were to document that ctypes is only sometimes importable and recommends a technique to avoid errors on select systems, I'd be much more inclined to adopt the recommendation.

@Avasam
Copy link
Contributor

Avasam commented Sep 14, 2024

Pretty sure this was fixed by #3178

@jaraco jaraco closed this as completed Sep 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants