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

Add patches to build Pythons 2.7 through 3.5 on Cygwin #980

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions pkgs/python/3.2/2.6.5-FD_SETSIZE.patch
1 change: 1 addition & 0 deletions pkgs/python/3.2/2.6.5-ncurses-abi6.patch
1 change: 1 addition & 0 deletions pkgs/python/3.2/2.7.3-dylib.patch
34 changes: 34 additions & 0 deletions pkgs/python/3.2/3.2.6-ctypes-util-find_library.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--- Lib/ctypes/util.py
+++ Lib/ctypes/util.py
@@ -82,6 +82,20 @@ if os.name == "posix" and sys.platform == "darwin":
continue
return None

+elif sys.platform == "cygwin":
+ def find_library(name):
+ for libdir in ['/usr/lib', '/usr/local/lib']:
+ for libext in ['lib%s.dll.a' % name, 'lib%s.a' % name]:
+ implib = os.path.join(libdir, libext)
+ if not os.path.exists(implib):
+ continue
+ cmd = "dlltool -I " + implib + " 2>/dev/null"
+ res = os.popen(cmd).read().replace("\n","")
+ if not res:
+ continue
+ return res
+ return None
+
elif os.name == "posix":
# Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
import re, tempfile, errno
@@ -224,6 +238,10 @@ def test():
print(cdll.LoadLibrary("libcrypto.dylib"))
print(cdll.LoadLibrary("libSystem.dylib"))
print(cdll.LoadLibrary("System.framework/System"))
+ elif sys.platform == "cygwin":
+ print cdll.LoadLibrary("cygbz2-1.dll")
+ print find_library("crypt")
+ print cdll.LoadLibrary("cygcrypt-0.dll")
else:
print(cdll.LoadLibrary("libm.so"))
print(cdll.LoadLibrary("libcrypt.so"))
29 changes: 29 additions & 0 deletions pkgs/python/3.2/3.2.6-dbm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git setup.py setup.py
index 3b78c70..0d911e8 100644
--- setup.py
+++ setup.py
@@ -1081,7 +1081,7 @@ class PyBuildExt(build_ext):

dbm_order = ['gdbm']
# The standard Unix dbm module:
- if platform not in ['cygwin']:
+ if platform not in ['win32']:
config_args = [arg.strip("'")
for arg in sysconfig.get_config_var("CONFIG_ARGS").split()]
dbm_args = [arg for arg in config_args
@@ -1136,6 +1136,15 @@ class PyBuildExt(build_ext):
],
libraries = gdbm_libs)
break
+ if find_file("ndbm.h", inc_dirs, []) is not None:
+ print("building dbm using gdbm")
+ dbmext = Extension(
+ '_dbm', ['_dbmmodule.c'],
+ define_macros=[
+ ('HAVE_NDBM_H', None),
+ ],
+ libraries = gdbm_libs)
+ break
elif cand == "bdb":
if db_incs is not None:
print("building dbm using bdb")
13 changes: 13 additions & 0 deletions pkgs/python/3.2/3.2.6-export-PyNode_SizeOf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git Include/node.h Include/node.h
index 9f6760c..2cde3b9 100644
--- Include/node.h
+++ Include/node.h
@@ -21,7 +21,7 @@ PyAPI_FUNC(int) PyNode_AddChild(node *n, int type,
char *str, int lineno, int col_offset);
PyAPI_FUNC(void) PyNode_Free(node *n);
#ifndef Py_LIMITED_API
-Py_ssize_t _PyNode_SizeOf(node *n);
+PyAPI_FUNC(Py_ssize_t) _PyNode_SizeOf(node *n);
#endif

/* Node access functions */
11 changes: 11 additions & 0 deletions pkgs/python/3.2/3.2.6-export-PySignal_SetWakeupFd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- Include/pyerrors.h
+++ Include/pyerrors.h
@@ -244,7 +244,7 @@ PyAPI_FUNC(void) PyErr_SetInterrupt(void);

/* In signalmodule.c */
#ifndef Py_LIMITED_API
-int PySignal_SetWakeupFd(int fd);
+PyAPI_FUNC(int) PySignal_SetWakeupFd(int fd);
#endif

/* Support for adding program text to SyntaxErrors */
31 changes: 31 additions & 0 deletions pkgs/python/3.2/3.2.6-getpath-exe-extension.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--- Modules/getpath.c
+++ Modules/getpath.c
@@ -491,6 +491,28 @@ calculate_path(void)
if (isxfile(progpath))
break;

+#ifdef __CYGWIN__
+ /*
+ * Cygwin automatically removes the ".exe" extension from argv[0]
+ * to make programs feel like they are in a more Unix-like
+ * environment. Unfortunately, this can make it problemmatic for
+ * Cygwin to distinguish between a directory and an executable with
+ * the same name excluding the ".exe" extension. For example, the
+ * Cygwin Python build directory has a "Python" directory and a
+ * "python.exe" executable. This causes isxfile() to erroneously
+ * return false. If isdir() returns true and there is enough space
+ * to append the ".exe" extension, then we try again with the
+ * extension appended.
+ */
+#define EXE ".exe"
+ if (isdir(progpath) && strlen(progpath) + strlen(EXE) <= MAXPATHLEN)
+ {
+ strcat(progpath, EXE);
+ if (isxfile(progpath))
+ break;
+ }
+#endif /* __CYGWIN__ */
+
if (!delim) {
progpath[0] = L'\0';
break;
47 changes: 47 additions & 0 deletions pkgs/python/3.2/3.2.6-issue13756.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
diff --git Lib/distutils/command/build_ext.py Lib/distutils/command/build_ext.py
index 64f634c..89ed2ab 100644
--- Lib/distutils/command/build_ext.py
+++ Lib/distutils/command/build_ext.py
@@ -719,13 +719,6 @@ class build_ext(Command):
# don't extend ext.libraries, it may be shared with other
# extensions, it is a reference to the original list
return ext.libraries + [pythonlib]
- elif sys.platform[:6] == "cygwin":
- template = "python%d.%d"
- pythonlib = (template %
- (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
- # don't extend ext.libraries, it may be shared with other
- # extensions, it is a reference to the original list
- return ext.libraries + [pythonlib]
elif sys.platform[:6] == "atheos":
from distutils import sysconfig

diff --git Makefile.pre.in Makefile.pre.in
index 5260e6b..eb4fac4 100644
--- Makefile.pre.in
+++ Makefile.pre.in
@@ -520,9 +520,9 @@ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
$(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
$(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources

-# This rule builds the Cygwin Python DLL and import library if configured
+# This rule builds the Python DLL and import library if configured
# for a shared core library; otherwise, this rule is a noop.
-$(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
+$(DLLLIBRARY) libpython$(LDVERSION).dll.a: $(LIBRARY_OBJS)
if test -n "$(DLLLIBRARY)"; then \
$(LDSHARED) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
$(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \
diff --git Modules/makesetup Modules/makesetup
index 40dfa9d..1a1fcf6 100755
--- Modules/makesetup
+++ Modules/makesetup
@@ -91,7 +91,7 @@ CYGWIN*) if test $libdir = .
else
ExtraLibDir='$(LIBPL)'
fi
- ExtraLibs="-L$ExtraLibDir -lpython\$(VERSION)";;
+ ExtraLibs="-L$ExtraLibDir -lpython\$(LDVERSION)";;
esac

# Main loop
20 changes: 20 additions & 0 deletions pkgs/python/3.2/3.2.6-no-enable-new-dtags.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git Lib/distutils/unixccompiler.py Lib/distutils/unixccompiler.py
index 69045f8..7ed0a5f 100644
--- Lib/distutils/unixccompiler.py
+++ Lib/distutils/unixccompiler.py
@@ -239,9 +239,13 @@ class UnixCCompiler(CCompiler):
# -Wl whenever gcc was used in the past it is probably
# safest to keep doing so.
if sysconfig.get_config_var("GNULD") == "yes":
- # GNU ld needs an extra option to get a RUNPATH
+ # GNU ELF ld needs an extra option to get a RUNPATH
# instead of just an RPATH.
- return "-Wl,--enable-new-dtags,-R" + dir
+ if sys.platform in ["win32", "cygwin"] or \
+ "mingw" in compiler:
+ return []
+ else:
+ return "-Wl,--enable-new-dtags,-R" + dir
else:
return "-Wl,-R" + dir
else:
11 changes: 11 additions & 0 deletions pkgs/python/3.2/3.2.6-no-libm.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- setup.py
+++ setup.py
@@ -508,7 +508,7 @@ class PyBuildExt(build_ext):

# Check for MacOS X, which doesn't need libm.a at all
math_libs = ['m']
- if platform == 'darwin':
+ if platform in ['darwin', 'cygwin']:
math_libs = []

# XXX Omitted modules: gl, pure, dl, SGI-specific modules
101 changes: 101 additions & 0 deletions pkgs/python/3.2/3.2.6-no-native-tls.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
diff --git Python/thread_pthread.h Python/thread_pthread.h
index de42f1a..a4eab78 100644
--- Python/thread_pthread.h
+++ Python/thread_pthread.h
@@ -601,6 +601,12 @@ _pythread_pthread_set_stacksize(size_t size)

#define THREAD_SET_STACKSIZE(x) _pythread_pthread_set_stacksize(x)

+
+/* Issue #25658: POSIX doesn't require that pthread_key_t is integer.
+ If key type isn't integer, TLS functions are implemented by CPython self.
+*/
+#ifdef PTHREAD_KEY_T_IS_INTEGER
+
#define Py_HAVE_NATIVE_TLS

int
@@ -643,3 +649,5 @@ PyThread_get_key_value(int key)
void
PyThread_ReInitTLS(void)
{}
+
+#endif /* PTHREAD_KEY_T_IS_INTEGER */
diff --git configure configure
index b107bf2..59f80cb 100755
--- configure
+++ configure
@@ -7564,6 +7564,35 @@ _ACEOF


fi
+
+# Issue #25658: POSIX doesn't require that pthread_key_t is integer.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthread_key_t is integer" >&5
+$as_echo_n "checking whether pthread_key_t is integer... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_key_t k; k * 1;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_pthread_key_t_is_integer=yes
+else
+ ac_pthread_key_t_is_integer=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pthread_key_t_is_integer" >&5
+$as_echo "$ac_pthread_key_t_is_integer" >&6; }
+if test "$ac_pthread_key_t_is_integer" = yes ; then
+
+$as_echo "#define PTHREAD_KEY_T_IS_INTEGER 1" >>confdefs.h
+
+fi
CC="$ac_save_cc"


diff --git configure.ac configure.ac
index 0ab4430..89e422a 100644
--- configure.ac
+++ configure.ac
@@ -1610,6 +1610,19 @@ if test "$have_pthread_t" = yes ; then
#endif
])
fi
+
+# Issue #25658: POSIX doesn't require that pthread_key_t is integer.
+AC_MSG_CHECKING(whether pthread_key_t is integer)
+AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[#include <pthread.h>]], [[pthread_key_t k; k * 1;]])],
+ [ac_pthread_key_t_is_integer=yes],
+ [ac_pthread_key_t_is_integer=no]
+)
+AC_MSG_RESULT($ac_pthread_key_t_is_integer)
+if test "$ac_pthread_key_t_is_integer" = yes ; then
+ AC_DEFINE(PTHREAD_KEY_T_IS_INTEGER, 1,
+ [Define if pthread_key_t is integer.])
+fi
CC="$ac_save_cc"

AC_SUBST(OTHER_LIBTOOL_OPT)
diff --git pyconfig.h.in pyconfig.h.in
index cf0ea1f..0bd8387 100644
--- pyconfig.h.in
+++ pyconfig.h.in
@@ -973,6 +973,9 @@
/* Define if POSIX semaphores aren't enabled on your system */
#undef POSIX_SEMAPHORES_NOT_ENABLED

+/* Define if pthread_key_t is integer. */
+#undef PTHREAD_KEY_T_IS_INTEGER
+
/* Defined if PTHREAD_SCOPE_SYSTEM supported. */
#undef PTHREAD_SYSTEM_SCHED_SUPPORTED

26 changes: 26 additions & 0 deletions pkgs/python/3.2/3.2.6-tkinter-x11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--- setup.py
+++ setup.py
@@ -1606,12 +1606,6 @@ class PyBuildExt(build_ext):
include_dirs.append('/usr/X11/include')
added_lib_dirs.append('/usr/X11/lib')

- # If Cygwin, then verify that X is installed before proceeding
- if platform == 'cygwin':
- x11_inc = find_file('X11/Xlib.h', [], include_dirs)
- if x11_inc is None:
- return
-
# Check for BLT extension
if self.compiler.find_library_file(lib_dirs + added_lib_dirs,
'BLT8.0'):
@@ -1629,9 +1623,7 @@ class PyBuildExt(build_ext):
if platform in ['aix3', 'aix4']:
libs.append('ld')

- # Finally, link with the X11 libraries (not appropriate on cygwin)
- if platform != "cygwin":
- libs.append('X11')
+ libs.append('X11')

ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
define_macros=[('WITH_APPINIT', 1)] + defs,
1 change: 1 addition & 0 deletions pkgs/python/3.3/2.6.5-FD_SETSIZE.patch
1 change: 1 addition & 0 deletions pkgs/python/3.3/2.6.5-ncurses-abi6.patch
1 change: 1 addition & 0 deletions pkgs/python/3.3/2.7.3-dylib.patch
1 change: 1 addition & 0 deletions pkgs/python/3.3/3.2.6-ctypes-util-find_library.patch
1 change: 1 addition & 0 deletions pkgs/python/3.3/3.2.6-export-PyNode_SizeOf.patch
1 change: 1 addition & 0 deletions pkgs/python/3.3/3.2.6-export-PySignal_SetWakeupFd.patch
1 change: 1 addition & 0 deletions pkgs/python/3.3/3.2.6-getpath-exe-extension.patch
1 change: 1 addition & 0 deletions pkgs/python/3.3/3.2.6-issue13756.patch
1 change: 1 addition & 0 deletions pkgs/python/3.3/3.2.6-no-enable-new-dtags.patch
1 change: 1 addition & 0 deletions pkgs/python/3.3/3.2.6-no-native-tls.patch
Loading