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

Support Cygwin patches #73

Closed
jaraco opened this issue Dec 5, 2021 · 15 comments
Closed

Support Cygwin patches #73

jaraco opened this issue Dec 5, 2021 · 15 comments
Labels
help wanted Extra attention is needed

Comments

@jaraco
Copy link
Member

jaraco commented Dec 5, 2021

Also need to incorporate mingw/cygwin distutil patches - see #60 (comment), #60 (comment);
pypa/setuptools#2909 adds a CI for Cygwin

Originally posted by @mkoeppe in pypa/setuptools#2896 (comment)

@jaraco jaraco transferred this issue from pypa/setuptools Dec 5, 2021
@jaraco
Copy link
Member Author

jaraco commented Dec 5, 2021

@mkoeppe Do you have a contact for Cygwin? Do you know what the Cygwin patches are?

Setuptools released two versions, 48 and 50, which twice attempted to adopt distutils into Setuptools, but there were emergent issues. I attempted to capture those emergent issues, but did not see anything reported from cygwin.

I'd really like to get this feature rolled out, as the longer it takes to get distutils adoption as the default, the more risk there is that changes to distutils will break use-cases that aren't being exercised.

Cygwin users will have the option to opt out by using SETUPTOOLS_USE_DISTUTILS=stdlib, but I would prefer if users did not have to do that, but I'm also reluctant to delay the rollout further.

Please do let us know more about what patches are present and how distutils might be able to incorporate that behavior.

@mkoeppe
Copy link
Contributor

mkoeppe commented Dec 6, 2021

I don't have a cygwin contact, but the patches can be found at https://cygwin.com/git-cygwin-packages/?p=git/cygwin-packages/python38.git;a=tree

@mkoeppe
Copy link
Contributor

mkoeppe commented Dec 6, 2021

@jaraco
Copy link
Member Author

jaraco commented Dec 11, 2021

I've reached out on the mailing list to raise awareness of the issue.

@mkoeppe

This comment has been minimized.

@mkoeppe

This comment has been minimized.

@jaraco
Copy link
Member Author

jaraco commented Dec 11, 2021

Let’s track msys2 project separately, even if some of the solutions may be similar.

@jaraco
Copy link
Member Author

jaraco commented Dec 12, 2021

In email, Marco Atzeri responded:

Hi Jason,

currently we are not using any patch on SetupTools
Last I packaged is 59.5.0 for python 3.6 to 3.9

https://cygwin.com/packages/summary/python-setuptools-src.html

there are several patches on Python source that include the distutil portion

I just updated the patches used on last binaries on :

http://cygwin.com/git/cygwin-packages/python39.git
http://cygwin.com/git/cygwin-packages/python39.git

they are almost identical

General information on our python packages are also on:

https://cygwin.com/packages/summary/python38-src.html
https://cygwin.com/packages/summary/python39-src.html


It also included an attachment 3.8-distutils-cygwin.patch:

--- origsrc/Python-3.8.0a4/Lib/distutils/cygwinccompiler.py	2019-05-06 14:30:25.000000000 -0400
+++ src/Python-3.8.0a4/Lib/distutils/cygwinccompiler.py	2019-05-19 14:35:55.872267300 -0400
@@ -92,9 +92,7 @@ class CygwinCCompiler(UnixCCompiler):
     compiler_type = 'cygwin'
     obj_extension = ".o"
     static_lib_extension = ".a"
-    shared_lib_extension = ".dll"
-    static_lib_format = "lib%s%s"
-    shared_lib_format = "%s%s"
+    shared_lib_extension = ".dll.a"
     exe_extension = ".exe"
 
     def __init__(self, verbose=0, dry_run=0, force=0):
--- origsrc/Python-3.8.0a4/Lib/distutils/unixccompiler.py	2019-05-19 14:24:27.779442200 -0400
+++ src/Python-3.8.0a4/Lib/distutils/unixccompiler.py	2019-05-19 14:35:55.872267300 -0400
@@ -81,6 +81,7 @@ class UnixCCompiler(CCompiler):
     xcode_stub_lib_format = dylib_lib_format
     if sys.platform == "cygwin":
         exe_extension = ".exe"
+        dylib_lib_extension = ".dll.a"
 
     def preprocess(self, source, output_file=None, macros=None,
                    include_dirs=None, extra_preargs=None, extra_postargs=None):
--- origsrc/Python-3.8.0b2/Misc/python.pc.in	2019-07-04 06:50:19.000000000 -0400
+++ src/Python-3.8.0b2/Misc/python.pc.in	2019-07-21 15:33:35.374399700 -0400
@@ -9,5 +9,5 @@ Description: Build a C extension for Pyt
 Requires:
 Version: @VERSION@
 Libs.private: @LIBS@
-Libs:
+Libs: @LIBPYTHON@
 Cflags: -I${includedir}/python@VERSION@@ABIFLAGS@

@jaraco jaraco added the help wanted Extra attention is needed label Dec 12, 2021
@lazka
Copy link
Contributor

lazka commented Dec 18, 2021

I've added a CI job in #82 for starters

@lazka
Copy link
Contributor

lazka commented Jun 8, 2022

@lazka
Copy link
Contributor

lazka commented Jun 8, 2022

Ah, I missed 3.1-enable-new-dtags.patch, I'll have a look

@lazka
Copy link
Contributor

lazka commented Jun 8, 2022

I've created #150, as always, feedback welcome.

@lazka
Copy link
Contributor

lazka commented Jul 2, 2022

I think this can be closed now

@DWesl
Copy link
Contributor

DWesl commented Jul 20, 2022

  1. The only remaining patch is https://cygwin.com/git-cygwin-packages/?p=git/cygwin-packages/python38.git;a=blob;f=00001-rpath.patch;h=aad36128683812464d49ae7f8ff3124e6a71e99e;hb=HEAD which comes from Fedora https://src.fedoraproject.org/rpms/python3.10/blob/4dc2200b8e81beeff7e672aa095f533e87b184c5/f/00001-rpath.patch so it isn't cygwin specific. If no one is complaining about this with non-stdlib distutils on Fedora then likely it is no longer an issue.

I suspect pypa/setuptools#3257 is about this patch no longer being applied on an rpm-based platform.

@DWesl
Copy link
Contributor

DWesl commented Jul 31, 2022

I just ran into this on Cygwin; pip decided to compile numpy, and failed with

    INFO: gcc -shared -Wl,--enable-auto-image-base [whole bunch of input files]  -L/usr/lib -Lbuild/temp.cygwin-3.3.5-x86_64-3.8 -Wl,--enable-new-dtags,-R/usr/lib -lnpymath -lblas -lblas -lpython3.8 -o build/lib.cygwin-3.3.5-x86_64-3.8/numpy/core/_multiarray_umath.cpython-38-x86_64-cygwin.dll
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: unrecognized option '--enable-new-dtags'
    /usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: use the --help option for usage information
    collect2: error: ld returned 1 exit status

There's a chance this is because I set BLAS=/usr/lib/libblas.dll.a, and this would happen even with that second patch if I set BLAS=/home/me/lib/myblas.dll.a, but applying that patch would allow the most common cases to work.

DWesl added a commit to DWesl/distutils that referenced this issue Jul 31, 2022
Last of the patches from pypa#73 
Might close pypa/setuptools#3257

Dual purposes here:
- On platforms like Cygwin that don't have `rpath`, try to avoid adding things to `rpath`
- Some distribution binary package makers require that no shared library list a system library directory (`/lib`, `/lib64`, `/usr/lib`, `/usr/lib64`) in its `rpath`; this patch simplifies the code to ensure the shared library can find its dependencies at runtime.
DWesl added a commit to DWesl/distutils that referenced this issue Jun 28, 2024
Last of the patches from pypa#73 
Might close pypa/setuptools#3257

Dual purposes here:
- On platforms like Cygwin that don't have `rpath`, try to avoid adding things to `rpath`
- Some distribution binary package makers require that no shared library list a system library directory (`/lib`, `/lib64`, `/usr/lib`, `/usr/lib64`) in its `rpath`; this patch simplifies the code to ensure the shared library can find its dependencies at runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants