Skip to content

[BUG] find_library_file doesn't find Cygwin import libraries or DLLs #3302

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

Closed
DWesl opened this issue May 2, 2022 · 2 comments
Closed

[BUG] find_library_file doesn't find Cygwin import libraries or DLLs #3302

DWesl opened this issue May 2, 2022 · 2 comments
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.

Comments

@DWesl
Copy link
Contributor

DWesl commented May 2, 2022

setuptools version

setuptools==62.1.0, 61.3.1, 60.10.0

Python version

Python 3.8 (and 3.7, I think)

OS

32-bit and 64-bit Cygwin 3.4.4 on Windows 10

Additional environment information

Cygwin library naming scheme:

  • Shared library/DLL name: cyg${name}.dll
  • Static library: lib${name}.a
  • Import library: lib${name}.dll.a

GCC looks for the import library or static library at link time. The import library redirects calls in the resulting executable or library to the corresponding functions in the DLL. The result will require the DLL at runtime, and the DLL must have execute permissions.

I think this is similar to how .lib and .dll library files function on native Windows targets.

Description

Following up on python-pillow/Pillow#6216:

Attempting to run python setup.py build_ext in Pillow's main directory fails because Pillow can't find jpeg. Downgrading setuptools to version 59.8.0 and running the same command again runs to completion.

Expected behavior

Running under python 3.8 with setuptools 59.8.0:

>>> from distutils.cygwinccompiler import CygwinCCompiler
>>> comp = CygwinCCompiler()
dllwrap: WARNING: dllwrap is deprecated, use gcc -shared or ld -shared instead

>>> comp.find_library_file(["/usr/lib"], "uuid")
'/usr/lib/libuuid.dll.a'

How to Reproduce

Running under python 3.8 with setuptools 62.1.0):

>>> from setuptools._distutils.cygwinccompiler import CygwinCCompiler
>>> comp = CygwinCCompiler()
>>> comp.find_library_file(["/usr/lib"], "uuid")
>>> import os.path
>>> os.path.exists("/usr/lib/libuuid.dll.a")
True

Output

$ python3.8 -m pip install -U pip 'setuptools<60' wheel
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in ./.local/lib/python3.8/site-packages (22.0.4)
Collecting setuptools<60
  Using cached setuptools-59.8.0-py3-none-any.whl (952 kB)
Requirement already satisfied: wheel in ./.local/lib/python3.8/site-packages (0.37.1)
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 62.1.0
    Uninstalling setuptools-62.1.0:
      Successfully uninstalled setuptools-62.1.0
Successfully installed setuptools-59.8.0

$ python3.8
Python 3.8.12 (default, Nov 24 2021, 12:34:46)
[GCC 11.2.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from distutils.cygwinccompiler import CygwinCCompiler
>>> comp = CygwinCCompiler()
dllwrap: WARNING: dllwrap is deprecated, use gcc -shared or ld -shared instead

>>> comp.find_library_file(["/usr/lib"], "uuid")
'/usr/lib/libuuid.dll.a'
>>>

$ python3.8 -m pip install -U pip 'setuptools' wheel                            
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in ./.local/lib/python3.8/site-packages (22.0.4)
Requirement already satisfied: setuptools in ./.local/lib/python3.8/site-packages (59.8.0)
Collecting setuptools
  Using cached setuptools-62.1.0-py3-none-any.whl (1.1 MB)
Requirement already satisfied: wheel in ./.local/lib/python3.8/site-packages (0.37.1)
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 59.8.0
    Uninstalling setuptools-59.8.0:
      Successfully uninstalled setuptools-59.8.0
Successfully installed setuptools-62.1.0

$ python3.8
Python 3.8.12 (default, Nov 24 2021, 12:34:46)
[GCC 11.2.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from distutils.cygwinccompiler import CygwinCCompiler
>>> comp = CygwinCCompiler()
>>> comp.find_library_file(["/usr/lib"], "uuid")
>>>
@DWesl DWesl added bug Needs Triage Issues that need to be evaluated for severity and status. labels May 2, 2022
DWesl added a commit to DWesl/setuptools that referenced this issue May 2, 2022
Closes pypa#3302 

Sets static library, DLL, and import library name patterns to those used by Cygwin packages.
The DLLs will often have a numeral as part of the name (cyg${name}-0.dll or cyg${name}_2.dll or such), but I don't know how to specify that here.
@DWesl
Copy link
Contributor Author

DWesl commented May 10, 2022

I plan to leave this open until pypa/distutils#139 lands in main.

@DWesl
Copy link
Contributor Author

DWesl commented Jun 26, 2022

Closed by #3366

@DWesl DWesl closed this as completed Jun 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant