uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
|
|
@ -0,0 +1,34 @@
|
|||
--- origsrc/Lib/ctypes/util.py 2007-09-14 15:05:26.000000000 -0500
|
||||
+++ src/Lib/ctypes/util.py 2008-11-25 17:54:47.319296200 -0600
|
||||
@@ -41,6 +41,20 @@
|
||||
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
|
||||
@@ -157,6 +173,10 @@
|
||||
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")
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
--- origsrc/setup.py 2008-02-04 17:41:02.000000000 -0600
|
||||
+++ src/setup.py 2008-07-02 02:11:28.671875000 -0500
|
||||
@@ -1277,12 +1279,6 @@
|
||||
include_dirs.append('/usr/X11/include')
|
||||
added_lib_dirs.append('/usr/X11/lib')
|
||||
|
||||
- # If Cygwin, then verify that X is installed before proceeding
|
||||
- if host_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'):
|
||||
@@ -1300,9 +1296,8 @@
|
||||
if host_platform in ['aix3', 'aix4']:
|
||||
libs.append('ld')
|
||||
|
||||
- # Finally, link with the X11 libraries (not appropriate on cygwin)
|
||||
- if host_platform != "cygwin":
|
||||
- libs.append('X11')
|
||||
+ # Finally, link with the X11 libraries
|
||||
+ libs.append('X11')
|
||||
|
||||
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
|
||||
define_macros=[('WITH_APPINIT', 1)] + defs,
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
--- origsrc/Modules/_ssl.c 2009-01-26 10:55:41.000000000 -0600
|
||||
+++ src/Modules/_ssl.c 2009-08-20 00:04:59.346816700 -0500
|
||||
@@ -15,6 +15,10 @@
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
+#ifdef __CYGWIN__
|
||||
+#undef WITH_THREAD
|
||||
+#endif
|
||||
+
|
||||
#ifdef WITH_THREAD
|
||||
#include "pythread.h"
|
||||
#define PySSL_BEGIN_ALLOW_THREADS { \
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
--- Python-2.6.5.orig/Modules/selectmodule.c 2012-02-02 22:35:21.835125000 -0500
|
||||
+++ Python-2.6.5/Modules/selectmodule.c 2012-02-02 22:41:41.210125000 -0500
|
||||
@@ -6,6 +6,21 @@
|
||||
>= 0.
|
||||
*/
|
||||
|
||||
+/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined.
|
||||
+ 64 is too small (too many people have bumped into that limit).
|
||||
+ Here we boost it.
|
||||
+
|
||||
+ Cygwin also defines FD_SETSIZE to 64, so also increase the limit on
|
||||
+ Cygwin. We must do this before sys/types.h is included, which otherwise
|
||||
+ sets FD_SETSIZE to the default.
|
||||
+
|
||||
+ Users who want even more than the boosted limit should #define
|
||||
+ FD_SETSIZE higher before this; e.g., via compiler /D switch.
|
||||
+*/
|
||||
+#if (defined(MS_WINDOWS) || defined(__CYGWIN__)) && !defined(FD_SETSIZE)
|
||||
+#define FD_SETSIZE 512
|
||||
+#endif
|
||||
+
|
||||
#include "Python.h"
|
||||
#include <structmember.h>
|
||||
|
||||
@@ -16,16 +31,6 @@
|
||||
#undef HAVE_BROKEN_POLL
|
||||
#endif
|
||||
|
||||
-/* Windows #defines FD_SETSIZE to 64 if FD_SETSIZE isn't already defined.
|
||||
- 64 is too small (too many people have bumped into that limit).
|
||||
- Here we boost it.
|
||||
- Users who want even more than the boosted limit should #define
|
||||
- FD_SETSIZE higher before this; e.g., via compiler /D switch.
|
||||
-*/
|
||||
-#if defined(MS_WINDOWS) && !defined(FD_SETSIZE)
|
||||
-#define FD_SETSIZE 512
|
||||
-#endif
|
||||
-
|
||||
#if defined(HAVE_POLL_H)
|
||||
#include <poll.h>
|
||||
#elif defined(HAVE_SYS_POLL_H)
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
--- origsrc/Include/pyerrors.h 2008-06-08 23:58:54.000000000 -0500
|
||||
+++ src/Include/pyerrors.h 2010-05-12 04:19:31.535297200 -0500
|
||||
@@ -232,7 +232,7 @@ PyAPI_FUNC(int) PyErr_CheckSignals(void)
|
||||
PyAPI_FUNC(void) PyErr_SetInterrupt(void);
|
||||
|
||||
/* In signalmodule.c */
|
||||
-int PySignal_SetWakeupFd(int fd);
|
||||
+PyAPI_FUNC(int) PySignal_SetWakeupFd(int fd);
|
||||
|
||||
/* Support for adding program text to SyntaxErrors */
|
||||
PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
--- origsrc/Include/py_curses.h 2009-09-06 16:23:05.000000000 -0500
|
||||
+++ src/Include/py_curses.h 2010-04-14 15:21:23.008971400 -0500
|
||||
@@ -17,6 +17,13 @@
|
||||
#define NCURSES_OPAQUE 0
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
+#ifdef __CYGWIN__
|
||||
+/* the following define is necessary for Cygwin; without it, the
|
||||
+ Cygwin-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python
|
||||
+ can't get at the WINDOW flags field. */
|
||||
+#define NCURSES_INTERNALS
|
||||
+#endif /* __CYGWIN__ */
|
||||
+
|
||||
#ifdef __FreeBSD__
|
||||
/*
|
||||
** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
--- origsrc/setup.py.orig 2012-11-27 10:20:47.442395900 -0500
|
||||
+++ src/setup.py 2012-11-27 10:53:15.583020900 -0500
|
||||
@@ -1141,7 +1141,7 @@
|
||||
|
||||
dbm_order = ['gdbm']
|
||||
# The standard Unix dbm module:
|
||||
- if host_platform not in ['cygwin']:
|
||||
+ if host_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
|
||||
@@ -1192,6 +1192,15 @@
|
||||
],
|
||||
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"
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
--- origsrc/Lib/distutils/unixccompiler.py.orig 2012-11-27 07:44:15.409993500 -0500
|
||||
+++ src/Lib/distutils/unixccompiler.py 2012-11-27 08:09:57.801770900 -0500
|
||||
@@ -141,6 +141,7 @@
|
||||
static_lib_format = shared_lib_format = dylib_lib_format = "lib%s%s"
|
||||
if sys.platform == "cygwin":
|
||||
exe_extension = ".exe"
|
||||
+ dylib_lib_extension = ".dll.a"
|
||||
|
||||
def preprocess(self, source,
|
||||
output_file=None, macros=None, include_dirs=None,
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
--- origsrc/Modules/getpath.c.orig 2012-11-27 12:07:56.098645900 -0500
|
||||
+++ src/Modules/getpath.c 2012-11-27 12:10:11.254895900 -0500
|
||||
@@ -436,6 +436,28 @@
|
||||
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] = '\0';
|
||||
break;
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
--- origsrc/setup.py.orig 2012-11-27 09:28:34.051770900 -0500
|
||||
+++ src/setup.py 2012-11-27 09:28:47.239270900 -0500
|
||||
@@ -470,7 +470,7 @@
|
||||
|
||||
# Check for MacOS X, which doesn't need libm.a at all
|
||||
math_libs = ['m']
|
||||
- if host_platform in ['darwin', 'beos']:
|
||||
+ if host_platform in ['darwin', 'beos', 'cygwin']:
|
||||
math_libs = []
|
||||
|
||||
# XXX Omitted modules: gl, pure, dl, SGI-specific modules
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
From 5a8d121a1f3ef5ad7c105ee378cc79a3eac0c7d4 Mon Sep 17 00:00:00 2001
|
||||
From: Rishi <rishi_devan@mail.com>
|
||||
Date: Wed, 15 Jul 2020 13:51:00 +0200
|
||||
Subject: [PATCH] bpo-39017: Avoid infinite loop in the tarfile module
|
||||
(GH-21454)
|
||||
|
||||
Avoid infinite loop when reading specially crafted TAR files using the tarfile module
|
||||
(CVE-2019-20907).
|
||||
---
|
||||
Lib/tarfile.py | 2 ++
|
||||
|
||||
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
|
||||
index e2b60532f6..6769066cab 100755
|
||||
--- a/Lib/tarfile.py
|
||||
+++ b/Lib/tarfile.py
|
||||
@@ -1249,6 +1249,8 @@ class TarInfo(object):
|
||||
|
||||
length, keyword = match.groups()
|
||||
length = int(length)
|
||||
+ if length == 0:
|
||||
+ raise InvalidHeaderError("invalid header")
|
||||
value = buf[match.end(2) + 1:match.start(1) + length - 1]
|
||||
|
||||
# Normally, we could just use "utf-8" as the encoding and "strict"
|
||||
|
|
@ -0,0 +1,390 @@
|
|||
From e7b005c05dbdbce967a409abd71641281a8604bf Mon Sep 17 00:00:00 2001
|
||||
From: Senthil Kumaran <senthil@uthcode.com>
|
||||
Date: Mon, 15 Feb 2021 11:16:43 -0800
|
||||
Subject: [PATCH 24/26] [3.6] bpo-42967: only use '&' as a query string
|
||||
separator (GH-24297) (GH-24532)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
bpo-42967: [security] Address a web cache-poisoning issue reported in
|
||||
urllib.parse.parse_qsl().
|
||||
|
||||
urllib.parse will only us "&" as query string separator by default
|
||||
instead of both ";" and "&" as allowed in earlier versions. An optional
|
||||
argument seperator with default value "&" is added to specify the
|
||||
separator.
|
||||
|
||||
Co-authored-by: Éric Araujo <merwok@netwok.org>
|
||||
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
|
||||
Co-authored-by: Adam Goldschmidt <adamgold7@gmail.com>
|
||||
|
||||
Rebased for Python 2.7 by Michał Górny
|
||||
---
|
||||
Doc/library/cgi.rst | 7 +++-
|
||||
Doc/library/urlparse.rst | 23 ++++++++++-
|
||||
Lib/cgi.py | 20 +++++++---
|
||||
Lib/test/test_cgi.py | 29 +++++++++++---
|
||||
Lib/test/test_urlparse.py | 38 +++++++++----------
|
||||
Lib/urlparse.py | 22 ++++++++---
|
||||
.../2021-02-14-15-59-16.bpo-42967.YApqDS.rst | 1 +
|
||||
7 files changed, 100 insertions(+), 40 deletions(-)
|
||||
create mode 100644 Misc/NEWS.d/next/Security/2021-02-14-15-59-16.bpo-42967.YApqDS.rst
|
||||
|
||||
diff --git a/Doc/library/cgi.rst b/Doc/library/cgi.rst
|
||||
index ecd62c8c01..b85cdd8b61 100644
|
||||
--- a/Doc/library/cgi.rst
|
||||
+++ b/Doc/library/cgi.rst
|
||||
@@ -285,10 +285,10 @@ These are useful if you want more control, or if you want to employ some of the
|
||||
algorithms implemented in this module in other circumstances.
|
||||
|
||||
|
||||
-.. function:: parse(fp[, environ[, keep_blank_values[, strict_parsing]]])
|
||||
+.. function:: parse(fp[, environ[, keep_blank_values[, strict_parsing]]], separator="&")
|
||||
|
||||
Parse a query in the environment or from a file (the file defaults to
|
||||
- ``sys.stdin`` and environment defaults to ``os.environ``). The *keep_blank_values* and *strict_parsing* parameters are
|
||||
+ ``sys.stdin`` and environment defaults to ``os.environ``). The *keep_blank_values*, *strict_parsing* and *separator* parameters are
|
||||
passed to :func:`urlparse.parse_qs` unchanged.
|
||||
|
||||
|
||||
@@ -316,6 +316,9 @@ algorithms implemented in this module in other circumstances.
|
||||
Note that this does not parse nested multipart parts --- use
|
||||
:class:`FieldStorage` for that.
|
||||
|
||||
+ .. versionchanged:: 3.6.13
|
||||
+ Added the *separator* parameter.
|
||||
+
|
||||
|
||||
.. function:: parse_header(string)
|
||||
|
||||
diff --git a/Doc/library/urlparse.rst b/Doc/library/urlparse.rst
|
||||
index 0989c88c30..2f8e4c5a44 100644
|
||||
--- a/Doc/library/urlparse.rst
|
||||
+++ b/Doc/library/urlparse.rst
|
||||
@@ -136,7 +136,7 @@ The :mod:`urlparse` module defines the following functions:
|
||||
now raise :exc:`ValueError`.
|
||||
|
||||
|
||||
-.. function:: parse_qs(qs[, keep_blank_values[, strict_parsing[, max_num_fields]]])
|
||||
+.. function:: parse_qs(qs[, keep_blank_values[, strict_parsing[, max_num_fields]]], separator='&')
|
||||
|
||||
Parse a query string given as a string argument (data of type
|
||||
:mimetype:`application/x-www-form-urlencoded`). Data are returned as a
|
||||
@@ -157,6 +157,9 @@ The :mod:`urlparse` module defines the following functions:
|
||||
read. If set, then throws a :exc:`ValueError` if there are more than
|
||||
*max_num_fields* fields read.
|
||||
|
||||
+ The optional argument *separator* is the symbol to use for separating the
|
||||
+ query arguments. It defaults to ``&``.
|
||||
+
|
||||
Use the :func:`urllib.urlencode` function to convert such dictionaries into
|
||||
query strings.
|
||||
|
||||
@@ -166,7 +169,14 @@ The :mod:`urlparse` module defines the following functions:
|
||||
.. versionchanged:: 2.7.16
|
||||
Added *max_num_fields* parameter.
|
||||
|
||||
-.. function:: parse_qsl(qs[, keep_blank_values[, strict_parsing[, max_num_fields]]])
|
||||
+ .. versionchanged:: 2.7.18-gentoo
|
||||
+ Added *separator* parameter with the default value of ``&``. Earlier
|
||||
+ Python versions allowed using both ``;`` and ``&`` as query parameter
|
||||
+ separator. This has been changed to allow only a single separator key,
|
||||
+ with ``&`` as the default separator.
|
||||
+
|
||||
+
|
||||
+.. function:: parse_qsl(qs[, keep_blank_values[, strict_parsing[, max_num_fields]]], separator='&')
|
||||
|
||||
Parse a query string given as a string argument (data of type
|
||||
:mimetype:`application/x-www-form-urlencoded`). Data are returned as a list of
|
||||
@@ -186,6 +196,9 @@ The :mod:`urlparse` module defines the following functions:
|
||||
read. If set, then throws a :exc:`ValueError` if there are more than
|
||||
*max_num_fields* fields read.
|
||||
|
||||
+ The optional argument *separator* is the symbol to use for separating the
|
||||
+ query arguments. It defaults to ``&``.
|
||||
+
|
||||
Use the :func:`urllib.urlencode` function to convert such lists of pairs into
|
||||
query strings.
|
||||
|
||||
@@ -195,6 +208,12 @@ The :mod:`urlparse` module defines the following functions:
|
||||
.. versionchanged:: 2.7.16
|
||||
Added *max_num_fields* parameter.
|
||||
|
||||
+ .. versionchanged:: 2.7.18-gentoo
|
||||
+ Added *separator* parameter with the default value of ``&``. Earlier
|
||||
+ Python versions allowed using both ``;`` and ``&`` as query parameter
|
||||
+ separator. This has been changed to allow only a single separator key,
|
||||
+ with ``&`` as the default separator.
|
||||
+
|
||||
.. function:: urlunparse(parts)
|
||||
|
||||
Construct a URL from a tuple as returned by ``urlparse()``. The *parts* argument
|
||||
diff --git a/Lib/cgi.py b/Lib/cgi.py
|
||||
index 5b903e0347..9d0848b6b1 100755
|
||||
--- a/Lib/cgi.py
|
||||
+++ b/Lib/cgi.py
|
||||
@@ -121,7 +121,8 @@ log = initlog # The current logging function
|
||||
# 0 ==> unlimited input
|
||||
maxlen = 0
|
||||
|
||||
-def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
|
||||
+def parse(fp=None, environ=os.environ, keep_blank_values=0,
|
||||
+ strict_parsing=0, separator='&'):
|
||||
"""Parse a query in the environment or from a file (default stdin)
|
||||
|
||||
Arguments, all optional:
|
||||
@@ -140,6 +141,9 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
|
||||
strict_parsing: flag indicating what to do with parsing errors.
|
||||
If false (the default), errors are silently ignored.
|
||||
If true, errors raise a ValueError exception.
|
||||
+
|
||||
+ separator: str. The symbol to use for separating the query arguments.
|
||||
+ Defaults to &.
|
||||
"""
|
||||
if fp is None:
|
||||
fp = sys.stdin
|
||||
@@ -171,7 +175,8 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
|
||||
else:
|
||||
qs = ""
|
||||
environ['QUERY_STRING'] = qs # XXX Shouldn't, really
|
||||
- return urlparse.parse_qs(qs, keep_blank_values, strict_parsing)
|
||||
+ return urlparse.parse_qs(qs, keep_blank_values, strict_parsing,
|
||||
+ separator=separator)
|
||||
|
||||
|
||||
# parse query string function called from urlparse,
|
||||
@@ -395,7 +400,7 @@ class FieldStorage:
|
||||
|
||||
def __init__(self, fp=None, headers=None, outerboundary="",
|
||||
environ=os.environ, keep_blank_values=0, strict_parsing=0,
|
||||
- max_num_fields=None):
|
||||
+ max_num_fields=None, separator='&'):
|
||||
"""Constructor. Read multipart/* until last part.
|
||||
|
||||
Arguments, all optional:
|
||||
@@ -430,6 +435,7 @@ class FieldStorage:
|
||||
self.keep_blank_values = keep_blank_values
|
||||
self.strict_parsing = strict_parsing
|
||||
self.max_num_fields = max_num_fields
|
||||
+ self.separator = separator
|
||||
if 'REQUEST_METHOD' in environ:
|
||||
method = environ['REQUEST_METHOD'].upper()
|
||||
self.qs_on_post = None
|
||||
@@ -613,7 +619,8 @@ class FieldStorage:
|
||||
if self.qs_on_post:
|
||||
qs += '&' + self.qs_on_post
|
||||
query = urlparse.parse_qsl(qs, self.keep_blank_values,
|
||||
- self.strict_parsing, self.max_num_fields)
|
||||
+ self.strict_parsing, self.max_num_fields,
|
||||
+ separator=self.separator)
|
||||
self.list = [MiniFieldStorage(key, value) for key, value in query]
|
||||
self.skip_lines()
|
||||
|
||||
@@ -629,7 +636,8 @@ class FieldStorage:
|
||||
query = urlparse.parse_qsl(self.qs_on_post,
|
||||
self.keep_blank_values,
|
||||
self.strict_parsing,
|
||||
- self.max_num_fields)
|
||||
+ self.max_num_fields,
|
||||
+ separator=self.separator)
|
||||
self.list.extend(MiniFieldStorage(key, value)
|
||||
for key, value in query)
|
||||
FieldStorageClass = None
|
||||
@@ -649,7 +657,7 @@ class FieldStorage:
|
||||
headers = rfc822.Message(self.fp)
|
||||
part = klass(self.fp, headers, ib,
|
||||
environ, keep_blank_values, strict_parsing,
|
||||
- max_num_fields)
|
||||
+ max_num_fields, separator=self.separator)
|
||||
|
||||
if max_num_fields is not None:
|
||||
max_num_fields -= 1
|
||||
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
|
||||
index 743c2afbd4..f414faa23b 100644
|
||||
--- a/Lib/test/test_cgi.py
|
||||
+++ b/Lib/test/test_cgi.py
|
||||
@@ -61,12 +61,9 @@ parse_strict_test_cases = [
|
||||
("", ValueError("bad query field: ''")),
|
||||
("&", ValueError("bad query field: ''")),
|
||||
("&&", ValueError("bad query field: ''")),
|
||||
- (";", ValueError("bad query field: ''")),
|
||||
- (";&;", ValueError("bad query field: ''")),
|
||||
# Should the next few really be valid?
|
||||
("=", {}),
|
||||
("=&=", {}),
|
||||
- ("=;=", {}),
|
||||
# This rest seem to make sense
|
||||
("=a", {'': ['a']}),
|
||||
("&=a", ValueError("bad query field: ''")),
|
||||
@@ -81,8 +78,6 @@ parse_strict_test_cases = [
|
||||
("a=a+b&b=b+c", {'a': ['a b'], 'b': ['b c']}),
|
||||
("a=a+b&a=b+a", {'a': ['a b', 'b a']}),
|
||||
("x=1&y=2.0&z=2-3.%2b0", {'x': ['1'], 'y': ['2.0'], 'z': ['2-3.+0']}),
|
||||
- ("x=1;y=2.0&z=2-3.%2b0", {'x': ['1'], 'y': ['2.0'], 'z': ['2-3.+0']}),
|
||||
- ("x=1;y=2.0;z=2-3.%2b0", {'x': ['1'], 'y': ['2.0'], 'z': ['2-3.+0']}),
|
||||
("Hbc5161168c542333633315dee1182227:key_store_seqid=400006&cuyer=r&view=bustomer&order_id=0bb2e248638833d48cb7fed300000f1b&expire=964546263&lobale=en-US&kid=130003.300038&ss=env",
|
||||
{'Hbc5161168c542333633315dee1182227:key_store_seqid': ['400006'],
|
||||
'cuyer': ['r'],
|
||||
@@ -188,6 +183,30 @@ class CgiTests(unittest.TestCase):
|
||||
self.assertEqual(expect[k], v)
|
||||
self.assertItemsEqual(expect.values(), d.values())
|
||||
|
||||
+ def test_separator(self):
|
||||
+ parse_semicolon = [
|
||||
+ ("x=1;y=2.0", {'x': ['1'], 'y': ['2.0']}),
|
||||
+ ("x=1;y=2.0;z=2-3.%2b0", {'x': ['1'], 'y': ['2.0'], 'z': ['2-3.+0']}),
|
||||
+ (";", ValueError("bad query field: ''")),
|
||||
+ (";;", ValueError("bad query field: ''")),
|
||||
+ ("=;a", ValueError("bad query field: 'a'")),
|
||||
+ (";b=a", ValueError("bad query field: ''")),
|
||||
+ ("b;=a", ValueError("bad query field: 'b'")),
|
||||
+ ("a=a+b;b=b+c", {'a': ['a b'], 'b': ['b c']}),
|
||||
+ ("a=a+b;a=b+a", {'a': ['a b', 'b a']}),
|
||||
+ ]
|
||||
+ for orig, expect in parse_semicolon:
|
||||
+ env = {'QUERY_STRING': orig}
|
||||
+ fs = cgi.FieldStorage(separator=';', environ=env)
|
||||
+ if isinstance(expect, dict):
|
||||
+ for key in expect.keys():
|
||||
+ expect_val = expect[key]
|
||||
+ self.assertIn(key, fs)
|
||||
+ if len(expect_val) > 1:
|
||||
+ self.assertEqual(fs.getvalue(key), expect_val)
|
||||
+ else:
|
||||
+ self.assertEqual(fs.getvalue(key), expect_val[0])
|
||||
+
|
||||
def test_log(self):
|
||||
cgi.log("Testing")
|
||||
|
||||
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
|
||||
index 86c4a0595c..0b2107339a 100644
|
||||
--- a/Lib/test/test_urlparse.py
|
||||
+++ b/Lib/test/test_urlparse.py
|
||||
@@ -24,16 +24,20 @@ parse_qsl_test_cases = [
|
||||
("&a=b", [('a', 'b')]),
|
||||
("a=a+b&b=b+c", [('a', 'a b'), ('b', 'b c')]),
|
||||
("a=1&a=2", [('a', '1'), ('a', '2')]),
|
||||
- (";", []),
|
||||
- (";;", []),
|
||||
- (";a=b", [('a', 'b')]),
|
||||
- ("a=a+b;b=b+c", [('a', 'a b'), ('b', 'b c')]),
|
||||
- ("a=1;a=2", [('a', '1'), ('a', '2')]),
|
||||
- (b";", []),
|
||||
- (b";;", []),
|
||||
- (b";a=b", [(b'a', b'b')]),
|
||||
- (b"a=a+b;b=b+c", [(b'a', b'a b'), (b'b', b'b c')]),
|
||||
- (b"a=1;a=2", [(b'a', b'1'), (b'a', b'2')]),
|
||||
+ (b"", []),
|
||||
+ (b"&", []),
|
||||
+ (b"&&", []),
|
||||
+ (b"=", [(b'', b'')]),
|
||||
+ (b"=a", [(b'', b'a')]),
|
||||
+ (b"a", [(b'a', b'')]),
|
||||
+ (b"a=", [(b'a', b'')]),
|
||||
+ (b"&a=b", [(b'a', b'b')]),
|
||||
+ (b"a=a+b&b=b+c", [(b'a', b'a b'), (b'b', b'b c')]),
|
||||
+ (b"a=1&a=2", [(b'a', b'1'), (b'a', b'2')]),
|
||||
+ (";a=b", [(';a', 'b')]),
|
||||
+ ("a=a+b;b=b+c", [('a', 'a b;b=b c')]),
|
||||
+ (b";a=b", [(b';a', b'b')]),
|
||||
+ (b"a=a+b;b=b+c", [(b'a', b'a b;b=b c')]),
|
||||
]
|
||||
|
||||
parse_qs_test_cases = [
|
||||
@@ -57,16 +61,10 @@ parse_qs_test_cases = [
|
||||
(b"&a=b", {b'a': [b'b']}),
|
||||
(b"a=a+b&b=b+c", {b'a': [b'a b'], b'b': [b'b c']}),
|
||||
(b"a=1&a=2", {b'a': [b'1', b'2']}),
|
||||
- (";", {}),
|
||||
- (";;", {}),
|
||||
- (";a=b", {'a': ['b']}),
|
||||
- ("a=a+b;b=b+c", {'a': ['a b'], 'b': ['b c']}),
|
||||
- ("a=1;a=2", {'a': ['1', '2']}),
|
||||
- (b";", {}),
|
||||
- (b";;", {}),
|
||||
- (b";a=b", {b'a': [b'b']}),
|
||||
- (b"a=a+b;b=b+c", {b'a': [b'a b'], b'b': [b'b c']}),
|
||||
- (b"a=1;a=2", {b'a': [b'1', b'2']}),
|
||||
+ (";a=b", {';a': ['b']}),
|
||||
+ ("a=a+b;b=b+c", {'a': ['a b;b=b c']}),
|
||||
+ (b";a=b", {b';a': [b'b']}),
|
||||
+ (b"a=a+b;b=b+c", {b'a':[ b'a b;b=b c']}),
|
||||
]
|
||||
|
||||
class UrlParseTestCase(unittest.TestCase):
|
||||
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
|
||||
index 798b467b60..6c32727fce 100644
|
||||
--- a/Lib/urlparse.py
|
||||
+++ b/Lib/urlparse.py
|
||||
@@ -382,7 +382,8 @@ def unquote(s):
|
||||
append(item)
|
||||
return ''.join(res)
|
||||
|
||||
-def parse_qs(qs, keep_blank_values=0, strict_parsing=0, max_num_fields=None):
|
||||
+def parse_qs(qs, keep_blank_values=0, strict_parsing=0, max_num_fields=None,
|
||||
+ separator='&'):
|
||||
"""Parse a query given as a string argument.
|
||||
|
||||
Arguments:
|
||||
@@ -402,17 +403,22 @@ def parse_qs(qs, keep_blank_values=0, strict_parsing=0, max_num_fields=None):
|
||||
|
||||
max_num_fields: int. If set, then throws a ValueError if there
|
||||
are more than n fields read by parse_qsl().
|
||||
+
|
||||
+ separator: str. The symbol to use for separating the query arguments.
|
||||
+ Defaults to &.
|
||||
+
|
||||
"""
|
||||
dict = {}
|
||||
for name, value in parse_qsl(qs, keep_blank_values, strict_parsing,
|
||||
- max_num_fields):
|
||||
+ max_num_fields, separator=separator):
|
||||
if name in dict:
|
||||
dict[name].append(value)
|
||||
else:
|
||||
dict[name] = [value]
|
||||
return dict
|
||||
|
||||
-def parse_qsl(qs, keep_blank_values=0, strict_parsing=0, max_num_fields=None):
|
||||
+def parse_qsl(qs, keep_blank_values=0, strict_parsing=0, max_num_fields=None,
|
||||
+ separator='&'):
|
||||
"""Parse a query given as a string argument.
|
||||
|
||||
Arguments:
|
||||
@@ -432,17 +438,23 @@ def parse_qsl(qs, keep_blank_values=0, strict_parsing=0, max_num_fields=None):
|
||||
max_num_fields: int. If set, then throws a ValueError if there
|
||||
are more than n fields read by parse_qsl().
|
||||
|
||||
+ separator: str. The symbol to use for separating the query arguments.
|
||||
+ Defaults to &.
|
||||
+
|
||||
Returns a list, as G-d intended.
|
||||
"""
|
||||
+ if not separator or (not isinstance(separator, (str, bytes))):
|
||||
+ raise ValueError("Separator must be of type string or bytes.")
|
||||
+
|
||||
# If max_num_fields is defined then check that the number of fields
|
||||
# is less than max_num_fields. This prevents a memory exhaustion DOS
|
||||
# attack via post bodies with many fields.
|
||||
if max_num_fields is not None:
|
||||
- num_fields = 1 + qs.count('&') + qs.count(';')
|
||||
+ num_fields = 1 + qs.count(separator)
|
||||
if max_num_fields < num_fields:
|
||||
raise ValueError('Max number of fields exceeded')
|
||||
|
||||
- pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
|
||||
+ pairs = [s1 for s1 in qs.split(separator)]
|
||||
r = []
|
||||
for name_value in pairs:
|
||||
if not name_value and not strict_parsing:
|
||||
diff --git a/Misc/NEWS.d/next/Security/2021-02-14-15-59-16.bpo-42967.YApqDS.rst b/Misc/NEWS.d/next/Security/2021-02-14-15-59-16.bpo-42967.YApqDS.rst
|
||||
new file mode 100644
|
||||
index 0000000000..f08489b414
|
||||
--- /dev/null
|
||||
+++ b/Misc/NEWS.d/next/Security/2021-02-14-15-59-16.bpo-42967.YApqDS.rst
|
||||
@@ -0,0 +1 @@
|
||||
+Fix web cache poisoning vulnerability by defaulting the query args separator to ``&``, and allowing the user to choose a custom separator.
|
||||
--
|
||||
2.31.1
|
||||
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
From fab838b2ee7cfb9037c24f0f18dfe01aa379b3f7 Mon Sep 17 00:00:00 2001
|
||||
From: Benjamin Peterson <benjamin@python.org>
|
||||
Date: Mon, 18 Jan 2021 15:11:46 -0600
|
||||
Subject: [3.6] closes bpo-42938: Replace snprintf with Python unicode
|
||||
formatting in ctypes param reprs. (GH-24250)
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
(cherry picked from commit 916610ef90a0d0761f08747f7b0905541f0977c7)
|
||||
|
||||
Co-authored-by: Benjamin Peterson <benjamin@python.org>
|
||||
Rebased for Python 2.7 by Michał Górny <mgorny@gentoo.org>
|
||||
---
|
||||
Lib/ctypes/test/test_parameters.py | 43 +++++++++++++++++++
|
||||
.../2021-01-18-09-27-31.bpo-42938.4Zn4Mp.rst | 2 +
|
||||
Modules/_ctypes/callproc.c | 49 +++++++++++-----------
|
||||
3 files changed, 69 insertions(+), 25 deletions(-)
|
||||
create mode 100644 Misc/NEWS.d/next/Security/2021-01-18-09-27-31.bpo-42938.4Zn4Mp.rst
|
||||
|
||||
diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/ctypes/test/test_parameters.py
|
||||
index 23c1b6e225..3456882ccb 100644
|
||||
--- a/Lib/ctypes/test/test_parameters.py
|
||||
+++ b/Lib/ctypes/test/test_parameters.py
|
||||
@@ -206,6 +206,49 @@ class SimpleTypesTestCase(unittest.TestCase):
|
||||
with self.assertRaises(ZeroDivisionError):
|
||||
WorseStruct().__setstate__({}, b'foo')
|
||||
|
||||
+ def test_parameter_repr(self):
|
||||
+ from ctypes import (
|
||||
+ c_bool,
|
||||
+ c_char,
|
||||
+ c_wchar,
|
||||
+ c_byte,
|
||||
+ c_ubyte,
|
||||
+ c_short,
|
||||
+ c_ushort,
|
||||
+ c_int,
|
||||
+ c_uint,
|
||||
+ c_long,
|
||||
+ c_ulong,
|
||||
+ c_longlong,
|
||||
+ c_ulonglong,
|
||||
+ c_float,
|
||||
+ c_double,
|
||||
+ c_longdouble,
|
||||
+ c_char_p,
|
||||
+ c_wchar_p,
|
||||
+ c_void_p,
|
||||
+ )
|
||||
+ self.assertRegexpMatches(repr(c_bool.from_param(True)), r"^<cparam '\?' at 0x[A-Fa-f0-9]+>$")
|
||||
+ self.assertEqual(repr(c_char.from_param('a')), "<cparam 'c' (a)>")
|
||||
+ self.assertRegexpMatches(repr(c_wchar.from_param('a')), r"^<cparam 'u' at 0x[A-Fa-f0-9]+>$")
|
||||
+ self.assertEqual(repr(c_byte.from_param(98)), "<cparam 'b' (98)>")
|
||||
+ self.assertEqual(repr(c_ubyte.from_param(98)), "<cparam 'B' (98)>")
|
||||
+ self.assertEqual(repr(c_short.from_param(511)), "<cparam 'h' (511)>")
|
||||
+ self.assertEqual(repr(c_ushort.from_param(511)), "<cparam 'H' (511)>")
|
||||
+ self.assertRegexpMatches(repr(c_int.from_param(20000)), r"^<cparam '[li]' \(20000\)>$")
|
||||
+ self.assertRegexpMatches(repr(c_uint.from_param(20000)), r"^<cparam '[LI]' \(20000\)>$")
|
||||
+ self.assertRegexpMatches(repr(c_long.from_param(20000)), r"^<cparam '[li]' \(20000\)>$")
|
||||
+ self.assertRegexpMatches(repr(c_ulong.from_param(20000)), r"^<cparam '[LI]' \(20000\)>$")
|
||||
+ self.assertRegexpMatches(repr(c_longlong.from_param(20000)), r"^<cparam '[liq]' \(20000\)>$")
|
||||
+ self.assertRegexpMatches(repr(c_ulonglong.from_param(20000)), r"^<cparam '[LIQ]' \(20000\)>$")
|
||||
+ self.assertEqual(repr(c_float.from_param(1.5)), "<cparam 'f' (1.5)>")
|
||||
+ self.assertEqual(repr(c_double.from_param(1.5)), "<cparam 'd' (1.5)>")
|
||||
+ self.assertEqual(repr(c_double.from_param(1e300)), "<cparam 'd' (1e+300)>")
|
||||
+ self.assertRegexpMatches(repr(c_longdouble.from_param(1.5)), r"^<cparam ('d' \(1.5\)|'g' at 0x[A-Fa-f0-9]+)>$")
|
||||
+ self.assertRegexpMatches(repr(c_char_p.from_param(b'hihi')), "^<cparam 'z' \(0x[A-Fa-f0-9]+\)>$")
|
||||
+ self.assertRegexpMatches(repr(c_wchar_p.from_param('hihi')), "^<cparam 'Z' \(0x[A-Fa-f0-9]+\)>$")
|
||||
+ self.assertRegexpMatches(repr(c_void_p.from_param(0x12)), r"^<cparam 'P' \(0x0*12\)>$")
|
||||
+
|
||||
################################################################
|
||||
|
||||
if __name__ == '__main__':
|
||||
diff --git a/Misc/NEWS.d/next/Security/2021-01-18-09-27-31.bpo-42938.4Zn4Mp.rst b/Misc/NEWS.d/next/Security/2021-01-18-09-27-31.bpo-42938.4Zn4Mp.rst
|
||||
new file mode 100644
|
||||
index 0000000000..7df65a156f
|
||||
--- /dev/null
|
||||
+++ b/Misc/NEWS.d/next/Security/2021-01-18-09-27-31.bpo-42938.4Zn4Mp.rst
|
||||
@@ -0,0 +1,2 @@
|
||||
+Avoid static buffers when computing the repr of :class:`ctypes.c_double` and
|
||||
+:class:`ctypes.c_longdouble` values.
|
||||
diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c
|
||||
index 066fefc0cc..421addf353 100644
|
||||
--- a/Modules/_ctypes/callproc.c
|
||||
+++ b/Modules/_ctypes/callproc.c
|
||||
@@ -460,50 +460,51 @@ PyCArg_dealloc(PyCArgObject *self)
|
||||
static PyObject *
|
||||
PyCArg_repr(PyCArgObject *self)
|
||||
{
|
||||
- char buffer[256];
|
||||
switch(self->tag) {
|
||||
case 'b':
|
||||
case 'B':
|
||||
- sprintf(buffer, "<cparam '%c' (%d)>",
|
||||
+ return PyString_FromFormat("<cparam '%c' (%d)>",
|
||||
self->tag, self->value.b);
|
||||
- break;
|
||||
case 'h':
|
||||
case 'H':
|
||||
- sprintf(buffer, "<cparam '%c' (%d)>",
|
||||
+ return PyString_FromFormat("<cparam '%c' (%d)>",
|
||||
self->tag, self->value.h);
|
||||
- break;
|
||||
case 'i':
|
||||
case 'I':
|
||||
- sprintf(buffer, "<cparam '%c' (%d)>",
|
||||
+ return PyString_FromFormat("<cparam '%c' (%d)>",
|
||||
self->tag, self->value.i);
|
||||
- break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
- sprintf(buffer, "<cparam '%c' (%ld)>",
|
||||
+ return PyString_FromFormat("<cparam '%c' (%ld)>",
|
||||
self->tag, self->value.l);
|
||||
- break;
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
case 'q':
|
||||
case 'Q':
|
||||
- sprintf(buffer,
|
||||
+ return PyString_FromFormat(
|
||||
"<cparam '%c' (%" PY_FORMAT_LONG_LONG "d)>",
|
||||
self->tag, self->value.q);
|
||||
- break;
|
||||
#endif
|
||||
case 'd':
|
||||
- sprintf(buffer, "<cparam '%c' (%f)>",
|
||||
- self->tag, self->value.d);
|
||||
- break;
|
||||
- case 'f':
|
||||
- sprintf(buffer, "<cparam '%c' (%f)>",
|
||||
- self->tag, self->value.f);
|
||||
- break;
|
||||
-
|
||||
+ case 'f': {
|
||||
+ PyObject *f = PyFloat_FromDouble((self->tag == 'f') ? self->value.f : self->value.d);
|
||||
+ if (f == NULL) {
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ PyObject *r = PyObject_Repr(f);
|
||||
+ if (r == NULL) {
|
||||
+ Py_DECREF(f);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ PyObject *result = PyString_FromFormat(
|
||||
+ "<cparam '%c' (%s)>", self->tag, PyString_AsString(r));
|
||||
+ Py_DECREF(r);
|
||||
+ Py_DECREF(f);
|
||||
+ return result;
|
||||
+ }
|
||||
case 'c':
|
||||
- sprintf(buffer, "<cparam '%c' (%c)>",
|
||||
+ return PyString_FromFormat("<cparam '%c' (%c)>",
|
||||
self->tag, self->value.c);
|
||||
- break;
|
||||
|
||||
/* Hm, are these 'z' and 'Z' codes useful at all?
|
||||
Shouldn't they be replaced by the functionality of c_string
|
||||
@@ -512,16 +513,14 @@ PyCArg_repr(PyCArgObject *self)
|
||||
case 'z':
|
||||
case 'Z':
|
||||
case 'P':
|
||||
- sprintf(buffer, "<cparam '%c' (%p)>",
|
||||
+ return PyString_FromFormat("<cparam '%c' (%p)>",
|
||||
self->tag, self->value.p);
|
||||
break;
|
||||
|
||||
default:
|
||||
- sprintf(buffer, "<cparam '%c' at %p>",
|
||||
+ return PyString_FromFormat("<cparam '%c' at %p>",
|
||||
self->tag, self);
|
||||
- break;
|
||||
}
|
||||
- return PyString_FromString(buffer);
|
||||
}
|
||||
|
||||
static PyMemberDef PyCArgType_members[] = {
|
||||
--
|
||||
cgit v1.2.3
|
||||
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
|
||||
index 978da73d74..3559eb95ca 100644
|
||||
--- a/Lib/py_compile.py
|
||||
+++ b/Lib/py_compile.py
|
||||
@@ -120,16 +120,27 @@ def compile(file, cfile=None, dfile=None, doraise=False):
|
||||
return
|
||||
if cfile is None:
|
||||
cfile = file + (__debug__ and 'c' or 'o')
|
||||
- with open(cfile, 'wb') as fc:
|
||||
- fc.write('\0\0\0\0')
|
||||
- if "DETERMINISTIC_BUILD" in os.environ:
|
||||
+ # Atomically write the pyc/pyo file. Issue #13146.
|
||||
+ # id() is used to generate a pseudo-random filename.
|
||||
+ path_tmp = '{}.{}'.format(cfile, id(cfile))
|
||||
+ try:
|
||||
+ with open(path_tmp, 'wb') as fc:
|
||||
fc.write('\0\0\0\0')
|
||||
- else:
|
||||
- wr_long(fc, timestamp)
|
||||
- marshal.dump(codeobject, fc)
|
||||
- fc.flush()
|
||||
- fc.seek(0, 0)
|
||||
- fc.write(MAGIC)
|
||||
+ if "DETERMINISTIC_BUILD" in os.environ:
|
||||
+ fc.write('\0\0\0\0')
|
||||
+ else:
|
||||
+ wr_long(fc, timestamp)
|
||||
+ marshal.dump(codeobject, fc)
|
||||
+ fc.flush()
|
||||
+ fc.seek(0, 0)
|
||||
+ fc.write(MAGIC)
|
||||
+ os.rename(path_tmp, cfile)
|
||||
+ except OSError:
|
||||
+ try:
|
||||
+ os.unlink(path_tmp)
|
||||
+ except OSError:
|
||||
+ pass
|
||||
+ raise
|
||||
|
||||
def main(args=None):
|
||||
"""Compile several source files.
|
||||
diff --git a/Python/import.c b/Python/import.c
|
||||
index 1e31d79279..f78a1efcf0 100644
|
||||
--- a/Python/import.c
|
||||
+++ b/Python/import.c
|
||||
@@ -951,6 +951,8 @@ static void
|
||||
write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat, time_t mtime)
|
||||
{
|
||||
FILE *fp;
|
||||
+ size_t cpathname_len;
|
||||
+ char *cpathname_tmp;
|
||||
#ifdef MS_WINDOWS /* since Windows uses different permissions */
|
||||
mode_t mode = srcstat->st_mode & ~S_IEXEC;
|
||||
/* Issue #6074: We ensure user write access, so we can delete it later
|
||||
@@ -963,11 +965,28 @@ write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat, t
|
||||
mode_t mode = srcstat->st_mode & ~S_IXUSR & ~S_IXGRP & ~S_IXOTH;
|
||||
#endif
|
||||
|
||||
+#ifdef MS_WINDOWS
|
||||
fp = open_exclusive(cpathname, mode);
|
||||
+#else
|
||||
+ /* Under POSIX, we first write to a tmp file and then take advantage
|
||||
+ of atomic renaming. */
|
||||
+ cpathname_len = strlen(cpathname);
|
||||
+ cpathname_tmp = PyMem_MALLOC(cpathname_len + 5);
|
||||
+ if (cpathname_tmp == NULL) {
|
||||
+ PyErr_Clear();
|
||||
+ return;
|
||||
+ }
|
||||
+ memcpy(cpathname_tmp, cpathname, cpathname_len);
|
||||
+ memcpy(cpathname_tmp + cpathname_len, ".tmp", 5);
|
||||
+ fp = open_exclusive(cpathname_tmp, mode);
|
||||
+#endif
|
||||
if (fp == NULL) {
|
||||
if (Py_VerboseFlag)
|
||||
PySys_WriteStderr(
|
||||
"# can't create %s\n", cpathname);
|
||||
+#ifndef MS_WINDOWS
|
||||
+ PyMem_FREE(cpathname_tmp);
|
||||
+#endif
|
||||
return;
|
||||
}
|
||||
PyMarshal_WriteLongToFile(pyc_magic, fp, Py_MARSHAL_VERSION);
|
||||
@@ -979,7 +998,12 @@ write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat, t
|
||||
PySys_WriteStderr("# can't write %s\n", cpathname);
|
||||
/* Don't keep partial file */
|
||||
fclose(fp);
|
||||
+#ifdef MS_WINDOWS
|
||||
(void) unlink(cpathname);
|
||||
+#else
|
||||
+ (void) unlink(cpathname_tmp);
|
||||
+ PyMem_FREE(cpathname_tmp);
|
||||
+#endif
|
||||
return;
|
||||
}
|
||||
/* Now write the true mtime (as a 32-bit field) */
|
||||
@@ -989,6 +1013,19 @@ write_compiled_module(PyCodeObject *co, char *cpathname, struct stat *srcstat, t
|
||||
PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION);
|
||||
fflush(fp);
|
||||
}
|
||||
+ /* Under POSIX, do an atomic rename */
|
||||
+#ifndef MS_WINDOWS
|
||||
+ if (rename(cpathname_tmp, cpathname)) {
|
||||
+ if (Py_VerboseFlag)
|
||||
+ PySys_WriteStderr("# can't write %s\n", cpathname);
|
||||
+ /* Don't keep tmp file */
|
||||
+ fclose(fp);
|
||||
+ (void) unlink(cpathname_tmp);
|
||||
+ PyMem_FREE(cpathname_tmp);
|
||||
+ return;
|
||||
+ }
|
||||
+ PyMem_FREE(cpathname_tmp);
|
||||
+#endif
|
||||
fclose(fp);
|
||||
if (Py_VerboseFlag)
|
||||
PySys_WriteStderr("# wrote %s\n", cpathname);
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
--- ./setup.py.orig 2018-04-29 15:47:33.000000000 -0700
|
||||
+++ ./setup.py 2018-11-11 09:41:58.097682221 -0800
|
||||
@@ -458,8 +458,6 @@
|
||||
if not cross_compiling:
|
||||
add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib')
|
||||
add_dir_to_list(self.compiler.include_dirs, '/usr/local/include')
|
||||
- if cross_compiling:
|
||||
- self.add_gcc_paths()
|
||||
self.add_multiarch_paths()
|
||||
|
||||
# Add paths specified in the environment variables LDFLAGS and
|
||||
@@ -517,7 +515,10 @@
|
||||
# be assumed that no additional -I,-L directives are needed.
|
||||
inc_dirs = self.compiler.include_dirs[:]
|
||||
lib_dirs = self.compiler.library_dirs[:]
|
||||
- if not cross_compiling:
|
||||
+ if cross_compiling:
|
||||
+ inc_dirs = []
|
||||
+ lib_dirs = []
|
||||
+ else:
|
||||
for d in (
|
||||
'/usr/include',
|
||||
):
|
||||
@@ -582,6 +584,8 @@ class PyBuildExt(build_ext):
|
||||
# Some modules that are normally always on:
|
||||
#exts.append( Extension('_weakref', ['_weakref.c']) )
|
||||
|
||||
+ self.compiler.library_dirs = lib_dirs + [ '.' ]
|
||||
+
|
||||
# array objects
|
||||
exts.append( Extension('array', ['arraymodule.c']) )
|
||||
|
||||
343
pkgs/development/interpreters/python/cpython/2.7/default.nix
Normal file
343
pkgs/development/interpreters/python/cpython/2.7/default.nix
Normal file
|
|
@ -0,0 +1,343 @@
|
|||
{ lib, stdenv, fetchurl, fetchpatch
|
||||
, bzip2
|
||||
, expat
|
||||
, libffi
|
||||
, gdbm
|
||||
, db
|
||||
, ncurses
|
||||
, openssl
|
||||
, readline
|
||||
, sqlite
|
||||
, tcl ? null, tk ? null, tix ? null, xlibsWrapper ? null, libX11 ? null, x11Support ? false
|
||||
, zlib
|
||||
, self
|
||||
, configd, coreutils
|
||||
, autoreconfHook
|
||||
, python-setup-hook
|
||||
# Some proprietary libs assume UCS2 unicode, especially on darwin :(
|
||||
, ucsEncoding ? 4
|
||||
# For the Python package set
|
||||
, packageOverrides ? (self: super: {})
|
||||
, pkgsBuildBuild
|
||||
, pkgsBuildHost
|
||||
, pkgsBuildTarget
|
||||
, pkgsHostHost
|
||||
, pkgsTargetTarget
|
||||
, sourceVersion
|
||||
, sha256
|
||||
, passthruFun
|
||||
, static ? stdenv.hostPlatform.isStatic
|
||||
, stripBytecode ? reproducibleBuild
|
||||
, rebuildBytecode ? true
|
||||
, reproducibleBuild ? false
|
||||
, enableOptimizations ? false
|
||||
, pythonAttr ? "python${sourceVersion.major}${sourceVersion.minor}"
|
||||
}:
|
||||
|
||||
assert x11Support -> tcl != null
|
||||
&& tk != null
|
||||
&& xlibsWrapper != null
|
||||
&& libX11 != null;
|
||||
|
||||
assert lib.assertMsg (enableOptimizations -> (!stdenv.cc.isClang))
|
||||
"Optimizations with clang are not supported. configure: error: llvm-profdata is required for a --enable-optimizations build but could not be found.";
|
||||
|
||||
assert lib.assertMsg (reproducibleBuild -> stripBytecode)
|
||||
"Deterministic builds require stripping bytecode.";
|
||||
|
||||
assert lib.assertMsg (reproducibleBuild -> (!enableOptimizations))
|
||||
"Deterministic builds are not achieved when optimizations are enabled.";
|
||||
|
||||
assert lib.assertMsg (reproducibleBuild -> (!rebuildBytecode))
|
||||
"Deterministic builds are not achieved when (default unoptimized) bytecode is created.";
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
buildPackages = pkgsBuildHost;
|
||||
inherit (passthru) pythonForBuild;
|
||||
|
||||
pythonForBuildInterpreter = if stdenv.hostPlatform == stdenv.buildPlatform then
|
||||
"$out/bin/python"
|
||||
else pythonForBuild.interpreter;
|
||||
|
||||
passthru = passthruFun rec {
|
||||
inherit self sourceVersion packageOverrides;
|
||||
implementation = "cpython";
|
||||
libPrefix = "python${pythonVersion}";
|
||||
executable = libPrefix;
|
||||
pythonVersion = with sourceVersion; "${major}.${minor}";
|
||||
sitePackages = "lib/${libPrefix}/site-packages";
|
||||
inherit hasDistutilsCxxPatch;
|
||||
pythonOnBuildForBuild = pkgsBuildBuild.${pythonAttr};
|
||||
pythonOnBuildForHost = pkgsBuildHost.${pythonAttr};
|
||||
pythonOnBuildForTarget = pkgsBuildTarget.${pythonAttr};
|
||||
pythonOnHostForHost = pkgsHostHost.${pythonAttr};
|
||||
pythonOnTargetForTarget = pkgsTargetTarget.${pythonAttr} or {};
|
||||
} // {
|
||||
inherit ucsEncoding;
|
||||
};
|
||||
|
||||
version = with sourceVersion; "${major}.${minor}.${patch}${suffix}";
|
||||
|
||||
src = fetchurl {
|
||||
url = with sourceVersion; "https://www.python.org/ftp/python/${major}.${minor}.${patch}/Python-${version}.tar.xz";
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
hasDistutilsCxxPatch = !(stdenv.cc.isGNU or false);
|
||||
patches =
|
||||
[ # Look in C_INCLUDE_PATH and LIBRARY_PATH for stuff.
|
||||
./search-path.patch
|
||||
|
||||
# Python recompiles a Python if the mtime stored *in* the
|
||||
# pyc/pyo file differs from the mtime of the source file. This
|
||||
# doesn't work in Nix because Nix changes the mtime of files in
|
||||
# the Nix store to 1. So treat that as a special case.
|
||||
./nix-store-mtime.patch
|
||||
|
||||
# patch python to put zero timestamp into pyc
|
||||
# if DETERMINISTIC_BUILD env var is set
|
||||
./deterministic-build.patch
|
||||
|
||||
# Fix python bug #27177 (https://bugs.python.org/issue27177)
|
||||
# The issue is that `match.group` only recognizes python integers
|
||||
# instead of everything that has `__index__`.
|
||||
# This bug was fixed upstream, but not backported to 2.7
|
||||
(fetchpatch {
|
||||
name = "re_match_index.patch";
|
||||
url = "https://bugs.python.org/file43084/re_match_index.patch";
|
||||
sha256 = "0l9rw6r5r90iybdkp3hhl2pf0h0s1izc68h5d3ywrm92pq32wz57";
|
||||
})
|
||||
|
||||
# Fix race-condition during pyc creation. Has a slight backwards
|
||||
# incompatible effect: pyc symlinks will now be overridden
|
||||
# (https://bugs.python.org/issue17222). Included in python >= 3.4,
|
||||
# backported in debian since 2013.
|
||||
# https://bugs.python.org/issue13146
|
||||
./atomic_pyc.patch
|
||||
|
||||
# Backport from CPython 3.8 of a good list of tests to run for PGO.
|
||||
./profile-task.patch
|
||||
|
||||
# Patch is likely to go away in the next release (if there is any)
|
||||
./CVE-2019-20907.patch
|
||||
|
||||
./CVE-2021-3177.patch
|
||||
|
||||
./CVE-2021-23336.patch
|
||||
|
||||
# The workaround is for unittests on Win64, which we don't support.
|
||||
# It does break aarch64-darwin, which we do support. See:
|
||||
# * https://bugs.python.org/issue35523
|
||||
# * https://github.com/python/cpython/commit/e6b247c8e524
|
||||
../3.7/no-win64-workaround.patch
|
||||
|
||||
] ++ optionals (x11Support && stdenv.isDarwin) [
|
||||
./use-correct-tcl-tk-on-darwin.patch
|
||||
] ++ optionals stdenv.isLinux [
|
||||
|
||||
# Disable the use of ldconfig in ctypes.util.find_library (since
|
||||
# ldconfig doesn't work on NixOS), and don't use
|
||||
# ctypes.util.find_library during the loading of the uuid module
|
||||
# (since it will do a futile invocation of gcc (!) to find
|
||||
# libuuid, slowing down program startup a lot).
|
||||
./no-ldconfig.patch
|
||||
|
||||
# Fix ctypes.util.find_library with gcc10.
|
||||
./find_library-gcc10.patch
|
||||
|
||||
] ++ optionals stdenv.hostPlatform.isCygwin [
|
||||
./2.5.2-ctypes-util-find_library.patch
|
||||
./2.5.2-tkinter-x11.patch
|
||||
./2.6.2-ssl-threads.patch
|
||||
./2.6.5-export-PySignal_SetWakeupFd.patch
|
||||
./2.6.5-FD_SETSIZE.patch
|
||||
./2.6.5-ncurses-abi6.patch
|
||||
./2.7.3-dbm.patch
|
||||
./2.7.3-dylib.patch
|
||||
./2.7.3-getpath-exe-extension.patch
|
||||
./2.7.3-no-libm.patch
|
||||
] ++ optionals hasDistutilsCxxPatch [
|
||||
|
||||
# Patch from http://bugs.python.org/issue1222585 adapted to work with
|
||||
# `patch -p1' and with a last hunk removed
|
||||
# Upstream distutils is calling C compiler to compile C++ code, which
|
||||
# only works for GCC and Apple Clang. This makes distutils to call C++
|
||||
# compiler when needed.
|
||||
./python-2.7-distutils-C++.patch
|
||||
] ++ optional (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
./cross-compile.patch
|
||||
];
|
||||
|
||||
preConfigure = ''
|
||||
# Purity.
|
||||
for i in /usr /sw /opt /pkg; do
|
||||
substituteInPlace ./setup.py --replace $i /no-such-path
|
||||
done
|
||||
'' + optionalString (stdenv ? cc && stdenv.cc.libc != null) ''
|
||||
for i in Lib/plat-*/regen; do
|
||||
substituteInPlace $i --replace /usr/include/ ${stdenv.cc.libc}/include/
|
||||
done
|
||||
'' + optionalString stdenv.isDarwin ''
|
||||
substituteInPlace configure --replace '`/usr/bin/arch`' '"i386"'
|
||||
substituteInPlace Lib/multiprocessing/__init__.py \
|
||||
--replace 'os.popen(comm)' 'os.popen("${coreutils}/bin/nproc")'
|
||||
'';
|
||||
|
||||
configureFlags = optionals enableOptimizations [
|
||||
"--enable-optimizations"
|
||||
] ++ optionals (!static) [
|
||||
"--enable-shared"
|
||||
] ++ [
|
||||
"--with-threads"
|
||||
"--enable-unicode=ucs${toString ucsEncoding}"
|
||||
] ++ optionals (stdenv.hostPlatform.isCygwin || stdenv.hostPlatform.isAarch64) [
|
||||
"--with-system-ffi"
|
||||
] ++ optionals stdenv.hostPlatform.isCygwin [
|
||||
"--with-system-expat"
|
||||
"ac_cv_func_bind_textdomain_codeset=yes"
|
||||
] ++ optionals stdenv.isDarwin [
|
||||
"--disable-toolbox-glue"
|
||||
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
"PYTHON_FOR_BUILD=${getBin buildPackages.python}/bin/python"
|
||||
"ac_cv_buggy_getaddrinfo=no"
|
||||
# Assume little-endian IEEE 754 floating point when cross compiling
|
||||
"ac_cv_little_endian_double=yes"
|
||||
"ac_cv_big_endian_double=no"
|
||||
"ac_cv_mixed_endian_double=no"
|
||||
"ac_cv_x87_double_rounding=yes"
|
||||
"ac_cv_tanh_preserves_zero_sign=yes"
|
||||
# Generally assume that things are present and work
|
||||
"ac_cv_posix_semaphores_enabled=yes"
|
||||
"ac_cv_broken_sem_getvalue=no"
|
||||
"ac_cv_wchar_t_signed=yes"
|
||||
"ac_cv_rshift_extends_sign=yes"
|
||||
"ac_cv_broken_nice=no"
|
||||
"ac_cv_broken_poll=no"
|
||||
"ac_cv_working_tzset=yes"
|
||||
"ac_cv_have_long_long_format=yes"
|
||||
"ac_cv_have_size_t_format=yes"
|
||||
"ac_cv_computed_gotos=yes"
|
||||
"ac_cv_file__dev_ptmx=yes"
|
||||
"ac_cv_file__dev_ptc=yes"
|
||||
]
|
||||
# Never even try to use lchmod on linux,
|
||||
# don't rely on detecting glibc-isms.
|
||||
++ optional stdenv.hostPlatform.isLinux "ac_cv_func_lchmod=no"
|
||||
++ optional static "LDFLAGS=-static";
|
||||
|
||||
strictDeps = true;
|
||||
buildInputs =
|
||||
optional (stdenv ? cc && stdenv.cc.libc != null) stdenv.cc.libc ++
|
||||
[ bzip2 openssl zlib ]
|
||||
++ optional (stdenv.hostPlatform.isCygwin || stdenv.hostPlatform.isAarch64) libffi
|
||||
++ optional stdenv.hostPlatform.isCygwin expat
|
||||
++ [ db gdbm ncurses sqlite readline ]
|
||||
++ optionals x11Support [ tcl tk xlibsWrapper libX11 ]
|
||||
++ optional (stdenv.isDarwin && configd != null) configd;
|
||||
nativeBuildInputs =
|
||||
[ autoreconfHook ]
|
||||
++ optionals (stdenv.hostPlatform != stdenv.buildPlatform)
|
||||
[ buildPackages.stdenv.cc buildPackages.python ];
|
||||
|
||||
mkPaths = paths: {
|
||||
C_INCLUDE_PATH = makeSearchPathOutput "dev" "include" paths;
|
||||
LIBRARY_PATH = makeLibraryPath paths;
|
||||
};
|
||||
|
||||
# Python 2.7 needs this
|
||||
crossCompileEnv = lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform)
|
||||
{ _PYTHON_HOST_PLATFORM = stdenv.hostPlatform.config; };
|
||||
|
||||
# Build the basic Python interpreter without modules that have
|
||||
# external dependencies.
|
||||
|
||||
in with passthru; stdenv.mkDerivation ({
|
||||
pname = "python";
|
||||
inherit version;
|
||||
|
||||
inherit src patches buildInputs nativeBuildInputs preConfigure configureFlags;
|
||||
|
||||
LDFLAGS = lib.optionalString (!stdenv.isDarwin) "-lgcc_s";
|
||||
inherit (mkPaths buildInputs) C_INCLUDE_PATH LIBRARY_PATH;
|
||||
|
||||
NIX_CFLAGS_COMPILE = optionalString (stdenv.targetPlatform.system == "x86_64-darwin") "-msse2"
|
||||
+ optionalString stdenv.hostPlatform.isMusl " -DTHREAD_STACK_SIZE=0x100000";
|
||||
DETERMINISTIC_BUILD = 1;
|
||||
|
||||
setupHook = python-setup-hook sitePackages;
|
||||
|
||||
postPatch = optionalString (x11Support && (tix != null)) ''
|
||||
substituteInPlace "Lib/lib-tk/Tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
|
||||
'';
|
||||
|
||||
postInstall =
|
||||
''
|
||||
# needed for some packages, especially packages that backport
|
||||
# functionality to 2.x from 3.x
|
||||
for item in $out/lib/${libPrefix}/test/*; do
|
||||
if [[ "$item" != */test_support.py*
|
||||
&& "$item" != */test/support
|
||||
&& "$item" != */test/regrtest.py* ]]; then
|
||||
rm -rf "$item"
|
||||
else
|
||||
echo $item
|
||||
fi
|
||||
done
|
||||
touch $out/lib/${libPrefix}/test/__init__.py
|
||||
ln -s $out/lib/${libPrefix}/pdb.py $out/bin/pdb
|
||||
ln -s $out/lib/${libPrefix}/pdb.py $out/bin/pdb${sourceVersion.major}.${sourceVersion.minor}
|
||||
ln -s $out/share/man/man1/{python2.7.1.gz,python.1.gz}
|
||||
|
||||
rm "$out"/lib/python*/plat-*/regen # refers to glibc.dev
|
||||
|
||||
# Determinism: Windows installers were not deterministic.
|
||||
# We're also not interested in building Windows installers.
|
||||
find "$out" -name 'wininst*.exe' | xargs -r rm -f
|
||||
'' + optionalString stripBytecode ''
|
||||
# Determinism: deterministic bytecode
|
||||
# First we delete all old bytecode.
|
||||
find $out -name "*.pyc" -delete
|
||||
'' + optionalString rebuildBytecode ''
|
||||
# We build 3 levels of optimized bytecode. Note the default level, without optimizations,
|
||||
# is not reproducible yet. https://bugs.python.org/issue29708
|
||||
# Not creating bytecode will result in a large performance loss however, so we do build it.
|
||||
find $out -name "*.py" | ${pythonForBuildInterpreter} -m compileall -q -f -x "lib2to3" -i -
|
||||
find $out -name "*.py" | ${pythonForBuildInterpreter} -O -m compileall -q -f -x "lib2to3" -i -
|
||||
find $out -name "*.py" | ${pythonForBuildInterpreter} -OO -m compileall -q -f -x "lib2to3" -i -
|
||||
'' + optionalString stdenv.hostPlatform.isCygwin ''
|
||||
cp libpython2.7.dll.a $out/lib
|
||||
'';
|
||||
|
||||
inherit passthru;
|
||||
|
||||
postFixup = ''
|
||||
# Include a sitecustomize.py file. Note it causes an error when it's in postInstall with 2.7.
|
||||
cp ${../../sitecustomize.py} $out/${sitePackages}/sitecustomize.py
|
||||
'';
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
doCheck = false; # expensive, and fails
|
||||
|
||||
meta = {
|
||||
homepage = "http://python.org";
|
||||
description = "A high-level dynamically-typed programming language";
|
||||
longDescription = ''
|
||||
Python is a remarkably powerful dynamic programming language that
|
||||
is used in a wide variety of application domains. Some of its key
|
||||
distinguishing features include: clear, readable syntax; strong
|
||||
introspection capabilities; intuitive object orientation; natural
|
||||
expression of procedural code; full modularity, supporting
|
||||
hierarchical packages; exception-based error handling; and very
|
||||
high level dynamic data types.
|
||||
'';
|
||||
license = lib.licenses.psfl;
|
||||
platforms = lib.platforms.all;
|
||||
maintainers = with lib.maintainers; [ fridh ];
|
||||
# Higher priority than Python 3.x so that `/bin/python` points to `/bin/python2`
|
||||
# in case both 2 and 3 are installed.
|
||||
priority = -100;
|
||||
};
|
||||
} // crossCompileEnv)
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
diff -ur orig/Lib/py_compile.py new/Lib/py_compile.py
|
||||
--- orig/Lib/py_compile.py
|
||||
+++ new/Lib/py_compile.py
|
||||
@@ -122,7 +122,10 @@
|
||||
cfile = file + (__debug__ and 'c' or 'o')
|
||||
with open(cfile, 'wb') as fc:
|
||||
fc.write('\0\0\0\0')
|
||||
- wr_long(fc, timestamp)
|
||||
+ if "DETERMINISTIC_BUILD" in os.environ:
|
||||
+ fc.write('\0\0\0\0')
|
||||
+ else:
|
||||
+ wr_long(fc, timestamp)
|
||||
marshal.dump(codeobject, fc)
|
||||
fc.flush()
|
||||
fc.seek(0, 0)
|
||||
diff -ur orig/Python/import.c new/Python/import.c
|
||||
--- orig/Python/import.c
|
||||
+++ new/Python/import.c
|
||||
@@ -939,10 +939,12 @@
|
||||
return;
|
||||
}
|
||||
/* Now write the true mtime (as a 32-bit field) */
|
||||
- fseek(fp, 4L, 0);
|
||||
- assert(mtime <= 0xFFFFFFFF);
|
||||
- PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION);
|
||||
- fflush(fp);
|
||||
+ if (Py_GETENV("DETERMINISTIC_BUILD") == NULL) {
|
||||
+ fseek(fp, 4L, 0);
|
||||
+ assert(mtime <= 0xFFFFFFFF);
|
||||
+ PyMarshal_WriteLongToFile((long)mtime, fp, Py_MARSHAL_VERSION);
|
||||
+ fflush(fp);
|
||||
+ }
|
||||
fclose(fp);
|
||||
if (Py_VerboseFlag)
|
||||
PySys_WriteStderr("# wrote %s\n", cpathname);
|
||||
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
Backport https://github.com/python/cpython/commit/82df3b3071bb003247c33eac4670775e9883c994
|
||||
and https://github.com/python/cpython/commit/27ac19cca2c639caaf6fedf3632fe6beb265f24f
|
||||
|
||||
Fixes the check phase of python2Packages.cffi.
|
||||
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -87,6 +87,12 @@ elif os.name == "posix":
|
||||
# Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
|
||||
import re, tempfile, errno
|
||||
|
||||
+ def _is_elf(filename):
|
||||
+ "Return True if the given file is an ELF file"
|
||||
+ elf_header = b'\x7fELF'
|
||||
+ with open(filename, 'rb') as thefile:
|
||||
+ return thefile.read(4) == elf_header
|
||||
+
|
||||
def _findLib_gcc(name):
|
||||
# Run GCC's linker with the -t (aka --trace) option and examine the
|
||||
# library name it prints out. The GCC command will fail because we
|
||||
@@ -110,10 +116,17 @@ elif os.name == "posix":
|
||||
# the normal behaviour of GCC if linking fails
|
||||
if e.errno != errno.ENOENT:
|
||||
raise
|
||||
- res = re.search(expr, trace)
|
||||
+ res = re.findall(expr, trace)
|
||||
if not res:
|
||||
return None
|
||||
- return res.group(0)
|
||||
+
|
||||
+ for file in res:
|
||||
+ # Check if the given file is an elf file: gcc can report
|
||||
+ # some files that are linker scripts and not actual
|
||||
+ # shared objects. See bpo-41976 for more details
|
||||
+ if not _is_elf(file):
|
||||
+ continue
|
||||
+ return file
|
||||
|
||||
|
||||
if sys.platform == "sunos5":
|
||||
@@ -237,8 +250,37 @@ elif os.name == "posix":
|
||||
def _findSoname_ldconfig(name):
|
||||
return None
|
||||
|
||||
+ def _findLib_ld(name):
|
||||
+ # See issue #9998 for why this is needed
|
||||
+ expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
|
||||
+ cmd = ['ld', '-t']
|
||||
+ libpath = os.environ.get('LD_LIBRARY_PATH')
|
||||
+ if libpath:
|
||||
+ for d in libpath.split(':'):
|
||||
+ cmd.extend(['-L', d])
|
||||
+ cmd.extend(['-o', os.devnull, '-l%s' % name])
|
||||
+ result = None
|
||||
+ try:
|
||||
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||
+ stderr=subprocess.PIPE,
|
||||
+ universal_newlines=True)
|
||||
+ out, _ = p.communicate()
|
||||
+ res = re.findall(expr, out)
|
||||
+ for file in res:
|
||||
+ # Check if the given file is an elf file: gcc can report
|
||||
+ # some files that are linker scripts and not actual
|
||||
+ # shared objects. See bpo-41976 for more details
|
||||
+ if not _is_elf(file):
|
||||
+ continue
|
||||
+ return file
|
||||
+ except Exception:
|
||||
+ pass # result will be None
|
||||
+ return result
|
||||
+
|
||||
def find_library(name):
|
||||
- return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name))
|
||||
+ # See issue #9998
|
||||
+ return _findSoname_ldconfig(name) or \
|
||||
+ _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
|
||||
|
||||
################################################################
|
||||
# test code
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
diff -ru -x '*~' Python-2.7.1-orig/Python/import.c Python-2.7.1/Python/import.c
|
||||
--- Python-2.7.1-orig/Python/import.c 2010-05-20 20:37:55.000000000 +0200
|
||||
+++ Python-2.7.1/Python/import.c 2011-01-04 15:55:11.000000000 +0100
|
||||
@@ -751,7 +751,7 @@
|
||||
return NULL;
|
||||
}
|
||||
pyc_mtime = PyMarshal_ReadLongFromFile(fp);
|
||||
- if (pyc_mtime != mtime) {
|
||||
+ if (pyc_mtime != mtime && mtime != 1) {
|
||||
if (Py_VerboseFlag)
|
||||
PySys_WriteStderr("# %s has bad mtime\n", cpathname);
|
||||
fclose(fp);
|
||||
|
|
@ -0,0 +1,117 @@
|
|||
From 6b0f329a9f37110020ca02b35c8125391ef282b7 Mon Sep 17 00:00:00 2001
|
||||
From: Frederik Rietdijk <fridh@fridh.nl>
|
||||
Date: Sat, 24 Dec 2016 15:56:10 +0100
|
||||
Subject: [PATCH] no ldconfig
|
||||
|
||||
---
|
||||
Lib/ctypes/util.py | 35 +----------------------------------
|
||||
Lib/uuid.py | 47 -----------------------------------------------
|
||||
2 files changed, 1 insertion(+), 81 deletions(-)
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index ab10ec5..f253e34 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -235,40 +235,7 @@ elif os.name == "posix":
|
||||
else:
|
||||
|
||||
def _findSoname_ldconfig(name):
|
||||
- import struct
|
||||
- if struct.calcsize('l') == 4:
|
||||
- machine = os.uname()[4] + '-32'
|
||||
- else:
|
||||
- machine = os.uname()[4] + '-64'
|
||||
- mach_map = {
|
||||
- 'x86_64-64': 'libc6,x86-64',
|
||||
- 'ppc64-64': 'libc6,64bit',
|
||||
- 'sparc64-64': 'libc6,64bit',
|
||||
- 's390x-64': 'libc6,64bit',
|
||||
- 'ia64-64': 'libc6,IA-64',
|
||||
- }
|
||||
- abi_type = mach_map.get(machine, 'libc6')
|
||||
-
|
||||
- # XXX assuming GLIBC's ldconfig (with option -p)
|
||||
- expr = r'\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type)
|
||||
-
|
||||
- env = dict(os.environ)
|
||||
- env['LC_ALL'] = 'C'
|
||||
- env['LANG'] = 'C'
|
||||
- null = open(os.devnull, 'wb')
|
||||
- try:
|
||||
- with null:
|
||||
- p = subprocess.Popen(['/sbin/ldconfig', '-p'],
|
||||
- stderr=null,
|
||||
- stdout=subprocess.PIPE,
|
||||
- env=env)
|
||||
- except OSError: # E.g. command not found
|
||||
- return None
|
||||
- [data, _] = p.communicate()
|
||||
- res = re.search(expr, data)
|
||||
- if not res:
|
||||
- return None
|
||||
- return res.group(1)
|
||||
+ return None
|
||||
|
||||
def find_library(name):
|
||||
return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name))
|
||||
diff --git a/Lib/uuid.py b/Lib/uuid.py
|
||||
index 7432032..05eeee5 100644
|
||||
--- a/Lib/uuid.py
|
||||
+++ b/Lib/uuid.py
|
||||
@@ -441,53 +441,6 @@ def _netbios_getnode():
|
||||
|
||||
# If ctypes is available, use it to find system routines for UUID generation.
|
||||
_uuid_generate_time = _UuidCreate = None
|
||||
-try:
|
||||
- import ctypes, ctypes.util
|
||||
- import sys
|
||||
-
|
||||
- # The uuid_generate_* routines are provided by libuuid on at least
|
||||
- # Linux and FreeBSD, and provided by libc on Mac OS X.
|
||||
- _libnames = ['uuid']
|
||||
- if not sys.platform.startswith('win'):
|
||||
- _libnames.append('c')
|
||||
- for libname in _libnames:
|
||||
- try:
|
||||
- lib = ctypes.CDLL(ctypes.util.find_library(libname))
|
||||
- except:
|
||||
- continue
|
||||
- if hasattr(lib, 'uuid_generate_time'):
|
||||
- _uuid_generate_time = lib.uuid_generate_time
|
||||
- break
|
||||
- del _libnames
|
||||
-
|
||||
- # The uuid_generate_* functions are broken on MacOS X 10.5, as noted
|
||||
- # in issue #8621 the function generates the same sequence of values
|
||||
- # in the parent process and all children created using fork (unless
|
||||
- # those children use exec as well).
|
||||
- #
|
||||
- # Assume that the uuid_generate functions are broken from 10.5 onward,
|
||||
- # the test can be adjusted when a later version is fixed.
|
||||
- if sys.platform == 'darwin':
|
||||
- import os
|
||||
- if int(os.uname()[2].split('.')[0]) >= 9:
|
||||
- _uuid_generate_time = None
|
||||
-
|
||||
- # On Windows prior to 2000, UuidCreate gives a UUID containing the
|
||||
- # hardware address. On Windows 2000 and later, UuidCreate makes a
|
||||
- # random UUID and UuidCreateSequential gives a UUID containing the
|
||||
- # hardware address. These routines are provided by the RPC runtime.
|
||||
- # NOTE: at least on Tim's WinXP Pro SP2 desktop box, while the last
|
||||
- # 6 bytes returned by UuidCreateSequential are fixed, they don't appear
|
||||
- # to bear any relationship to the MAC address of any network device
|
||||
- # on the box.
|
||||
- try:
|
||||
- lib = ctypes.windll.rpcrt4
|
||||
- except:
|
||||
- lib = None
|
||||
- _UuidCreate = getattr(lib, 'UuidCreateSequential',
|
||||
- getattr(lib, 'UuidCreate', None))
|
||||
-except:
|
||||
- pass
|
||||
|
||||
def _unixdll_getnode():
|
||||
"""Get the hardware address on Unix using ctypes."""
|
||||
--
|
||||
2.11.0
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Backport from CPython 3.8 of a good list of tests to run for PGO.
|
||||
|
||||
Upstream commit:
|
||||
https://github.com/python/cpython/commit/4e16a4a31
|
||||
|
||||
Upstream discussion:
|
||||
https://bugs.python.org/issue36044
|
||||
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index 00fdd21ce..713dc1e53 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -259,7 +259,7 @@ TCLTK_LIBS=
|
||||
# The task to run while instrumented when building the profile-opt target.
|
||||
# We exclude unittests with -x that take a rediculious amount of time to
|
||||
# run in the instrumented training build or do not provide much value.
|
||||
-PROFILE_TASK=-m test.regrtest --pgo -x test_asyncore test_gdb test_multiprocessing test_subprocess
|
||||
+PROFILE_TASK=-m test.regrtest --pgo test_array test_base64 test_binascii test_binop test_bisect test_bytes test_bz2 test_cmath test_codecs test_collections test_complex test_dataclasses test_datetime test_decimal test_difflib test_embed test_float test_fstring test_functools test_generators test_hashlib test_heapq test_int test_itertools test_json test_long test_lzma test_math test_memoryview test_operator test_ordered_dict test_pickle test_pprint test_re test_set test_sqlite test_statistics test_struct test_tabnanny test_time test_unicode test_xml_etree test_xml_etree_c
|
||||
|
||||
# report files for gcov / lcov coverage report
|
||||
COVERAGE_INFO= $(abs_builddir)/coverage.info
|
||||
|
|
@ -0,0 +1,259 @@
|
|||
--- a/Lib/distutils/cygwinccompiler.py
|
||||
+++ b/Lib/distutils/cygwinccompiler.py
|
||||
@@ -117,8 +117,10 @@
|
||||
# dllwrap 2.10.90 is buggy
|
||||
if self.ld_version >= "2.10.90":
|
||||
self.linker_dll = "gcc"
|
||||
+ self.linker_dll_cxx = "g++"
|
||||
else:
|
||||
self.linker_dll = "dllwrap"
|
||||
+ self.linker_dll_cxx = "dllwrap"
|
||||
|
||||
# ld_version >= "2.13" support -shared so use it instead of
|
||||
# -mdll -static
|
||||
@@ -132,9 +134,13 @@
|
||||
self.set_executables(compiler='gcc -mcygwin -O -Wall',
|
||||
compiler_so='gcc -mcygwin -mdll -O -Wall',
|
||||
compiler_cxx='g++ -mcygwin -O -Wall',
|
||||
+ compiler_so_cxx='g++ -mcygwin -mdll -O -Wall',
|
||||
linker_exe='gcc -mcygwin',
|
||||
linker_so=('%s -mcygwin %s' %
|
||||
- (self.linker_dll, shared_option)))
|
||||
+ (self.linker_dll, shared_option)),
|
||||
+ linker_exe_cxx='g++ -mcygwin',
|
||||
+ linker_so_cxx=('%s -mcygwin %s' %
|
||||
+ (self.linker_dll_cxx, shared_option)))
|
||||
|
||||
# cygwin and mingw32 need different sets of libraries
|
||||
if self.gcc_version == "2.91.57":
|
||||
@@ -160,8 +166,12 @@
|
||||
raise CompileError, msg
|
||||
else: # for other files use the C-compiler
|
||||
try:
|
||||
- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||
- extra_postargs)
|
||||
+ if self.detect_language(src) == 'c++':
|
||||
+ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
+ else:
|
||||
+ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
except DistutilsExecError, msg:
|
||||
raise CompileError, msg
|
||||
|
||||
@@ -327,9 +337,14 @@
|
||||
self.set_executables(compiler='gcc%s -O -Wall' % no_cygwin,
|
||||
compiler_so='gcc%s -mdll -O -Wall' % no_cygwin,
|
||||
compiler_cxx='g++%s -O -Wall' % no_cygwin,
|
||||
+ compiler_so_cxx='g++%s -mdll -O -Wall' % no_cygwin,
|
||||
linker_exe='gcc%s' % no_cygwin,
|
||||
linker_so='%s%s %s %s'
|
||||
% (self.linker_dll, no_cygwin,
|
||||
+ shared_option, entry_point),
|
||||
+ linker_exe_cxx='g++%s' % no_cygwin,
|
||||
+ linker_so_cxx='%s%s %s %s'
|
||||
+ % (self.linker_dll_cxx, no_cygwin,
|
||||
shared_option, entry_point))
|
||||
# Maybe we should also append -mthreads, but then the finished
|
||||
# dlls need another dll (mingwm10.dll see Mingw32 docs)
|
||||
--- a/Lib/distutils/emxccompiler.py
|
||||
+++ b/Lib/distutils/emxccompiler.py
|
||||
@@ -65,8 +65,12 @@
|
||||
# XXX optimization, warnings etc. should be customizable.
|
||||
self.set_executables(compiler='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
|
||||
compiler_so='gcc -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
|
||||
+ compiler_cxx='g++ -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
|
||||
+ compiler_so_cxx='g++ -Zomf -Zmt -O3 -fomit-frame-pointer -mprobe -Wall',
|
||||
linker_exe='gcc -Zomf -Zmt -Zcrtdll',
|
||||
- linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll')
|
||||
+ linker_so='gcc -Zomf -Zmt -Zcrtdll -Zdll',
|
||||
+ linker_exe_cxx='g++ -Zomf -Zmt -Zcrtdll',
|
||||
+ linker_so_cxx='g++ -Zomf -Zmt -Zcrtdll -Zdll')
|
||||
|
||||
# want the gcc library statically linked (so that we don't have
|
||||
# to distribute a version dependent on the compiler we have)
|
||||
@@ -83,8 +87,12 @@
|
||||
raise CompileError, msg
|
||||
else: # for other files use the C-compiler
|
||||
try:
|
||||
- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||
- extra_postargs)
|
||||
+ if self.detect_language(src) == 'c++':
|
||||
+ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
+ else:
|
||||
+ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
except DistutilsExecError, msg:
|
||||
raise CompileError, msg
|
||||
|
||||
--- a/Lib/distutils/sysconfig.py
|
||||
+++ b/Lib/distutils/sysconfig.py
|
||||
@@ -170,10 +170,12 @@
|
||||
_osx_support.customize_compiler(_config_vars)
|
||||
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
|
||||
|
||||
- (cc, cxx, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
|
||||
- get_config_vars('CC', 'CXX', 'CFLAGS',
|
||||
- 'CCSHARED', 'LDSHARED', 'SO', 'AR',
|
||||
- 'ARFLAGS')
|
||||
+ (cc, cxx, ccshared, ldshared, ldcxxshared, so_ext, ar, ar_flags) = \
|
||||
+ get_config_vars('CC', 'CXX', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED',
|
||||
+ 'SO', 'AR', 'ARFLAGS')
|
||||
+
|
||||
+ cflags = ''
|
||||
+ cxxflags = ''
|
||||
|
||||
if 'CC' in os.environ:
|
||||
newcc = os.environ['CC']
|
||||
@@ -188,19 +190,27 @@
|
||||
cxx = os.environ['CXX']
|
||||
if 'LDSHARED' in os.environ:
|
||||
ldshared = os.environ['LDSHARED']
|
||||
+ if 'LDCXXSHARED' in os.environ:
|
||||
+ ldcxxshared = os.environ['LDCXXSHARED']
|
||||
if 'CPP' in os.environ:
|
||||
cpp = os.environ['CPP']
|
||||
else:
|
||||
cpp = cc + " -E" # not always
|
||||
if 'LDFLAGS' in os.environ:
|
||||
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['LDFLAGS']
|
||||
if 'CFLAGS' in os.environ:
|
||||
cflags = cflags + ' ' + os.environ['CFLAGS']
|
||||
ldshared = ldshared + ' ' + os.environ['CFLAGS']
|
||||
+ if 'CXXFLAGS' in os.environ:
|
||||
+ cxxflags = os.environ['CXXFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS']
|
||||
if 'CPPFLAGS' in os.environ:
|
||||
cpp = cpp + ' ' + os.environ['CPPFLAGS']
|
||||
cflags = cflags + ' ' + os.environ['CPPFLAGS']
|
||||
+ cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS']
|
||||
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS']
|
||||
if 'AR' in os.environ:
|
||||
ar = os.environ['AR']
|
||||
if 'ARFLAGS' in os.environ:
|
||||
@@ -209,13 +219,17 @@
|
||||
archiver = ar + ' ' + ar_flags
|
||||
|
||||
cc_cmd = cc + ' ' + cflags
|
||||
+ cxx_cmd = cxx + ' ' + cxxflags
|
||||
compiler.set_executables(
|
||||
preprocessor=cpp,
|
||||
compiler=cc_cmd,
|
||||
compiler_so=cc_cmd + ' ' + ccshared,
|
||||
- compiler_cxx=cxx,
|
||||
+ compiler_cxx=cxx_cmd,
|
||||
+ compiler_so_cxx=cxx_cmd + ' ' + ccshared,
|
||||
linker_so=ldshared,
|
||||
linker_exe=cc,
|
||||
+ linker_so_cxx=ldcxxshared,
|
||||
+ linker_exe_cxx=cxx,
|
||||
archiver=archiver)
|
||||
|
||||
compiler.shared_lib_extension = so_ext
|
||||
--- a/Lib/distutils/unixccompiler.py
|
||||
+++ b/Lib/distutils/unixccompiler.py
|
||||
@@ -55,14 +55,17 @@
|
||||
# are pretty generic; they will probably have to be set by an outsider
|
||||
# (eg. using information discovered by the sysconfig about building
|
||||
# Python extensions).
|
||||
- executables = {'preprocessor' : None,
|
||||
- 'compiler' : ["cc"],
|
||||
- 'compiler_so' : ["cc"],
|
||||
- 'compiler_cxx' : ["cc"],
|
||||
- 'linker_so' : ["cc", "-shared"],
|
||||
- 'linker_exe' : ["cc"],
|
||||
- 'archiver' : ["ar", "-cr"],
|
||||
- 'ranlib' : None,
|
||||
+ executables = {'preprocessor' : None,
|
||||
+ 'compiler' : ["cc"],
|
||||
+ 'compiler_so' : ["cc"],
|
||||
+ 'compiler_cxx' : ["c++"],
|
||||
+ 'compiler_so_cxx' : ["c++"],
|
||||
+ 'linker_so' : ["cc", "-shared"],
|
||||
+ 'linker_exe' : ["cc"],
|
||||
+ 'linker_so_cxx' : ["c++", "-shared"],
|
||||
+ 'linker_exe_cxx' : ["c++"],
|
||||
+ 'archiver' : ["ar", "-cr"],
|
||||
+ 'ranlib' : None,
|
||||
}
|
||||
|
||||
if sys.platform[:6] == "darwin":
|
||||
@@ -112,12 +115,19 @@
|
||||
|
||||
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
||||
compiler_so = self.compiler_so
|
||||
+ compiler_so_cxx = self.compiler_so_cxx
|
||||
if sys.platform == 'darwin':
|
||||
compiler_so = _osx_support.compiler_fixup(compiler_so,
|
||||
cc_args + extra_postargs)
|
||||
+ compiler_so_cxx = _osx_support.compiler_fixup(compiler_so_cxx,
|
||||
+ cc_args + extra_postargs)
|
||||
try:
|
||||
- self.spawn(compiler_so + cc_args + [src, '-o', obj] +
|
||||
- extra_postargs)
|
||||
+ if self.detect_language(src) == 'c++':
|
||||
+ self.spawn(compiler_so_cxx + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
+ else:
|
||||
+ self.spawn(compiler_so + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
except DistutilsExecError, msg:
|
||||
raise CompileError, msg
|
||||
|
||||
@@ -174,23 +184,16 @@
|
||||
ld_args.extend(extra_postargs)
|
||||
self.mkpath(os.path.dirname(output_filename))
|
||||
try:
|
||||
- if target_desc == CCompiler.EXECUTABLE:
|
||||
- linker = self.linker_exe[:]
|
||||
+ if target_lang == "c++":
|
||||
+ if target_desc == CCompiler.EXECUTABLE:
|
||||
+ linker = self.linker_exe_cxx[:]
|
||||
+ else:
|
||||
+ linker = self.linker_so_cxx[:]
|
||||
else:
|
||||
- linker = self.linker_so[:]
|
||||
- if target_lang == "c++" and self.compiler_cxx:
|
||||
- # skip over environment variable settings if /usr/bin/env
|
||||
- # is used to set up the linker's environment.
|
||||
- # This is needed on OSX. Note: this assumes that the
|
||||
- # normal and C++ compiler have the same environment
|
||||
- # settings.
|
||||
- i = 0
|
||||
- if os.path.basename(linker[0]) == "env":
|
||||
- i = 1
|
||||
- while '=' in linker[i]:
|
||||
- i = i + 1
|
||||
-
|
||||
- linker[i] = self.compiler_cxx[i]
|
||||
+ if target_desc == CCompiler.EXECUTABLE:
|
||||
+ linker = self.linker_exe[:]
|
||||
+ else:
|
||||
+ linker = self.linker_so[:]
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
linker = _osx_support.compiler_fixup(linker, ld_args)
|
||||
--- a/Lib/_osx_support.py
|
||||
+++ b/Lib/_osx_support.py
|
||||
@@ -14,13 +14,13 @@
|
||||
# configuration variables that may contain universal build flags,
|
||||
# like "-arch" or "-isdkroot", that may need customization for
|
||||
# the user environment
|
||||
-_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS',
|
||||
- 'BLDSHARED', 'LDSHARED', 'CC', 'CXX',
|
||||
- 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
|
||||
- 'PY_CORE_CFLAGS')
|
||||
+_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CPPFLAGS',
|
||||
+ 'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'LDCXXSHARED',
|
||||
+ 'CC', 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS',
|
||||
+ 'PY_CPPFLAGS', 'PY_CORE_CFLAGS')
|
||||
|
||||
# configuration variables that may contain compiler calls
|
||||
-_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX')
|
||||
+_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'LDCXXSHARED', 'CC', 'CXX')
|
||||
|
||||
# prefix added to original configuration variable names
|
||||
_INITPRE = '_OSX_SUPPORT_INITIAL_'
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
diff -rc Python-2.4.4-orig/setup.py Python-2.4.4/setup.py
|
||||
*** Python-2.4.4-orig/setup.py 2006-10-08 19:41:25.000000000 +0200
|
||||
--- Python-2.4.4/setup.py 2007-05-27 16:04:54.000000000 +0200
|
||||
***************
|
||||
*** 279,288 ****
|
||||
# Check for AtheOS which has libraries in non-standard locations
|
||||
if platform == 'atheos':
|
||||
lib_dirs += ['/system/libs', '/atheos/autolnk/lib']
|
||||
- lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep)
|
||||
inc_dirs += ['/system/include', '/atheos/autolnk/include']
|
||||
- inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)
|
||||
|
||||
# OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb)
|
||||
if platform in ['osf1', 'unixware7', 'openunix8']:
|
||||
lib_dirs += ['/usr/ccs/lib']
|
||||
--- 279,289 ----
|
||||
# Check for AtheOS which has libraries in non-standard locations
|
||||
if platform == 'atheos':
|
||||
lib_dirs += ['/system/libs', '/atheos/autolnk/lib']
|
||||
inc_dirs += ['/system/include', '/atheos/autolnk/include']
|
||||
|
||||
+ lib_dirs += os.getenv('LIBRARY_PATH', '').split(os.pathsep)
|
||||
+ inc_dirs += os.getenv('C_INCLUDE_PATH', '').split(os.pathsep)
|
||||
+
|
||||
# OSF/1 and Unixware have some stuff in /usr/ccs/lib (like -ldb)
|
||||
if platform in ['osf1', 'unixware7', 'openunix8']:
|
||||
lib_dirs += ['/usr/ccs/lib']
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
diff --git a/setup.py b/setup.py
|
||||
index 2779658..902d0eb 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext):
|
||||
# Rather than complicate the code below, detecting and building
|
||||
# AquaTk is a separate method. Only one Tkinter will be built on
|
||||
# Darwin - either AquaTk, if it is found, or X11 based Tk.
|
||||
- if (host_platform == 'darwin' and
|
||||
- self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
|
||||
- return
|
||||
|
||||
# Assume we haven't found any of the libraries or include files
|
||||
# The versions with dots are used on Unix, and the versions without
|
||||
@@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext):
|
||||
if dir not in include_dirs:
|
||||
include_dirs.append(dir)
|
||||
|
||||
- # Check for various platform-specific directories
|
||||
- if host_platform == 'sunos5':
|
||||
- include_dirs.append('/usr/openwin/include')
|
||||
- added_lib_dirs.append('/usr/openwin/lib')
|
||||
- elif os.path.exists('/usr/X11R6/include'):
|
||||
- include_dirs.append('/usr/X11R6/include')
|
||||
- added_lib_dirs.append('/usr/X11R6/lib64')
|
||||
- added_lib_dirs.append('/usr/X11R6/lib')
|
||||
- elif os.path.exists('/usr/X11R5/include'):
|
||||
- include_dirs.append('/usr/X11R5/include')
|
||||
- added_lib_dirs.append('/usr/X11R5/lib')
|
||||
- else:
|
||||
- # Assume default location for X11
|
||||
- include_dirs.append('/usr/X11/include')
|
||||
- added_lib_dirs.append('/usr/X11/lib')
|
||||
-
|
||||
# If Cygwin, then verify that X is installed before proceeding
|
||||
if host_platform == 'cygwin':
|
||||
x11_inc = find_file('X11/Xlib.h', [], include_dirs)
|
||||
@@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext):
|
||||
if host_platform in ['aix3', 'aix4']:
|
||||
libs.append('ld')
|
||||
|
||||
- # Finally, link with the X11 libraries (not appropriate on cygwin)
|
||||
- if host_platform != "cygwin":
|
||||
- libs.append('X11')
|
||||
-
|
||||
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
|
||||
define_macros=[('WITH_APPINIT', 1)] + defs,
|
||||
include_dirs = include_dirs,
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
From 084c6dd6352077e64f10cf7aa168f95d800f3819 Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Ringer <jonringer117@gmail.com>
|
||||
Date: Mon, 9 Nov 2020 10:24:35 -0800
|
||||
Subject: [PATCH] CPython: Don't use ldconfig
|
||||
|
||||
---
|
||||
Lib/ctypes/util.py | 77 ++--------------------------------------------
|
||||
1 file changed, 2 insertions(+), 75 deletions(-)
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index 0c2510e..7fb98af 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -100,53 +100,7 @@ elif os.name == "posix":
|
||||
return thefile.read(4) == elf_header
|
||||
|
||||
def _findLib_gcc(name):
|
||||
- # Run GCC's linker with the -t (aka --trace) option and examine the
|
||||
- # library name it prints out. The GCC command will fail because we
|
||||
- # haven't supplied a proper program with main(), but that does not
|
||||
- # matter.
|
||||
- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name))
|
||||
-
|
||||
- c_compiler = shutil.which('gcc')
|
||||
- if not c_compiler:
|
||||
- c_compiler = shutil.which('cc')
|
||||
- if not c_compiler:
|
||||
- # No C compiler available, give up
|
||||
- return None
|
||||
-
|
||||
- temp = tempfile.NamedTemporaryFile()
|
||||
- try:
|
||||
- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name]
|
||||
-
|
||||
- env = dict(os.environ)
|
||||
- env['LC_ALL'] = 'C'
|
||||
- env['LANG'] = 'C'
|
||||
- try:
|
||||
- proc = subprocess.Popen(args,
|
||||
- stdout=subprocess.PIPE,
|
||||
- stderr=subprocess.STDOUT,
|
||||
- env=env)
|
||||
- except OSError: # E.g. bad executable
|
||||
- return None
|
||||
- with proc:
|
||||
- trace = proc.stdout.read()
|
||||
- finally:
|
||||
- try:
|
||||
- temp.close()
|
||||
- except FileNotFoundError:
|
||||
- # Raised if the file was already removed, which is the normal
|
||||
- # behaviour of GCC if linking fails
|
||||
- pass
|
||||
- res = re.findall(expr, trace)
|
||||
- if not res:
|
||||
- return None
|
||||
-
|
||||
- for file in res:
|
||||
- # Check if the given file is an elf file: gcc can report
|
||||
- # some files that are linker scripts and not actual
|
||||
- # shared objects. See bpo-41976 for more details
|
||||
- if not _is_elf(file):
|
||||
- continue
|
||||
- return os.fsdecode(file)
|
||||
+ return None
|
||||
|
||||
|
||||
if sys.platform == "sunos5":
|
||||
@@ -268,34 +222,7 @@ elif os.name == "posix":
|
||||
else:
|
||||
|
||||
def _findSoname_ldconfig(name):
|
||||
- import struct
|
||||
- if struct.calcsize('l') == 4:
|
||||
- machine = os.uname().machine + '-32'
|
||||
- else:
|
||||
- machine = os.uname().machine + '-64'
|
||||
- mach_map = {
|
||||
- 'x86_64-64': 'libc6,x86-64',
|
||||
- 'ppc64-64': 'libc6,64bit',
|
||||
- 'sparc64-64': 'libc6,64bit',
|
||||
- 's390x-64': 'libc6,64bit',
|
||||
- 'ia64-64': 'libc6,IA-64',
|
||||
- }
|
||||
- abi_type = mach_map.get(machine, 'libc6')
|
||||
-
|
||||
- # XXX assuming GLIBC's ldconfig (with option -p)
|
||||
- regex = r'\s+(lib%s\.[^\s]+)\s+\(%s'
|
||||
- regex = os.fsencode(regex % (re.escape(name), abi_type))
|
||||
- try:
|
||||
- with subprocess.Popen(['/sbin/ldconfig', '-p'],
|
||||
- stdin=subprocess.DEVNULL,
|
||||
- stderr=subprocess.DEVNULL,
|
||||
- stdout=subprocess.PIPE,
|
||||
- env={'LC_ALL': 'C', 'LANG': 'C'}) as p:
|
||||
- res = re.search(regex, p.stdout.read())
|
||||
- if res:
|
||||
- return os.fsdecode(res.group(1))
|
||||
- except OSError:
|
||||
- pass
|
||||
+ return None
|
||||
|
||||
def _findLib_ld(name):
|
||||
# See issue #9998 for why this is needed
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
From 5330b6af9f832af59aa5c61d9ef6971053a8e709 Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Ringer <jonringer117@gmail.com>
|
||||
Date: Mon, 9 Nov 2020 10:24:35 -0800
|
||||
Subject: [PATCH] CPython: Don't use ldconfig
|
||||
|
||||
---
|
||||
Lib/ctypes/util.py | 77 ++--------------------------------------------
|
||||
1 file changed, 2 insertions(+), 75 deletions(-)
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index 0c2510e161..7fb98af308 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -100,53 +100,7 @@ def _is_elf(filename):
|
||||
return thefile.read(4) == elf_header
|
||||
|
||||
def _findLib_gcc(name):
|
||||
- # Run GCC's linker with the -t (aka --trace) option and examine the
|
||||
- # library name it prints out. The GCC command will fail because we
|
||||
- # haven't supplied a proper program with main(), but that does not
|
||||
- # matter.
|
||||
- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name))
|
||||
-
|
||||
- c_compiler = shutil.which('gcc')
|
||||
- if not c_compiler:
|
||||
- c_compiler = shutil.which('cc')
|
||||
- if not c_compiler:
|
||||
- # No C compiler available, give up
|
||||
- return None
|
||||
-
|
||||
- temp = tempfile.NamedTemporaryFile()
|
||||
- try:
|
||||
- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name]
|
||||
-
|
||||
- env = dict(os.environ)
|
||||
- env['LC_ALL'] = 'C'
|
||||
- env['LANG'] = 'C'
|
||||
- try:
|
||||
- proc = subprocess.Popen(args,
|
||||
- stdout=subprocess.PIPE,
|
||||
- stderr=subprocess.STDOUT,
|
||||
- env=env)
|
||||
- except OSError: # E.g. bad executable
|
||||
- return None
|
||||
- with proc:
|
||||
- trace = proc.stdout.read()
|
||||
- finally:
|
||||
- try:
|
||||
- temp.close()
|
||||
- except FileNotFoundError:
|
||||
- # Raised if the file was already removed, which is the normal
|
||||
- # behaviour of GCC if linking fails
|
||||
- pass
|
||||
- res = re.findall(expr, trace)
|
||||
- if not res:
|
||||
- return None
|
||||
-
|
||||
- for file in res:
|
||||
- # Check if the given file is an elf file: gcc can report
|
||||
- # some files that are linker scripts and not actual
|
||||
- # shared objects. See bpo-41976 for more details
|
||||
- if not _is_elf(file):
|
||||
- continue
|
||||
- return os.fsdecode(file)
|
||||
+ return None
|
||||
|
||||
|
||||
if sys.platform == "sunos5":
|
||||
@@ -268,34 +222,7 @@ def find_library(name, is64 = False):
|
||||
else:
|
||||
|
||||
def _findSoname_ldconfig(name):
|
||||
- import struct
|
||||
- if struct.calcsize('l') == 4:
|
||||
- machine = os.uname().machine + '-32'
|
||||
- else:
|
||||
- machine = os.uname().machine + '-64'
|
||||
- mach_map = {
|
||||
- 'x86_64-64': 'libc6,x86-64',
|
||||
- 'ppc64-64': 'libc6,64bit',
|
||||
- 'sparc64-64': 'libc6,64bit',
|
||||
- 's390x-64': 'libc6,64bit',
|
||||
- 'ia64-64': 'libc6,IA-64',
|
||||
- }
|
||||
- abi_type = mach_map.get(machine, 'libc6')
|
||||
-
|
||||
- # XXX assuming GLIBC's ldconfig (with option -p)
|
||||
- regex = r'\s+(lib%s\.[^\s]+)\s+\(%s'
|
||||
- regex = os.fsencode(regex % (re.escape(name), abi_type))
|
||||
- try:
|
||||
- with subprocess.Popen(['/sbin/ldconfig', '-p'],
|
||||
- stdin=subprocess.DEVNULL,
|
||||
- stderr=subprocess.DEVNULL,
|
||||
- stdout=subprocess.PIPE,
|
||||
- env={'LC_ALL': 'C', 'LANG': 'C'}) as p:
|
||||
- res = re.search(regex, p.stdout.read())
|
||||
- if res:
|
||||
- return os.fsdecode(res.group(1))
|
||||
- except OSError:
|
||||
- pass
|
||||
+ return None
|
||||
|
||||
def _findLib_ld(name):
|
||||
# See issue #9998 for why this is needed
|
||||
--
|
||||
2.33.1
|
||||
|
||||
|
|
@ -0,0 +1,257 @@
|
|||
diff --git a/Lib/_osx_support.py b/Lib/_osx_support.py
|
||||
index aa66c8b9f4..71e6556bac 100644
|
||||
--- a/Lib/_osx_support.py
|
||||
+++ b/Lib/_osx_support.py
|
||||
@@ -14,13 +14,13 @@
|
||||
# configuration variables that may contain universal build flags,
|
||||
# like "-arch" or "-isdkroot", that may need customization for
|
||||
# the user environment
|
||||
-_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS',
|
||||
- 'BLDSHARED', 'LDSHARED', 'CC', 'CXX',
|
||||
- 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
|
||||
- 'PY_CORE_CFLAGS', 'PY_CORE_LDFLAGS')
|
||||
+_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CPPFLAGS',
|
||||
+ 'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'LDCXXSHARED',
|
||||
+ 'CC', 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS',
|
||||
+ 'PY_CPPFLAGS', 'PY_CORE_LDFLAGS', 'PY_CORE_CFLAGS')
|
||||
|
||||
# configuration variables that may contain compiler calls
|
||||
-_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX')
|
||||
+_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'LDCXXSHARED', 'CC', 'CXX')
|
||||
|
||||
# prefix added to original configuration variable names
|
||||
_INITPRE = '_OSX_SUPPORT_INITIAL_'
|
||||
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
|
||||
index 66c12dd358..dddb9fd2d4 100644
|
||||
--- a/Lib/distutils/cygwinccompiler.py
|
||||
+++ b/Lib/distutils/cygwinccompiler.py
|
||||
@@ -123,8 +123,10 @@ def __init__(self, verbose=0, dry_run=0, force=0):
|
||||
# dllwrap 2.10.90 is buggy
|
||||
if self.ld_version >= "2.10.90":
|
||||
self.linker_dll = "gcc"
|
||||
+ self.linker_dll_cxx = "g++"
|
||||
else:
|
||||
self.linker_dll = "dllwrap"
|
||||
+ self.linker_dll_cxx = "dllwrap"
|
||||
|
||||
# ld_version >= "2.13" support -shared so use it instead of
|
||||
# -mdll -static
|
||||
@@ -138,9 +140,13 @@ def __init__(self, verbose=0, dry_run=0, force=0):
|
||||
self.set_executables(compiler='gcc -mcygwin -O -Wall',
|
||||
compiler_so='gcc -mcygwin -mdll -O -Wall',
|
||||
compiler_cxx='g++ -mcygwin -O -Wall',
|
||||
+ compiler_so_cxx='g++ -mcygwin -mdll -O -Wall',
|
||||
linker_exe='gcc -mcygwin',
|
||||
linker_so=('%s -mcygwin %s' %
|
||||
- (self.linker_dll, shared_option)))
|
||||
+ (self.linker_dll, shared_option)),
|
||||
+ linker_exe_cxx='g++ -mcygwin',
|
||||
+ linker_so_cxx=('%s -mcygwin %s' %
|
||||
+ (self.linker_dll_cxx, shared_option)))
|
||||
|
||||
# cygwin and mingw32 need different sets of libraries
|
||||
if self.gcc_version == "2.91.57":
|
||||
@@ -164,8 +170,12 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
||||
raise CompileError(msg)
|
||||
else: # for other files use the C-compiler
|
||||
try:
|
||||
- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||
- extra_postargs)
|
||||
+ if self.detect_language(src) == 'c++':
|
||||
+ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
+ else:
|
||||
+ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
except DistutilsExecError as msg:
|
||||
raise CompileError(msg)
|
||||
|
||||
@@ -300,9 +310,14 @@ def __init__(self, verbose=0, dry_run=0, force=0):
|
||||
self.set_executables(compiler='gcc -O -Wall',
|
||||
compiler_so='gcc -mdll -O -Wall',
|
||||
compiler_cxx='g++ -O -Wall',
|
||||
+ compiler_so_cxx='g++ -mdll -O -Wall',
|
||||
linker_exe='gcc',
|
||||
linker_so='%s %s %s'
|
||||
% (self.linker_dll, shared_option,
|
||||
+ entry_point),
|
||||
+ linker_exe_cxx='g++',
|
||||
+ linker_so_cxx='%s %s %s'
|
||||
+ % (self.linker_dll_cxx, shared_option,
|
||||
entry_point))
|
||||
# Maybe we should also append -mthreads, but then the finished
|
||||
# dlls need another dll (mingwm10.dll see Mingw32 docs)
|
||||
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
|
||||
index 3414a761e7..f1af560cc1 100644
|
||||
--- a/Lib/distutils/sysconfig.py
|
||||
+++ b/Lib/distutils/sysconfig.py
|
||||
@@ -216,9 +216,11 @@ def customize_compiler(compiler):
|
||||
_osx_support.customize_compiler(_config_vars)
|
||||
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
|
||||
|
||||
- (cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
|
||||
- get_config_vars('CC', 'CXX', 'CFLAGS',
|
||||
- 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
|
||||
+ (cc, cxx, cflags, ccshared, ldshared, ldcxxshared, shlib_suffix, ar, ar_flags) = \
|
||||
+ get_config_vars('CC', 'CXX', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED',
|
||||
+ 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
|
||||
+
|
||||
+ cxxflags = cflags
|
||||
|
||||
if 'CC' in os.environ:
|
||||
newcc = os.environ['CC']
|
||||
@@ -233,19 +235,27 @@ def customize_compiler(compiler):
|
||||
cxx = os.environ['CXX']
|
||||
if 'LDSHARED' in os.environ:
|
||||
ldshared = os.environ['LDSHARED']
|
||||
+ if 'LDCXXSHARED' in os.environ:
|
||||
+ ldcxxshared = os.environ['LDCXXSHARED']
|
||||
if 'CPP' in os.environ:
|
||||
cpp = os.environ['CPP']
|
||||
else:
|
||||
cpp = cc + " -E" # not always
|
||||
if 'LDFLAGS' in os.environ:
|
||||
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['LDFLAGS']
|
||||
if 'CFLAGS' in os.environ:
|
||||
- cflags = cflags + ' ' + os.environ['CFLAGS']
|
||||
+ cflags = os.environ['CFLAGS']
|
||||
ldshared = ldshared + ' ' + os.environ['CFLAGS']
|
||||
+ if 'CXXFLAGS' in os.environ:
|
||||
+ cxxflags = os.environ['CXXFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS']
|
||||
if 'CPPFLAGS' in os.environ:
|
||||
cpp = cpp + ' ' + os.environ['CPPFLAGS']
|
||||
cflags = cflags + ' ' + os.environ['CPPFLAGS']
|
||||
+ cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS']
|
||||
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS']
|
||||
if 'AR' in os.environ:
|
||||
ar = os.environ['AR']
|
||||
if 'ARFLAGS' in os.environ:
|
||||
@@ -254,13 +264,17 @@ def customize_compiler(compiler):
|
||||
archiver = ar + ' ' + ar_flags
|
||||
|
||||
cc_cmd = cc + ' ' + cflags
|
||||
+ cxx_cmd = cxx + ' ' + cxxflags
|
||||
compiler.set_executables(
|
||||
preprocessor=cpp,
|
||||
compiler=cc_cmd,
|
||||
compiler_so=cc_cmd + ' ' + ccshared,
|
||||
- compiler_cxx=cxx,
|
||||
+ compiler_cxx=cxx_cmd,
|
||||
+ compiler_so_cxx=cxx_cmd + ' ' + ccshared,
|
||||
linker_so=ldshared,
|
||||
linker_exe=cc,
|
||||
+ linker_so_cxx=ldcxxshared,
|
||||
+ linker_exe_cxx=cxx,
|
||||
archiver=archiver)
|
||||
|
||||
compiler.shared_lib_extension = shlib_suffix
|
||||
diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
|
||||
index d00c48981e..4a3d271fee 100644
|
||||
--- a/Lib/distutils/unixccompiler.py
|
||||
+++ b/Lib/distutils/unixccompiler.py
|
||||
@@ -52,14 +52,17 @@ class UnixCCompiler(CCompiler):
|
||||
# are pretty generic; they will probably have to be set by an outsider
|
||||
# (eg. using information discovered by the sysconfig about building
|
||||
# Python extensions).
|
||||
- executables = {'preprocessor' : None,
|
||||
- 'compiler' : ["cc"],
|
||||
- 'compiler_so' : ["cc"],
|
||||
- 'compiler_cxx' : ["cc"],
|
||||
- 'linker_so' : ["cc", "-shared"],
|
||||
- 'linker_exe' : ["cc"],
|
||||
- 'archiver' : ["ar", "-cr"],
|
||||
- 'ranlib' : None,
|
||||
+ executables = {'preprocessor' : None,
|
||||
+ 'compiler' : ["cc"],
|
||||
+ 'compiler_so' : ["cc"],
|
||||
+ 'compiler_cxx' : ["c++"],
|
||||
+ 'compiler_so_cxx' : ["c++"],
|
||||
+ 'linker_so' : ["cc", "-shared"],
|
||||
+ 'linker_exe' : ["cc"],
|
||||
+ 'linker_so_cxx' : ["c++", "-shared"],
|
||||
+ 'linker_exe_cxx' : ["c++"],
|
||||
+ 'archiver' : ["ar", "-cr"],
|
||||
+ 'ranlib' : None,
|
||||
}
|
||||
|
||||
if sys.platform[:6] == "darwin":
|
||||
@@ -110,12 +113,19 @@ def preprocess(self, source, output_file=None, macros=None,
|
||||
|
||||
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
||||
compiler_so = self.compiler_so
|
||||
+ compiler_so_cxx = self.compiler_so_cxx
|
||||
if sys.platform == 'darwin':
|
||||
compiler_so = _osx_support.compiler_fixup(compiler_so,
|
||||
cc_args + extra_postargs)
|
||||
+ compiler_so_cxx = _osx_support.compiler_fixup(compiler_so_cxx,
|
||||
+ cc_args + extra_postargs)
|
||||
try:
|
||||
- self.spawn(compiler_so + cc_args + [src, '-o', obj] +
|
||||
- extra_postargs)
|
||||
+ if self.detect_language(src) == 'c++':
|
||||
+ self.spawn(compiler_so_cxx + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
+ else:
|
||||
+ self.spawn(compiler_so + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
except DistutilsExecError as msg:
|
||||
raise CompileError(msg)
|
||||
|
||||
@@ -173,30 +183,16 @@ def link(self, target_desc, objects,
|
||||
ld_args.extend(extra_postargs)
|
||||
self.mkpath(os.path.dirname(output_filename))
|
||||
try:
|
||||
- if target_desc == CCompiler.EXECUTABLE:
|
||||
- linker = self.linker_exe[:]
|
||||
+ if target_lang == "c++":
|
||||
+ if target_desc == CCompiler.EXECUTABLE:
|
||||
+ linker = self.linker_exe_cxx[:]
|
||||
+ else:
|
||||
+ linker = self.linker_so_cxx[:]
|
||||
else:
|
||||
- linker = self.linker_so[:]
|
||||
- if target_lang == "c++" and self.compiler_cxx:
|
||||
- # skip over environment variable settings if /usr/bin/env
|
||||
- # is used to set up the linker's environment.
|
||||
- # This is needed on OSX. Note: this assumes that the
|
||||
- # normal and C++ compiler have the same environment
|
||||
- # settings.
|
||||
- i = 0
|
||||
- if os.path.basename(linker[0]) == "env":
|
||||
- i = 1
|
||||
- while '=' in linker[i]:
|
||||
- i += 1
|
||||
-
|
||||
- if os.path.basename(linker[i]) == 'ld_so_aix':
|
||||
- # AIX platforms prefix the compiler with the ld_so_aix
|
||||
- # script, so we need to adjust our linker index
|
||||
- offset = 1
|
||||
+ if target_desc == CCompiler.EXECUTABLE:
|
||||
+ linker = self.linker_exe[:]
|
||||
else:
|
||||
- offset = 0
|
||||
-
|
||||
- linker[i+offset] = self.compiler_cxx[i]
|
||||
+ linker = self.linker_so[:]
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
linker = _osx_support.compiler_fixup(linker, ld_args)
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index f803391346..090f14c46c 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -732,9 +732,9 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt @LIBMPDEC_INTERNAL@ @LIBEXPAT_INTERNAL
|
||||
*\ -s*|s*) quiet="-q";; \
|
||||
*) quiet="";; \
|
||||
esac; \
|
||||
- echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
|
||||
+ echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' CFLAGS='$(PY_CFLAGS)' \
|
||||
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build"; \
|
||||
- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
|
||||
+ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' CFLAGS='$(PY_CFLAGS)' \
|
||||
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
--- a/Lib/py_compile.py
|
||||
+++ b/Lib/py_compile.py
|
||||
@@ -139,3 +139,4 @@
|
||||
source_stats = loader.path_stats(file)
|
||||
+ source_mtime = 1 if 'DETERMINISTIC_BUILD' in os.environ else source_stats['mtime']
|
||||
bytecode = importlib._bootstrap_external._code_to_bytecode(
|
||||
- code, source_stats['mtime'], source_stats['size'])
|
||||
+ code, source_mtime, source_stats['size'])
|
||||
--- a/Lib/importlib/_bootstrap_external.py
|
||||
+++ b/Lib/importlib/_bootstrap_external.py
|
||||
@@ -485,5 +485,5 @@
|
||||
if source_stats is not None:
|
||||
try:
|
||||
- source_mtime = int(source_stats['mtime'])
|
||||
+ source_mtime = 1
|
||||
except KeyError:
|
||||
pass
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
From 918201682127ed8a270a4bd1a448b490019e4ada Mon Sep 17 00:00:00 2001
|
||||
From: Frederik Rietdijk <fridh@fridh.nl>
|
||||
Date: Thu, 14 Sep 2017 10:00:31 +0200
|
||||
Subject: [PATCH] ctypes.util: support LD_LIBRARY_PATH
|
||||
|
||||
Backports support for LD_LIBRARY_PATH from 3.6
|
||||
---
|
||||
Lib/ctypes/util.py | 26 +++++++++++++++++++++++++-
|
||||
1 file changed, 25 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index e9957d7951..9926f6c881 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -219,8 +219,32 @@ elif os.name == "posix":
|
||||
def _findSoname_ldconfig(name):
|
||||
return None
|
||||
|
||||
+ def _findLib_ld(name):
|
||||
+ # See issue #9998 for why this is needed
|
||||
+ expr = r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name)
|
||||
+ cmd = ['ld', '-t']
|
||||
+ libpath = os.environ.get('LD_LIBRARY_PATH')
|
||||
+ if libpath:
|
||||
+ for d in libpath.split(':'):
|
||||
+ cmd.extend(['-L', d])
|
||||
+ cmd.extend(['-o', os.devnull, '-l%s' % name])
|
||||
+ result = None
|
||||
+ try:
|
||||
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE,
|
||||
+ stderr=subprocess.PIPE,
|
||||
+ universal_newlines=True)
|
||||
+ out, _ = p.communicate()
|
||||
+ res = re.search(expr, os.fsdecode(out))
|
||||
+ if res:
|
||||
+ result = res.group(0)
|
||||
+ except Exception as e:
|
||||
+ pass # result will be None
|
||||
+ return result
|
||||
+
|
||||
def find_library(name):
|
||||
- return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name))
|
||||
+ # See issue #9998
|
||||
+ return _findSoname_ldconfig(name) or \
|
||||
+ _get_soname(_findLib_gcc(name) or _findLib_ld(name))
|
||||
|
||||
################################################################
|
||||
# test code
|
||||
--
|
||||
2.14.1
|
||||
|
||||
|
|
@ -0,0 +1,164 @@
|
|||
From 590c46bb04f79ab611b2f8fd682dd7e43a01f268 Mon Sep 17 00:00:00 2001
|
||||
From: Frederik Rietdijk <fridh@fridh.nl>
|
||||
Date: Mon, 28 Aug 2017 09:24:06 +0200
|
||||
Subject: [PATCH] Don't use ldconfig and speed up uuid load
|
||||
|
||||
---
|
||||
Lib/ctypes/util.py | 70 ++----------------------------------------------------
|
||||
Lib/uuid.py | 49 --------------------------------------
|
||||
2 files changed, 2 insertions(+), 117 deletions(-)
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index 7684eab81d..e9957d7951 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -95,46 +95,7 @@ elif os.name == "posix":
|
||||
import re, tempfile
|
||||
|
||||
def _findLib_gcc(name):
|
||||
- # Run GCC's linker with the -t (aka --trace) option and examine the
|
||||
- # library name it prints out. The GCC command will fail because we
|
||||
- # haven't supplied a proper program with main(), but that does not
|
||||
- # matter.
|
||||
- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name))
|
||||
-
|
||||
- c_compiler = shutil.which('gcc')
|
||||
- if not c_compiler:
|
||||
- c_compiler = shutil.which('cc')
|
||||
- if not c_compiler:
|
||||
- # No C compiler available, give up
|
||||
- return None
|
||||
-
|
||||
- temp = tempfile.NamedTemporaryFile()
|
||||
- try:
|
||||
- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name]
|
||||
-
|
||||
- env = dict(os.environ)
|
||||
- env['LC_ALL'] = 'C'
|
||||
- env['LANG'] = 'C'
|
||||
- try:
|
||||
- proc = subprocess.Popen(args,
|
||||
- stdout=subprocess.PIPE,
|
||||
- stderr=subprocess.STDOUT,
|
||||
- env=env)
|
||||
- except OSError: # E.g. bad executable
|
||||
- return None
|
||||
- with proc:
|
||||
- trace = proc.stdout.read()
|
||||
- finally:
|
||||
- try:
|
||||
- temp.close()
|
||||
- except FileNotFoundError:
|
||||
- # Raised if the file was already removed, which is the normal
|
||||
- # behaviour of GCC if linking fails
|
||||
- pass
|
||||
- res = re.search(expr, trace)
|
||||
- if not res:
|
||||
- return None
|
||||
- return os.fsdecode(res.group(0))
|
||||
+ return None
|
||||
|
||||
|
||||
if sys.platform == "sunos5":
|
||||
@@ -256,34 +217,7 @@ elif os.name == "posix":
|
||||
else:
|
||||
|
||||
def _findSoname_ldconfig(name):
|
||||
- import struct
|
||||
- if struct.calcsize('l') == 4:
|
||||
- machine = os.uname().machine + '-32'
|
||||
- else:
|
||||
- machine = os.uname().machine + '-64'
|
||||
- mach_map = {
|
||||
- 'x86_64-64': 'libc6,x86-64',
|
||||
- 'ppc64-64': 'libc6,64bit',
|
||||
- 'sparc64-64': 'libc6,64bit',
|
||||
- 's390x-64': 'libc6,64bit',
|
||||
- 'ia64-64': 'libc6,IA-64',
|
||||
- }
|
||||
- abi_type = mach_map.get(machine, 'libc6')
|
||||
-
|
||||
- # XXX assuming GLIBC's ldconfig (with option -p)
|
||||
- regex = os.fsencode(
|
||||
- '\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type))
|
||||
- try:
|
||||
- with subprocess.Popen(['/sbin/ldconfig', '-p'],
|
||||
- stdin=subprocess.DEVNULL,
|
||||
- stderr=subprocess.DEVNULL,
|
||||
- stdout=subprocess.PIPE,
|
||||
- env={'LC_ALL': 'C', 'LANG': 'C'}) as p:
|
||||
- res = re.search(regex, p.stdout.read())
|
||||
- if res:
|
||||
- return os.fsdecode(res.group(1))
|
||||
- except OSError:
|
||||
- pass
|
||||
+ return None
|
||||
|
||||
def find_library(name):
|
||||
return _findSoname_ldconfig(name) or _get_soname(_findLib_gcc(name))
|
||||
diff --git a/Lib/uuid.py b/Lib/uuid.py
|
||||
index e96e7e034c..31160ace95 100644
|
||||
--- a/Lib/uuid.py
|
||||
+++ b/Lib/uuid.py
|
||||
@@ -455,58 +455,9 @@ def _netbios_getnode():
|
||||
continue
|
||||
return int.from_bytes(bytes, 'big')
|
||||
|
||||
-# Thanks to Thomas Heller for ctypes and for his help with its use here.
|
||||
|
||||
-# If ctypes is available, use it to find system routines for UUID generation.
|
||||
-# XXX This makes the module non-thread-safe!
|
||||
_uuid_generate_time = _UuidCreate = None
|
||||
-try:
|
||||
- import ctypes, ctypes.util
|
||||
- import sys
|
||||
|
||||
- # The uuid_generate_* routines are provided by libuuid on at least
|
||||
- # Linux and FreeBSD, and provided by libc on Mac OS X.
|
||||
- _libnames = ['uuid']
|
||||
- if not sys.platform.startswith('win'):
|
||||
- _libnames.append('c')
|
||||
- for libname in _libnames:
|
||||
- try:
|
||||
- lib = ctypes.CDLL(ctypes.util.find_library(libname))
|
||||
- except Exception:
|
||||
- continue
|
||||
- if hasattr(lib, 'uuid_generate_time'):
|
||||
- _uuid_generate_time = lib.uuid_generate_time
|
||||
- break
|
||||
- del _libnames
|
||||
-
|
||||
- # The uuid_generate_* functions are broken on MacOS X 10.5, as noted
|
||||
- # in issue #8621 the function generates the same sequence of values
|
||||
- # in the parent process and all children created using fork (unless
|
||||
- # those children use exec as well).
|
||||
- #
|
||||
- # Assume that the uuid_generate functions are broken from 10.5 onward,
|
||||
- # the test can be adjusted when a later version is fixed.
|
||||
- if sys.platform == 'darwin':
|
||||
- import os
|
||||
- if int(os.uname().release.split('.')[0]) >= 9:
|
||||
- _uuid_generate_time = None
|
||||
-
|
||||
- # On Windows prior to 2000, UuidCreate gives a UUID containing the
|
||||
- # hardware address. On Windows 2000 and later, UuidCreate makes a
|
||||
- # random UUID and UuidCreateSequential gives a UUID containing the
|
||||
- # hardware address. These routines are provided by the RPC runtime.
|
||||
- # NOTE: at least on Tim's WinXP Pro SP2 desktop box, while the last
|
||||
- # 6 bytes returned by UuidCreateSequential are fixed, they don't appear
|
||||
- # to bear any relationship to the MAC address of any network device
|
||||
- # on the box.
|
||||
- try:
|
||||
- lib = ctypes.windll.rpcrt4
|
||||
- except:
|
||||
- lib = None
|
||||
- _UuidCreate = getattr(lib, 'UuidCreateSequential',
|
||||
- getattr(lib, 'UuidCreate', None))
|
||||
-except:
|
||||
- pass
|
||||
|
||||
def _unixdll_getnode():
|
||||
"""Get the hardware address on Unix using ctypes."""
|
||||
--
|
||||
2.14.1
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Backport from CPython 3.8 of a good list of tests to run for PGO.
|
||||
|
||||
Upstream commit:
|
||||
https://github.com/python/cpython/commit/4e16a4a31
|
||||
|
||||
Upstream discussion:
|
||||
https://bugs.python.org/issue36044
|
||||
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index 00fdd21ce..713dc1e53 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -259,7 +259,7 @@ TCLTK_LIBS=
|
||||
# The task to run while instrumented when building the profile-opt target.
|
||||
# We exclude unittests with -x that take a rediculious amount of time to
|
||||
# run in the instrumented training build or do not provide much value.
|
||||
-PROFILE_TASK=-m test.regrtest --pgo -x test_asyncore test_gdb test_multiprocessing_fork test_multiprocessing_forkserver test_multiprocessing_main_handling test_multiprocessing_spawn test_subprocess
|
||||
+PROFILE_TASK=-m test.regrtest --pgo test_array test_base64 test_binascii test_binop test_bisect test_bytes test_bz2 test_cmath test_codecs test_collections test_complex test_dataclasses test_datetime test_decimal test_difflib test_embed test_float test_fstring test_functools test_generators test_hashlib test_heapq test_int test_itertools test_json test_long test_lzma test_math test_memoryview test_operator test_ordered_dict test_pickle test_pprint test_re test_set test_sqlite test_statistics test_struct test_tabnanny test_time test_unicode test_xml_etree test_xml_etree_c
|
||||
|
||||
# report files for gcov / lcov coverage report
|
||||
COVERAGE_INFO= $(abs_builddir)/coverage.info
|
||||
|
|
@ -0,0 +1,237 @@
|
|||
Source: https://bugs.python.org/file47046/python-3.x-distutils-C++.patch
|
||||
--- a/Lib/distutils/cygwinccompiler.py
|
||||
+++ b/Lib/distutils/cygwinccompiler.py
|
||||
@@ -125,8 +125,10 @@
|
||||
# dllwrap 2.10.90 is buggy
|
||||
if self.ld_version >= "2.10.90":
|
||||
self.linker_dll = "gcc"
|
||||
+ self.linker_dll_cxx = "g++"
|
||||
else:
|
||||
self.linker_dll = "dllwrap"
|
||||
+ self.linker_dll_cxx = "dllwrap"
|
||||
|
||||
# ld_version >= "2.13" support -shared so use it instead of
|
||||
# -mdll -static
|
||||
@@ -140,9 +142,13 @@
|
||||
self.set_executables(compiler='gcc -mcygwin -O -Wall',
|
||||
compiler_so='gcc -mcygwin -mdll -O -Wall',
|
||||
compiler_cxx='g++ -mcygwin -O -Wall',
|
||||
+ compiler_so_cxx='g++ -mcygwin -mdll -O -Wall',
|
||||
linker_exe='gcc -mcygwin',
|
||||
linker_so=('%s -mcygwin %s' %
|
||||
- (self.linker_dll, shared_option)))
|
||||
+ (self.linker_dll, shared_option)),
|
||||
+ linker_exe_cxx='g++ -mcygwin',
|
||||
+ linker_so_cxx=('%s -mcygwin %s' %
|
||||
+ (self.linker_dll_cxx, shared_option)))
|
||||
|
||||
# cygwin and mingw32 need different sets of libraries
|
||||
if self.gcc_version == "2.91.57":
|
||||
@@ -166,8 +172,12 @@
|
||||
raise CompileError(msg)
|
||||
else: # for other files use the C-compiler
|
||||
try:
|
||||
- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||
- extra_postargs)
|
||||
+ if self.detect_language(src) == 'c++':
|
||||
+ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
+ else:
|
||||
+ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
except DistutilsExecError as msg:
|
||||
raise CompileError(msg)
|
||||
|
||||
@@ -302,9 +312,14 @@
|
||||
self.set_executables(compiler='gcc -O -Wall',
|
||||
compiler_so='gcc -mdll -O -Wall',
|
||||
compiler_cxx='g++ -O -Wall',
|
||||
+ compiler_so_cxx='g++ -mdll -O -Wall',
|
||||
linker_exe='gcc',
|
||||
linker_so='%s %s %s'
|
||||
% (self.linker_dll, shared_option,
|
||||
+ entry_point),
|
||||
+ linker_exe_cxx='g++',
|
||||
+ linker_so_cxx='%s %s %s'
|
||||
+ % (self.linker_dll_cxx, shared_option,
|
||||
entry_point))
|
||||
# Maybe we should also append -mthreads, but then the finished
|
||||
# dlls need another dll (mingwm10.dll see Mingw32 docs)
|
||||
--- a/Lib/distutils/sysconfig.py
|
||||
+++ b/Lib/distutils/sysconfig.py
|
||||
@@ -184,9 +184,11 @@
|
||||
_osx_support.customize_compiler(_config_vars)
|
||||
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
|
||||
|
||||
- (cc, cxx, opt, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
|
||||
- get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
|
||||
- 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
|
||||
+ (cc, cxx, cflags, ccshared, ldshared, ldcxxshared, shlib_suffix, ar, ar_flags) = \
|
||||
+ get_config_vars('CC', 'CXX', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED',
|
||||
+ 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
|
||||
+
|
||||
+ cxxflags = cflags
|
||||
|
||||
if 'CC' in os.environ:
|
||||
newcc = os.environ['CC']
|
||||
@@ -201,19 +204,27 @@
|
||||
cxx = os.environ['CXX']
|
||||
if 'LDSHARED' in os.environ:
|
||||
ldshared = os.environ['LDSHARED']
|
||||
+ if 'LDCXXSHARED' in os.environ:
|
||||
+ ldcxxshared = os.environ['LDCXXSHARED']
|
||||
if 'CPP' in os.environ:
|
||||
cpp = os.environ['CPP']
|
||||
else:
|
||||
cpp = cc + " -E" # not always
|
||||
if 'LDFLAGS' in os.environ:
|
||||
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['LDFLAGS']
|
||||
if 'CFLAGS' in os.environ:
|
||||
- cflags = opt + ' ' + os.environ['CFLAGS']
|
||||
+ cflags = os.environ['CFLAGS']
|
||||
ldshared = ldshared + ' ' + os.environ['CFLAGS']
|
||||
+ if 'CXXFLAGS' in os.environ:
|
||||
+ cxxflags = os.environ['CXXFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS']
|
||||
if 'CPPFLAGS' in os.environ:
|
||||
cpp = cpp + ' ' + os.environ['CPPFLAGS']
|
||||
cflags = cflags + ' ' + os.environ['CPPFLAGS']
|
||||
+ cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS']
|
||||
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS']
|
||||
if 'AR' in os.environ:
|
||||
ar = os.environ['AR']
|
||||
if 'ARFLAGS' in os.environ:
|
||||
@@ -222,13 +233,17 @@
|
||||
archiver = ar + ' ' + ar_flags
|
||||
|
||||
cc_cmd = cc + ' ' + cflags
|
||||
+ cxx_cmd = cxx + ' ' + cxxflags
|
||||
compiler.set_executables(
|
||||
preprocessor=cpp,
|
||||
compiler=cc_cmd,
|
||||
compiler_so=cc_cmd + ' ' + ccshared,
|
||||
- compiler_cxx=cxx,
|
||||
+ compiler_cxx=cxx_cmd,
|
||||
+ compiler_so_cxx=cxx_cmd + ' ' + ccshared,
|
||||
linker_so=ldshared,
|
||||
linker_exe=cc,
|
||||
+ linker_so_cxx=ldcxxshared,
|
||||
+ linker_exe_cxx=cxx,
|
||||
archiver=archiver)
|
||||
|
||||
compiler.shared_lib_extension = shlib_suffix
|
||||
--- a/Lib/distutils/unixccompiler.py
|
||||
+++ b/Lib/distutils/unixccompiler.py
|
||||
@@ -52,14 +52,17 @@
|
||||
# are pretty generic; they will probably have to be set by an outsider
|
||||
# (eg. using information discovered by the sysconfig about building
|
||||
# Python extensions).
|
||||
- executables = {'preprocessor' : None,
|
||||
- 'compiler' : ["cc"],
|
||||
- 'compiler_so' : ["cc"],
|
||||
- 'compiler_cxx' : ["cc"],
|
||||
- 'linker_so' : ["cc", "-shared"],
|
||||
- 'linker_exe' : ["cc"],
|
||||
- 'archiver' : ["ar", "-cr"],
|
||||
- 'ranlib' : None,
|
||||
+ executables = {'preprocessor' : None,
|
||||
+ 'compiler' : ["cc"],
|
||||
+ 'compiler_so' : ["cc"],
|
||||
+ 'compiler_cxx' : ["c++"],
|
||||
+ 'compiler_so_cxx' : ["c++"],
|
||||
+ 'linker_so' : ["cc", "-shared"],
|
||||
+ 'linker_exe' : ["cc"],
|
||||
+ 'linker_so_cxx' : ["c++", "-shared"],
|
||||
+ 'linker_exe_cxx' : ["c++"],
|
||||
+ 'archiver' : ["ar", "-cr"],
|
||||
+ 'ranlib' : None,
|
||||
}
|
||||
|
||||
if sys.platform[:6] == "darwin":
|
||||
@@ -108,12 +111,19 @@
|
||||
|
||||
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
||||
compiler_so = self.compiler_so
|
||||
+ compiler_so_cxx = self.compiler_so_cxx
|
||||
if sys.platform == 'darwin':
|
||||
compiler_so = _osx_support.compiler_fixup(compiler_so,
|
||||
cc_args + extra_postargs)
|
||||
+ compiler_so_cxx = _osx_support.compiler_fixup(compiler_so_cxx,
|
||||
+ cc_args + extra_postargs)
|
||||
try:
|
||||
- self.spawn(compiler_so + cc_args + [src, '-o', obj] +
|
||||
- extra_postargs)
|
||||
+ if self.detect_language(src) == 'c++':
|
||||
+ self.spawn(compiler_so_cxx + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
+ else:
|
||||
+ self.spawn(compiler_so + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
except DistutilsExecError as msg:
|
||||
raise CompileError(msg)
|
||||
|
||||
@@ -171,22 +181,16 @@
|
||||
ld_args.extend(extra_postargs)
|
||||
self.mkpath(os.path.dirname(output_filename))
|
||||
try:
|
||||
- if target_desc == CCompiler.EXECUTABLE:
|
||||
- linker = self.linker_exe[:]
|
||||
+ if target_lang == "c++":
|
||||
+ if target_desc == CCompiler.EXECUTABLE:
|
||||
+ linker = self.linker_exe_cxx[:]
|
||||
+ else:
|
||||
+ linker = self.linker_so_cxx[:]
|
||||
else:
|
||||
- linker = self.linker_so[:]
|
||||
- if target_lang == "c++" and self.compiler_cxx:
|
||||
- # skip over environment variable settings if /usr/bin/env
|
||||
- # is used to set up the linker's environment.
|
||||
- # This is needed on OSX. Note: this assumes that the
|
||||
- # normal and C++ compiler have the same environment
|
||||
- # settings.
|
||||
- i = 0
|
||||
- if os.path.basename(linker[0]) == "env":
|
||||
- i = 1
|
||||
- while '=' in linker[i]:
|
||||
- i += 1
|
||||
- linker[i] = self.compiler_cxx[i]
|
||||
+ if target_desc == CCompiler.EXECUTABLE:
|
||||
+ linker = self.linker_exe[:]
|
||||
+ else:
|
||||
+ linker = self.linker_so[:]
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
linker = _osx_support.compiler_fixup(linker, ld_args)
|
||||
--- a/Lib/_osx_support.py
|
||||
+++ b/Lib/_osx_support.py
|
||||
@@ -14,13 +14,13 @@
|
||||
# configuration variables that may contain universal build flags,
|
||||
# like "-arch" or "-isdkroot", that may need customization for
|
||||
# the user environment
|
||||
-_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS',
|
||||
- 'BLDSHARED', 'LDSHARED', 'CC', 'CXX',
|
||||
- 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
|
||||
- 'PY_CORE_CFLAGS')
|
||||
+_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CPPFLAGS',
|
||||
+ 'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'LDCXXSHARED',
|
||||
+ 'CC', 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS',
|
||||
+ 'PY_CPPFLAGS', 'PY_CORE_CFLAGS')
|
||||
|
||||
# configuration variables that may contain compiler calls
|
||||
-_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX')
|
||||
+_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'LDCXXSHARED', 'CC', 'CXX')
|
||||
|
||||
# prefix added to original configuration variable names
|
||||
_INITPRE = '_OSX_SUPPORT_INITIAL_'
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -538,7 +538,7 @@
|
||||
*\ -s*|s*) quiet="-q";; \
|
||||
*) quiet="";; \
|
||||
esac; \
|
||||
- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
|
||||
+ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' CFLAGS='$(PY_CFLAGS)' \
|
||||
_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
|
||||
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
diff --git a/setup.py b/setup.py
|
||||
index 2779658..902d0eb 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext):
|
||||
# Rather than complicate the code below, detecting and building
|
||||
# AquaTk is a separate method. Only one Tkinter will be built on
|
||||
# Darwin - either AquaTk, if it is found, or X11 based Tk.
|
||||
- if (host_platform == 'darwin' and
|
||||
- self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
|
||||
- return
|
||||
|
||||
# Assume we haven't found any of the libraries or include files
|
||||
# The versions with dots are used on Unix, and the versions without
|
||||
@@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext):
|
||||
if dir not in include_dirs:
|
||||
include_dirs.append(dir)
|
||||
|
||||
- # Check for various platform-specific directories
|
||||
- if host_platform == 'sunos5':
|
||||
- include_dirs.append('/usr/openwin/include')
|
||||
- added_lib_dirs.append('/usr/openwin/lib')
|
||||
- elif os.path.exists('/usr/X11R6/include'):
|
||||
- include_dirs.append('/usr/X11R6/include')
|
||||
- added_lib_dirs.append('/usr/X11R6/lib64')
|
||||
- added_lib_dirs.append('/usr/X11R6/lib')
|
||||
- elif os.path.exists('/usr/X11R5/include'):
|
||||
- include_dirs.append('/usr/X11R5/include')
|
||||
- added_lib_dirs.append('/usr/X11R5/lib')
|
||||
- else:
|
||||
- # Assume default location for X11
|
||||
- include_dirs.append('/usr/X11/include')
|
||||
- added_lib_dirs.append('/usr/X11/lib')
|
||||
-
|
||||
# If Cygwin, then verify that X is installed before proceeding
|
||||
if host_platform == 'cygwin':
|
||||
x11_inc = find_file('X11/Xlib.h', [], include_dirs)
|
||||
@@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext):
|
||||
if host_platform in ['aix3', 'aix4']:
|
||||
libs.append('ld')
|
||||
|
||||
- # Finally, link with the X11 libraries (not appropriate on cygwin)
|
||||
- if host_platform != "cygwin":
|
||||
- libs.append('X11')
|
||||
-
|
||||
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
|
||||
define_macros=[('WITH_APPINIT', 1)] + defs,
|
||||
include_dirs = include_dirs,
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
From 9b5a023a5dc3127da15253f7acad71019395ebe1 Mon Sep 17 00:00:00 2001
|
||||
From: Pablo Galindo <Pablogsal@gmail.com>
|
||||
Date: Thu, 8 Oct 2020 19:50:37 +0100
|
||||
Subject: [PATCH] [3.7] bpo-41976: Fix the fallback to gcc of
|
||||
ctypes.util.find_library when using gcc>9 (GH-22598). (GH-22601)
|
||||
|
||||
(cherry picked from commit 27ac19cca2c639caaf6fedf3632fe6beb265f24f)
|
||||
|
||||
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
|
||||
---
|
||||
Lib/ctypes/test/test_find.py | 12 ++++++-
|
||||
Lib/ctypes/util.py | 32 +++++++++++++++----
|
||||
.../2020-10-08-18-22-28.bpo-41976.Svm0wb.rst | 3 ++
|
||||
3 files changed, 39 insertions(+), 8 deletions(-)
|
||||
create mode 100644 Misc/NEWS.d/next/Library/2020-10-08-18-22-28.bpo-41976.Svm0wb.rst
|
||||
|
||||
diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
|
||||
index b99fdcba7b28f..92ac1840ad7d4 100644
|
||||
--- a/Lib/ctypes/test/test_find.py
|
||||
+++ b/Lib/ctypes/test/test_find.py
|
||||
@@ -1,4 +1,5 @@
|
||||
import unittest
|
||||
+import unittest.mock
|
||||
import os.path
|
||||
import sys
|
||||
import test.support
|
||||
@@ -72,7 +73,7 @@ def test_shell_injection(self):
|
||||
|
||||
@unittest.skipUnless(sys.platform.startswith('linux'),
|
||||
'Test only valid for Linux')
|
||||
-class LibPathFindTest(unittest.TestCase):
|
||||
+class FindLibraryLinux(unittest.TestCase):
|
||||
def test_find_on_libpath(self):
|
||||
import subprocess
|
||||
import tempfile
|
||||
@@ -111,6 +112,15 @@ def test_find_on_libpath(self):
|
||||
# LD_LIBRARY_PATH)
|
||||
self.assertEqual(find_library(libname), 'lib%s.so' % libname)
|
||||
|
||||
+ def test_find_library_with_gcc(self):
|
||||
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
|
||||
+ self.assertNotEqual(find_library('c'), None)
|
||||
+
|
||||
+ def test_find_library_with_ld(self):
|
||||
+ with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
|
||||
+ unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
|
||||
+ self.assertNotEqual(find_library('c'), None)
|
||||
+
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index 97973bce001d9..0c2510e1619c8 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -93,6 +93,12 @@ def find_library(name):
|
||||
# Andreas Degert's find functions, using gcc, /sbin/ldconfig, objdump
|
||||
import re, tempfile
|
||||
|
||||
+ def _is_elf(filename):
|
||||
+ "Return True if the given file is an ELF file"
|
||||
+ elf_header = b'\x7fELF'
|
||||
+ with open(filename, 'br') as thefile:
|
||||
+ return thefile.read(4) == elf_header
|
||||
+
|
||||
def _findLib_gcc(name):
|
||||
# Run GCC's linker with the -t (aka --trace) option and examine the
|
||||
# library name it prints out. The GCC command will fail because we
|
||||
@@ -299,17 +312,22 @@ def _findLib_ld(name):
|
||||
stderr=subprocess.PIPE,
|
||||
universal_newlines=True)
|
||||
out, _ = p.communicate()
|
||||
- res = re.search(expr, os.fsdecode(out))
|
||||
- if res:
|
||||
- result = res.group(0)
|
||||
- except Exception as e:
|
||||
+ res = re.findall(expr, os.fsdecode(out))
|
||||
+ for file in res:
|
||||
+ # Check if the given file is an elf file: gcc can report
|
||||
+ # some files that are linker scripts and not actual
|
||||
+ # shared objects. See bpo-41976 for more details
|
||||
+ if not _is_elf(file):
|
||||
+ continue
|
||||
+ return os.fsdecode(file)
|
||||
+ except Exception:
|
||||
pass # result will be None
|
||||
return result
|
||||
|
||||
def find_library(name):
|
||||
# See issue #9998
|
||||
return _findSoname_ldconfig(name) or \
|
||||
- _get_soname(_findLib_gcc(name) or _findLib_ld(name))
|
||||
+ _get_soname(_findLib_gcc(name)) or _get_soname(_findLib_ld(name))
|
||||
|
||||
################################################################
|
||||
# test code
|
||||
diff --git a/Misc/NEWS.d/next/Library/2020-10-08-18-22-28.bpo-41976.Svm0wb.rst b/Misc/NEWS.d/next/Library/2020-10-08-18-22-28.bpo-41976.Svm0wb.rst
|
||||
new file mode 100644
|
||||
index 0000000000000..c8b3fc771845e
|
||||
--- /dev/null
|
||||
+++ b/Misc/NEWS.d/next/Library/2020-10-08-18-22-28.bpo-41976.Svm0wb.rst
|
||||
@@ -0,0 +1,3 @@
|
||||
+Fixed a bug that was causing :func:`ctypes.util.find_library` to return
|
||||
+``None`` when triying to locate a library in an environment when gcc>=9 is
|
||||
+available and ``ldconfig`` is not. Patch by Pablo Galindo
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
From 45dfbbb4f5b67ab83e4365564ea569334e979f8e Mon Sep 17 00:00:00 2001
|
||||
From: Ben Wolsieffer <benwolsieffer@gmail.com>
|
||||
Date: Fri, 25 Sep 2020 16:49:16 -0400
|
||||
Subject: [PATCH] Fix finding headers when cross compiling
|
||||
|
||||
When cross-compiling third-party extensions, get_python_inc() may be called to
|
||||
return the path to Python's headers. However, it uses the sys.prefix or
|
||||
sys.exec_prefix of the build Python, which returns incorrect paths when
|
||||
cross-compiling (paths pointing to build system headers).
|
||||
|
||||
To fix this, we use the INCLUDEPY and CONFINCLUDEPY conf variables, which can
|
||||
be configured to point at host Python by setting _PYTHON_SYSCONFIGDATA_NAME.
|
||||
The existing behavior is maintained on non-POSIX platforms or if a prefix is
|
||||
manually specified.
|
||||
---
|
||||
Lib/distutils/sysconfig.py | 14 ++++++++++----
|
||||
1 file changed, 10 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
|
||||
index 2bcd1dd288..567375e488 100644
|
||||
--- a/Lib/distutils/sysconfig.py
|
||||
+++ b/Lib/distutils/sysconfig.py
|
||||
@@ -84,8 +84,6 @@ def get_python_inc(plat_specific=0, prefix=None):
|
||||
If 'prefix' is supplied, use it instead of sys.base_prefix or
|
||||
sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
|
||||
"""
|
||||
- if prefix is None:
|
||||
- prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
|
||||
if os.name == "posix":
|
||||
if python_build:
|
||||
# Assume the executable is in the build directory. The
|
||||
@@ -98,9 +96,17 @@ def get_python_inc(plat_specific=0, prefix=None):
|
||||
else:
|
||||
incdir = os.path.join(get_config_var('srcdir'), 'Include')
|
||||
return os.path.normpath(incdir)
|
||||
- python_dir = 'python' + get_python_version() + build_flags
|
||||
- return os.path.join(prefix, "include", python_dir)
|
||||
+ if prefix is None:
|
||||
+ if plat_specific:
|
||||
+ return get_config_var('CONFINCLUDEPY')
|
||||
+ else:
|
||||
+ return get_config_var('INCLUDEPY')
|
||||
+ else:
|
||||
+ python_dir = 'python' + get_python_version() + build_flags
|
||||
+ return os.path.join(prefix, "include", python_dir)
|
||||
elif os.name == "nt":
|
||||
+ if prefix is None:
|
||||
+ prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
|
||||
return os.path.join(prefix, "include")
|
||||
else:
|
||||
raise DistutilsPlatformError(
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
From 105621b99cc30615c79b5aa3d12d6732e14b0d59 Mon Sep 17 00:00:00 2001
|
||||
From: Frederik Rietdijk <fridh@fridh.nl>
|
||||
Date: Mon, 28 Aug 2017 09:24:06 +0200
|
||||
Subject: [PATCH] Don't use ldconfig and speed up uuid load
|
||||
|
||||
---
|
||||
Lib/ctypes/util.py | 70 ++----------------------------------------------------
|
||||
Lib/uuid.py | 48 -------------------------------------
|
||||
2 files changed, 2 insertions(+), 116 deletions(-)
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index 339ae8aa8a..2944985c30 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -85,46 +85,7 @@ elif os.name == "posix":
|
||||
import re, tempfile
|
||||
|
||||
def _findLib_gcc(name):
|
||||
- # Run GCC's linker with the -t (aka --trace) option and examine the
|
||||
- # library name it prints out. The GCC command will fail because we
|
||||
- # haven't supplied a proper program with main(), but that does not
|
||||
- # matter.
|
||||
- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name))
|
||||
-
|
||||
- c_compiler = shutil.which('gcc')
|
||||
- if not c_compiler:
|
||||
- c_compiler = shutil.which('cc')
|
||||
- if not c_compiler:
|
||||
- # No C compiler available, give up
|
||||
- return None
|
||||
-
|
||||
- temp = tempfile.NamedTemporaryFile()
|
||||
- try:
|
||||
- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name]
|
||||
-
|
||||
- env = dict(os.environ)
|
||||
- env['LC_ALL'] = 'C'
|
||||
- env['LANG'] = 'C'
|
||||
- try:
|
||||
- proc = subprocess.Popen(args,
|
||||
- stdout=subprocess.PIPE,
|
||||
- stderr=subprocess.STDOUT,
|
||||
- env=env)
|
||||
- except OSError: # E.g. bad executable
|
||||
- return None
|
||||
- with proc:
|
||||
- trace = proc.stdout.read()
|
||||
- finally:
|
||||
- try:
|
||||
- temp.close()
|
||||
- except FileNotFoundError:
|
||||
- # Raised if the file was already removed, which is the normal
|
||||
- # behaviour of GCC if linking fails
|
||||
- pass
|
||||
- res = re.search(expr, trace)
|
||||
- if not res:
|
||||
- return None
|
||||
- return os.fsdecode(res.group(0))
|
||||
+ return None
|
||||
|
||||
|
||||
if sys.platform == "sunos5":
|
||||
@@ -246,34 +207,7 @@ elif os.name == "posix":
|
||||
else:
|
||||
|
||||
def _findSoname_ldconfig(name):
|
||||
- import struct
|
||||
- if struct.calcsize('l') == 4:
|
||||
- machine = os.uname().machine + '-32'
|
||||
- else:
|
||||
- machine = os.uname().machine + '-64'
|
||||
- mach_map = {
|
||||
- 'x86_64-64': 'libc6,x86-64',
|
||||
- 'ppc64-64': 'libc6,64bit',
|
||||
- 'sparc64-64': 'libc6,64bit',
|
||||
- 's390x-64': 'libc6,64bit',
|
||||
- 'ia64-64': 'libc6,IA-64',
|
||||
- }
|
||||
- abi_type = mach_map.get(machine, 'libc6')
|
||||
-
|
||||
- # XXX assuming GLIBC's ldconfig (with option -p)
|
||||
- regex = r'\s+(lib%s\.[^\s]+)\s+\(%s'
|
||||
- regex = os.fsencode(regex % (re.escape(name), abi_type))
|
||||
- try:
|
||||
- with subprocess.Popen(['/sbin/ldconfig', '-p'],
|
||||
- stdin=subprocess.DEVNULL,
|
||||
- stderr=subprocess.DEVNULL,
|
||||
- stdout=subprocess.PIPE,
|
||||
- env={'LC_ALL': 'C', 'LANG': 'C'}) as p:
|
||||
- res = re.search(regex, p.stdout.read())
|
||||
- if res:
|
||||
- return os.fsdecode(res.group(1))
|
||||
- except OSError:
|
||||
- pass
|
||||
+ return None
|
||||
|
||||
def _findLib_ld(name):
|
||||
# See issue #9998 for why this is needed
|
||||
diff --git a/Lib/uuid.py b/Lib/uuid.py
|
||||
index 200c800b34..31160ace95 100644
|
||||
--- a/Lib/uuid.py
|
||||
+++ b/Lib/uuid.py
|
||||
@@ -455,57 +455,9 @@ def _netbios_getnode():
|
||||
continue
|
||||
return int.from_bytes(bytes, 'big')
|
||||
|
||||
-# Thanks to Thomas Heller for ctypes and for his help with its use here.
|
||||
|
||||
-# If ctypes is available, use it to find system routines for UUID generation.
|
||||
-# XXX This makes the module non-thread-safe!
|
||||
_uuid_generate_time = _UuidCreate = None
|
||||
-try:
|
||||
- import ctypes, ctypes.util
|
||||
- import sys
|
||||
|
||||
- # The uuid_generate_* routines are provided by libuuid on at least
|
||||
- # Linux and FreeBSD, and provided by libc on Mac OS X.
|
||||
- _libnames = ['uuid']
|
||||
- if not sys.platform.startswith('win'):
|
||||
- _libnames.append('c')
|
||||
- for libname in _libnames:
|
||||
- try:
|
||||
- lib = ctypes.CDLL(ctypes.util.find_library(libname))
|
||||
- except Exception:
|
||||
- continue
|
||||
- if hasattr(lib, 'uuid_generate_time'):
|
||||
- _uuid_generate_time = lib.uuid_generate_time
|
||||
- break
|
||||
- del _libnames
|
||||
-
|
||||
- # The uuid_generate_* functions are broken on MacOS X 10.5, as noted
|
||||
- # in issue #8621 the function generates the same sequence of values
|
||||
- # in the parent process and all children created using fork (unless
|
||||
- # those children use exec as well).
|
||||
- #
|
||||
- # Assume that the uuid_generate functions are broken from 10.5 onward,
|
||||
- # the test can be adjusted when a later version is fixed.
|
||||
- if sys.platform == 'darwin':
|
||||
- if int(os.uname().release.split('.')[0]) >= 9:
|
||||
- _uuid_generate_time = None
|
||||
-
|
||||
- # On Windows prior to 2000, UuidCreate gives a UUID containing the
|
||||
- # hardware address. On Windows 2000 and later, UuidCreate makes a
|
||||
- # random UUID and UuidCreateSequential gives a UUID containing the
|
||||
- # hardware address. These routines are provided by the RPC runtime.
|
||||
- # NOTE: at least on Tim's WinXP Pro SP2 desktop box, while the last
|
||||
- # 6 bytes returned by UuidCreateSequential are fixed, they don't appear
|
||||
- # to bear any relationship to the MAC address of any network device
|
||||
- # on the box.
|
||||
- try:
|
||||
- lib = ctypes.windll.rpcrt4
|
||||
- except:
|
||||
- lib = None
|
||||
- _UuidCreate = getattr(lib, 'UuidCreateSequential',
|
||||
- getattr(lib, 'UuidCreate', None))
|
||||
-except:
|
||||
- pass
|
||||
|
||||
def _unixdll_getnode():
|
||||
"""Get the hardware address on Unix using ctypes."""
|
||||
--
|
||||
2.14.1
|
||||
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
Backport from CPython 3.8 of a good list of tests to run for PGO.
|
||||
|
||||
Upstream commit:
|
||||
https://github.com/python/cpython/commit/4e16a4a31
|
||||
|
||||
Upstream discussion:
|
||||
https://bugs.python.org/issue36044
|
||||
|
||||
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
||||
index 00fdd21ce..713dc1e53 100644
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -259,7 +259,7 @@ TCLTK_LIBS=
|
||||
# The task to run while instrumented when building the profile-opt target.
|
||||
# We exclude unittests with -x that take a rediculious amount of time to
|
||||
# run in the instrumented training build or do not provide much value.
|
||||
-PROFILE_TASK=-m test.regrtest --pgo
|
||||
+PROFILE_TASK=-m test.regrtest --pgo test_array test_base64 test_binascii test_binop test_bisect test_bytes test_bz2 test_cmath test_codecs test_collections test_complex test_dataclasses test_datetime test_decimal test_difflib test_embed test_float test_fstring test_functools test_generators test_hashlib test_heapq test_int test_itertools test_json test_long test_lzma test_math test_memoryview test_operator test_ordered_dict test_pickle test_pprint test_re test_set test_sqlite test_statistics test_struct test_tabnanny test_time test_unicode test_xml_etree test_xml_etree_c
|
||||
|
||||
# report files for gcov / lcov coverage report
|
||||
COVERAGE_INFO= $(abs_builddir)/coverage.info
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
diff --git a/setup.py b/setup.py
|
||||
index 2779658..902d0eb 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -1699,9 +1699,6 @@ class PyBuildExt(build_ext):
|
||||
# Rather than complicate the code below, detecting and building
|
||||
# AquaTk is a separate method. Only one Tkinter will be built on
|
||||
# Darwin - either AquaTk, if it is found, or X11 based Tk.
|
||||
- if (host_platform == 'darwin' and
|
||||
- self.detect_tkinter_darwin(inc_dirs, lib_dirs)):
|
||||
- return
|
||||
|
||||
# Assume we haven't found any of the libraries or include files
|
||||
# The versions with dots are used on Unix, and the versions without
|
||||
@@ -1747,22 +1744,6 @@ class PyBuildExt(build_ext):
|
||||
if dir not in include_dirs:
|
||||
include_dirs.append(dir)
|
||||
|
||||
- # Check for various platform-specific directories
|
||||
- if host_platform == 'sunos5':
|
||||
- include_dirs.append('/usr/openwin/include')
|
||||
- added_lib_dirs.append('/usr/openwin/lib')
|
||||
- elif os.path.exists('/usr/X11R6/include'):
|
||||
- include_dirs.append('/usr/X11R6/include')
|
||||
- added_lib_dirs.append('/usr/X11R6/lib64')
|
||||
- added_lib_dirs.append('/usr/X11R6/lib')
|
||||
- elif os.path.exists('/usr/X11R5/include'):
|
||||
- include_dirs.append('/usr/X11R5/include')
|
||||
- added_lib_dirs.append('/usr/X11R5/lib')
|
||||
- else:
|
||||
- # Assume default location for X11
|
||||
- include_dirs.append('/usr/X11/include')
|
||||
- added_lib_dirs.append('/usr/X11/lib')
|
||||
-
|
||||
# If Cygwin, then verify that X is installed before proceeding
|
||||
if host_platform == 'cygwin':
|
||||
x11_inc = find_file('X11/Xlib.h', [], include_dirs)
|
||||
@@ -1786,10 +1767,6 @@ class PyBuildExt(build_ext):
|
||||
if host_platform in ['aix3', 'aix4']:
|
||||
libs.append('ld')
|
||||
|
||||
- # Finally, link with the X11 libraries (not appropriate on cygwin)
|
||||
- if host_platform != "cygwin":
|
||||
- libs.append('X11')
|
||||
-
|
||||
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
|
||||
define_macros=[('WITH_APPINIT', 1)] + defs,
|
||||
include_dirs = include_dirs,
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
|
||||
index c3682b4..16826c6 100644
|
||||
--- a/Modules/posixmodule.c
|
||||
+++ b/Modules/posixmodule.c
|
||||
@@ -5880,15 +5880,13 @@ error:
|
||||
#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) || defined(HAVE_DEV_PTMX)
|
||||
#ifdef HAVE_PTY_H
|
||||
#include <pty.h>
|
||||
-#else
|
||||
+#endif
|
||||
#ifdef HAVE_LIBUTIL_H
|
||||
#include <libutil.h>
|
||||
-#else
|
||||
+#endif
|
||||
#ifdef HAVE_UTIL_H
|
||||
#include <util.h>
|
||||
-#endif /* HAVE_UTIL_H */
|
||||
-#endif /* HAVE_LIBUTIL_H */
|
||||
-#endif /* HAVE_PTY_H */
|
||||
+#endif
|
||||
#ifdef HAVE_STROPTS_H
|
||||
#include <stropts.h>
|
||||
#endif
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
From debccd4be0a8d619770f63622d9de1b451dd02ac Mon Sep 17 00:00:00 2001
|
||||
From: Ben Wolsieffer <benwolsieffer@gmail.com>
|
||||
Date: Fri, 25 Sep 2020 16:49:16 -0400
|
||||
Subject: [PATCH] Fix finding headers when cross compiling
|
||||
|
||||
When cross-compiling third-party extensions, get_python_inc() may be called to
|
||||
return the path to Python's headers. However, it uses the sys.prefix or
|
||||
sys.exec_prefix of the build Python, which returns incorrect paths when
|
||||
cross-compiling (paths pointing to build system headers).
|
||||
|
||||
To fix this, we use the INCLUDEPY and CONFINCLUDEPY conf variables, which can
|
||||
be configured to point at host Python by setting _PYTHON_SYSCONFIGDATA_NAME.
|
||||
The existing behavior is maintained on non-POSIX platforms or if a prefix is
|
||||
manually specified.
|
||||
---
|
||||
Lib/distutils/sysconfig.py | 14 ++++++++++----
|
||||
1 file changed, 10 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
|
||||
index 37feae5df7..6d4ad06696 100644
|
||||
--- a/Lib/distutils/sysconfig.py
|
||||
+++ b/Lib/distutils/sysconfig.py
|
||||
@@ -95,8 +95,6 @@ def get_python_inc(plat_specific=0, prefix=None):
|
||||
If 'prefix' is supplied, use it instead of sys.base_prefix or
|
||||
sys.base_exec_prefix -- i.e., ignore 'plat_specific'.
|
||||
"""
|
||||
- if prefix is None:
|
||||
- prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
|
||||
if os.name == "posix":
|
||||
if python_build:
|
||||
# Assume the executable is in the build directory. The
|
||||
@@ -109,9 +107,17 @@ def get_python_inc(plat_specific=0, prefix=None):
|
||||
else:
|
||||
incdir = os.path.join(get_config_var('srcdir'), 'Include')
|
||||
return os.path.normpath(incdir)
|
||||
- python_dir = 'python' + get_python_version() + build_flags
|
||||
- return os.path.join(prefix, "include", python_dir)
|
||||
+ if prefix is None:
|
||||
+ if plat_specific:
|
||||
+ return get_config_var('CONFINCLUDEPY')
|
||||
+ else:
|
||||
+ return get_config_var('INCLUDEPY')
|
||||
+ else:
|
||||
+ python_dir = 'python' + get_python_version() + build_flags
|
||||
+ return os.path.join(prefix, "include", python_dir)
|
||||
elif os.name == "nt":
|
||||
+ if prefix is None:
|
||||
+ prefix = plat_specific and BASE_EXEC_PREFIX or BASE_PREFIX
|
||||
if python_build:
|
||||
# Include both the include and PC dir to ensure we can find
|
||||
# pyconfig.h
|
||||
--
|
||||
2.28.0
|
||||
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
From a612c481f6116955d420db5ae1fe4c1eb93eb2f2 Mon Sep 17 00:00:00 2001
|
||||
From: Marcin Niemira <marcin.niemira@gmail.com>
|
||||
Date: Sun, 9 Jun 2019 07:05:06 +1000
|
||||
Subject: [PATCH] bpo-11122: fix hardcoded path checking for rpmbuild in
|
||||
bdist_rpm.py (GH-10594) (cherry picked from commit
|
||||
45a14942c969ed508b35abd5e116cb18f84ce5b4)
|
||||
|
||||
Co-authored-by: Marcin Niemira <marcin.niemira@gmail.com>
|
||||
---
|
||||
Lib/distutils/command/bdist_rpm.py | 5 +----
|
||||
.../next/Library/2018-11-12-19-08-50.bpo-11122.Gj7BQn.rst | 1 +
|
||||
2 files changed, 2 insertions(+), 4 deletions(-)
|
||||
create mode 100644 Misc/NEWS.d/next/Library/2018-11-12-19-08-50.bpo-11122.Gj7BQn.rst
|
||||
|
||||
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
|
||||
index 20ca7ac6dcffa..74381cc69a6ce 100644
|
||||
--- a/Lib/distutils/command/bdist_rpm.py
|
||||
+++ b/Lib/distutils/command/bdist_rpm.py
|
||||
@@ -309,10 +309,7 @@ def run(self):
|
||||
|
||||
# build package
|
||||
log.info("building RPMs")
|
||||
- rpm_cmd = ['rpm']
|
||||
- if os.path.exists('/usr/bin/rpmbuild') or \
|
||||
- os.path.exists('/bin/rpmbuild'):
|
||||
- rpm_cmd = ['rpmbuild']
|
||||
+ rpm_cmd = ['rpmbuild']
|
||||
|
||||
if self.source_only: # what kind of RPMs?
|
||||
rpm_cmd.append('-bs')
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
From ba458f33f335b217d078fdce56e9c6f9f93adb49 Mon Sep 17 00:00:00 2001
|
||||
From: Frederik Rietdijk <fridh@fridh.nl>
|
||||
Date: Mon, 28 Aug 2017 09:24:06 +0200
|
||||
Subject: [PATCH] Don't use ldconfig
|
||||
|
||||
---
|
||||
Lib/ctypes/util.py | 78 ++--------------------------------------------
|
||||
1 file changed, 2 insertions(+), 76 deletions(-)
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index 0c2510e..79635a8 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -100,54 +100,7 @@ elif os.name == "posix":
|
||||
return thefile.read(4) == elf_header
|
||||
|
||||
def _findLib_gcc(name):
|
||||
- # Run GCC's linker with the -t (aka --trace) option and examine the
|
||||
- # library name it prints out. The GCC command will fail because we
|
||||
- # haven't supplied a proper program with main(), but that does not
|
||||
- # matter.
|
||||
- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name))
|
||||
-
|
||||
- c_compiler = shutil.which('gcc')
|
||||
- if not c_compiler:
|
||||
- c_compiler = shutil.which('cc')
|
||||
- if not c_compiler:
|
||||
- # No C compiler available, give up
|
||||
- return None
|
||||
-
|
||||
- temp = tempfile.NamedTemporaryFile()
|
||||
- try:
|
||||
- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name]
|
||||
-
|
||||
- env = dict(os.environ)
|
||||
- env['LC_ALL'] = 'C'
|
||||
- env['LANG'] = 'C'
|
||||
- try:
|
||||
- proc = subprocess.Popen(args,
|
||||
- stdout=subprocess.PIPE,
|
||||
- stderr=subprocess.STDOUT,
|
||||
- env=env)
|
||||
- except OSError: # E.g. bad executable
|
||||
- return None
|
||||
- with proc:
|
||||
- trace = proc.stdout.read()
|
||||
- finally:
|
||||
- try:
|
||||
- temp.close()
|
||||
- except FileNotFoundError:
|
||||
- # Raised if the file was already removed, which is the normal
|
||||
- # behaviour of GCC if linking fails
|
||||
- pass
|
||||
- res = re.findall(expr, trace)
|
||||
- if not res:
|
||||
- return None
|
||||
-
|
||||
- for file in res:
|
||||
- # Check if the given file is an elf file: gcc can report
|
||||
- # some files that are linker scripts and not actual
|
||||
- # shared objects. See bpo-41976 for more details
|
||||
- if not _is_elf(file):
|
||||
- continue
|
||||
- return os.fsdecode(file)
|
||||
-
|
||||
+ return None
|
||||
|
||||
if sys.platform == "sunos5":
|
||||
# use /usr/ccs/bin/dump on solaris
|
||||
@@ -268,34 +221,7 @@ elif os.name == "posix":
|
||||
else:
|
||||
|
||||
def _findSoname_ldconfig(name):
|
||||
- import struct
|
||||
- if struct.calcsize('l') == 4:
|
||||
- machine = os.uname().machine + '-32'
|
||||
- else:
|
||||
- machine = os.uname().machine + '-64'
|
||||
- mach_map = {
|
||||
- 'x86_64-64': 'libc6,x86-64',
|
||||
- 'ppc64-64': 'libc6,64bit',
|
||||
- 'sparc64-64': 'libc6,64bit',
|
||||
- 's390x-64': 'libc6,64bit',
|
||||
- 'ia64-64': 'libc6,IA-64',
|
||||
- }
|
||||
- abi_type = mach_map.get(machine, 'libc6')
|
||||
-
|
||||
- # XXX assuming GLIBC's ldconfig (with option -p)
|
||||
- regex = r'\s+(lib%s\.[^\s]+)\s+\(%s'
|
||||
- regex = os.fsencode(regex % (re.escape(name), abi_type))
|
||||
- try:
|
||||
- with subprocess.Popen(['/sbin/ldconfig', '-p'],
|
||||
- stdin=subprocess.DEVNULL,
|
||||
- stderr=subprocess.DEVNULL,
|
||||
- stdout=subprocess.PIPE,
|
||||
- env={'LC_ALL': 'C', 'LANG': 'C'}) as p:
|
||||
- res = re.search(regex, p.stdout.read())
|
||||
- if res:
|
||||
- return os.fsdecode(res.group(1))
|
||||
- except OSError:
|
||||
- pass
|
||||
+ return None
|
||||
|
||||
def _findLib_ld(name):
|
||||
# See issue #9998 for why this is needed
|
||||
--
|
||||
2.30.0
|
||||
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
From e6b247c8e524dbe5fc03b3492f628d0d5348bc49 Mon Sep 17 00:00:00 2001
|
||||
From: Victor Stinner <vstinner@redhat.com>
|
||||
Date: Tue, 18 Dec 2018 14:47:21 +0100
|
||||
Subject: [PATCH] bpo-35523: Remove ctypes callback workaround (GH-11211)
|
||||
|
||||
Remove ctypes callback workaround: no longer create a callback at startup.
|
||||
Avoid SELinux alert on "import ctypes" and "import uuid".
|
||||
---
|
||||
Lib/ctypes/__init__.py | 5 -----
|
||||
.../next/Library/2018-12-18-13-52-13.bpo-35523.SkoMno.rst | 2 ++
|
||||
2 files changed, 2 insertions(+), 5 deletions(-)
|
||||
create mode 100644 Misc/NEWS.d/next/Library/2018-12-18-13-52-13.bpo-35523.SkoMno.rst
|
||||
|
||||
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
|
||||
index 6146773988648..5f78beda5866e 100644
|
||||
--- a/Lib/ctypes/__init__.py
|
||||
+++ b/Lib/ctypes/__init__.py
|
||||
@@ -266,11 +266,6 @@ def _reset_cache():
|
||||
# _SimpleCData.c_char_p_from_param
|
||||
POINTER(c_char).from_param = c_char_p.from_param
|
||||
_pointer_type_cache[None] = c_void_p
|
||||
- # XXX for whatever reasons, creating the first instance of a callback
|
||||
- # function is needed for the unittests on Win64 to succeed. This MAY
|
||||
- # be a compiler bug, since the problem occurs only when _ctypes is
|
||||
- # compiled with the MS SDK compiler. Or an uninitialized variable?
|
||||
- CFUNCTYPE(c_int)(lambda: None)
|
||||
|
||||
def create_unicode_buffer(init, size=None):
|
||||
"""create_unicode_buffer(aString) -> character array
|
||||
diff --git a/Misc/NEWS.d/next/Library/2018-12-18-13-52-13.bpo-35523.SkoMno.rst b/Misc/NEWS.d/next/Library/2018-12-18-13-52-13.bpo-35523.SkoMno.rst
|
||||
new file mode 100644
|
||||
index 0000000000000..94a9fd257383e
|
||||
--- /dev/null
|
||||
+++ b/Misc/NEWS.d/next/Library/2018-12-18-13-52-13.bpo-35523.SkoMno.rst
|
||||
@@ -0,0 +1,2 @@
|
||||
+Remove :mod:`ctypes` callback workaround: no longer create a callback at
|
||||
+startup. Avoid SELinux alert on ``import ctypes`` and ``import uuid``.
|
||||
|
|
@ -0,0 +1,248 @@
|
|||
--- a/Lib/_osx_support.py
|
||||
+++ b/Lib/_osx_support.py
|
||||
@@ -14,13 +14,13 @@ __all__ = [
|
||||
# configuration variables that may contain universal build flags,
|
||||
# like "-arch" or "-isdkroot", that may need customization for
|
||||
# the user environment
|
||||
-_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS', 'BASECFLAGS',
|
||||
- 'BLDSHARED', 'LDSHARED', 'CC', 'CXX',
|
||||
- 'PY_CFLAGS', 'PY_LDFLAGS', 'PY_CPPFLAGS',
|
||||
- 'PY_CORE_CFLAGS', 'PY_CORE_LDFLAGS')
|
||||
+_UNIVERSAL_CONFIG_VARS = ('CFLAGS', 'CXXFLAGS', 'LDFLAGS', 'CPPFLAGS',
|
||||
+ 'BASECFLAGS', 'BLDSHARED', 'LDSHARED', 'LDCXXSHARED',
|
||||
+ 'CC', 'CXX', 'PY_CFLAGS', 'PY_LDFLAGS',
|
||||
+ 'PY_CPPFLAGS', 'PY_CORE_LDFLAGS', 'PY_CORE_CFLAGS')
|
||||
|
||||
# configuration variables that may contain compiler calls
|
||||
-_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'CC', 'CXX')
|
||||
+_COMPILER_CONFIG_VARS = ('BLDSHARED', 'LDSHARED', 'LDCXXSHARED', 'CC', 'CXX')
|
||||
|
||||
# prefix added to original configuration variable names
|
||||
_INITPRE = '_OSX_SUPPORT_INITIAL_'
|
||||
--- a/Lib/distutils/cygwinccompiler.py
|
||||
+++ b/Lib/distutils/cygwinccompiler.py
|
||||
@@ -125,8 +125,10 @@ class CygwinCCompiler(UnixCCompiler):
|
||||
# dllwrap 2.10.90 is buggy
|
||||
if self.ld_version >= "2.10.90":
|
||||
self.linker_dll = "gcc"
|
||||
+ self.linker_dll_cxx = "g++"
|
||||
else:
|
||||
self.linker_dll = "dllwrap"
|
||||
+ self.linker_dll_cxx = "dllwrap"
|
||||
|
||||
# ld_version >= "2.13" support -shared so use it instead of
|
||||
# -mdll -static
|
||||
@@ -140,9 +142,13 @@ class CygwinCCompiler(UnixCCompiler):
|
||||
self.set_executables(compiler='gcc -mcygwin -O -Wall',
|
||||
compiler_so='gcc -mcygwin -mdll -O -Wall',
|
||||
compiler_cxx='g++ -mcygwin -O -Wall',
|
||||
+ compiler_so_cxx='g++ -mcygwin -mdll -O -Wall',
|
||||
linker_exe='gcc -mcygwin',
|
||||
linker_so=('%s -mcygwin %s' %
|
||||
- (self.linker_dll, shared_option)))
|
||||
+ (self.linker_dll, shared_option)),
|
||||
+ linker_exe_cxx='g++ -mcygwin',
|
||||
+ linker_so_cxx=('%s -mcygwin %s' %
|
||||
+ (self.linker_dll_cxx, shared_option)))
|
||||
|
||||
# cygwin and mingw32 need different sets of libraries
|
||||
if self.gcc_version == "2.91.57":
|
||||
@@ -166,8 +172,12 @@ class CygwinCCompiler(UnixCCompiler):
|
||||
raise CompileError(msg)
|
||||
else: # for other files use the C-compiler
|
||||
try:
|
||||
- self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||
- extra_postargs)
|
||||
+ if self.detect_language(src) == 'c++':
|
||||
+ self.spawn(self.compiler_so_cxx + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
+ else:
|
||||
+ self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
except DistutilsExecError as msg:
|
||||
raise CompileError(msg)
|
||||
|
||||
@@ -302,9 +312,14 @@ class Mingw32CCompiler(CygwinCCompiler):
|
||||
self.set_executables(compiler='gcc -O -Wall',
|
||||
compiler_so='gcc -mdll -O -Wall',
|
||||
compiler_cxx='g++ -O -Wall',
|
||||
+ compiler_so_cxx='g++ -mdll -O -Wall',
|
||||
linker_exe='gcc',
|
||||
linker_so='%s %s %s'
|
||||
% (self.linker_dll, shared_option,
|
||||
+ entry_point),
|
||||
+ linker_exe_cxx='g++',
|
||||
+ linker_so_cxx='%s %s %s'
|
||||
+ % (self.linker_dll_cxx, shared_option,
|
||||
entry_point))
|
||||
# Maybe we should also append -mthreads, but then the finished
|
||||
# dlls need another dll (mingwm10.dll see Mingw32 docs)
|
||||
--- a/Lib/distutils/sysconfig.py
|
||||
+++ b/Lib/distutils/sysconfig.py
|
||||
@@ -170,9 +170,11 @@ def customize_compiler(compiler):
|
||||
_osx_support.customize_compiler(_config_vars)
|
||||
_config_vars['CUSTOMIZED_OSX_COMPILER'] = 'True'
|
||||
|
||||
- (cc, cxx, cflags, ccshared, ldshared, shlib_suffix, ar, ar_flags) = \
|
||||
- get_config_vars('CC', 'CXX', 'CFLAGS',
|
||||
- 'CCSHARED', 'LDSHARED', 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
|
||||
+ (cc, cxx, cflags, ccshared, ldshared, ldcxxshared, shlib_suffix, ar, ar_flags) = \
|
||||
+ get_config_vars('CC', 'CXX', 'CFLAGS', 'CCSHARED', 'LDSHARED', 'LDCXXSHARED',
|
||||
+ 'SHLIB_SUFFIX', 'AR', 'ARFLAGS')
|
||||
+
|
||||
+ cxxflags = cflags
|
||||
|
||||
if 'CC' in os.environ:
|
||||
newcc = os.environ['CC']
|
||||
@@ -187,19 +189,27 @@ def customize_compiler(compiler):
|
||||
cxx = os.environ['CXX']
|
||||
if 'LDSHARED' in os.environ:
|
||||
ldshared = os.environ['LDSHARED']
|
||||
+ if 'LDCXXSHARED' in os.environ:
|
||||
+ ldcxxshared = os.environ['LDCXXSHARED']
|
||||
if 'CPP' in os.environ:
|
||||
cpp = os.environ['CPP']
|
||||
else:
|
||||
cpp = cc + " -E" # not always
|
||||
if 'LDFLAGS' in os.environ:
|
||||
ldshared = ldshared + ' ' + os.environ['LDFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['LDFLAGS']
|
||||
if 'CFLAGS' in os.environ:
|
||||
- cflags = cflags + ' ' + os.environ['CFLAGS']
|
||||
+ cflags = os.environ['CFLAGS']
|
||||
ldshared = ldshared + ' ' + os.environ['CFLAGS']
|
||||
+ if 'CXXFLAGS' in os.environ:
|
||||
+ cxxflags = os.environ['CXXFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['CXXFLAGS']
|
||||
if 'CPPFLAGS' in os.environ:
|
||||
cpp = cpp + ' ' + os.environ['CPPFLAGS']
|
||||
cflags = cflags + ' ' + os.environ['CPPFLAGS']
|
||||
+ cxxflags = cxxflags + ' ' + os.environ['CPPFLAGS']
|
||||
ldshared = ldshared + ' ' + os.environ['CPPFLAGS']
|
||||
+ ldcxxshared = ldcxxshared + ' ' + os.environ['CPPFLAGS']
|
||||
if 'AR' in os.environ:
|
||||
ar = os.environ['AR']
|
||||
if 'ARFLAGS' in os.environ:
|
||||
@@ -208,13 +218,17 @@ def customize_compiler(compiler):
|
||||
archiver = ar + ' ' + ar_flags
|
||||
|
||||
cc_cmd = cc + ' ' + cflags
|
||||
+ cxx_cmd = cxx + ' ' + cxxflags
|
||||
compiler.set_executables(
|
||||
preprocessor=cpp,
|
||||
compiler=cc_cmd,
|
||||
compiler_so=cc_cmd + ' ' + ccshared,
|
||||
- compiler_cxx=cxx,
|
||||
+ compiler_cxx=cxx_cmd,
|
||||
+ compiler_so_cxx=cxx_cmd + ' ' + ccshared,
|
||||
linker_so=ldshared,
|
||||
linker_exe=cc,
|
||||
+ linker_so_cxx=ldcxxshared,
|
||||
+ linker_exe_cxx=cxx,
|
||||
archiver=archiver)
|
||||
|
||||
compiler.shared_lib_extension = shlib_suffix
|
||||
--- a/Lib/distutils/unixccompiler.py
|
||||
+++ b/Lib/distutils/unixccompiler.py
|
||||
@@ -52,14 +52,17 @@ class UnixCCompiler(CCompiler):
|
||||
# are pretty generic; they will probably have to be set by an outsider
|
||||
# (eg. using information discovered by the sysconfig about building
|
||||
# Python extensions).
|
||||
- executables = {'preprocessor' : None,
|
||||
- 'compiler' : ["cc"],
|
||||
- 'compiler_so' : ["cc"],
|
||||
- 'compiler_cxx' : ["cc"],
|
||||
- 'linker_so' : ["cc", "-shared"],
|
||||
- 'linker_exe' : ["cc"],
|
||||
- 'archiver' : ["ar", "-cr"],
|
||||
- 'ranlib' : None,
|
||||
+ executables = {'preprocessor' : None,
|
||||
+ 'compiler' : ["cc"],
|
||||
+ 'compiler_so' : ["cc"],
|
||||
+ 'compiler_cxx' : ["c++"],
|
||||
+ 'compiler_so_cxx' : ["c++"],
|
||||
+ 'linker_so' : ["cc", "-shared"],
|
||||
+ 'linker_exe' : ["cc"],
|
||||
+ 'linker_so_cxx' : ["c++", "-shared"],
|
||||
+ 'linker_exe_cxx' : ["c++"],
|
||||
+ 'archiver' : ["ar", "-cr"],
|
||||
+ 'ranlib' : None,
|
||||
}
|
||||
|
||||
if sys.platform[:6] == "darwin":
|
||||
@@ -110,12 +113,19 @@ class UnixCCompiler(CCompiler):
|
||||
|
||||
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
|
||||
compiler_so = self.compiler_so
|
||||
+ compiler_so_cxx = self.compiler_so_cxx
|
||||
if sys.platform == 'darwin':
|
||||
compiler_so = _osx_support.compiler_fixup(compiler_so,
|
||||
cc_args + extra_postargs)
|
||||
+ compiler_so_cxx = _osx_support.compiler_fixup(compiler_so_cxx,
|
||||
+ cc_args + extra_postargs)
|
||||
try:
|
||||
- self.spawn(compiler_so + cc_args + [src, '-o', obj] +
|
||||
- extra_postargs)
|
||||
+ if self.detect_language(src) == 'c++':
|
||||
+ self.spawn(compiler_so_cxx + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
+ else:
|
||||
+ self.spawn(compiler_so + cc_args + [src, '-o', obj] +
|
||||
+ extra_postargs)
|
||||
except DistutilsExecError as msg:
|
||||
raise CompileError(msg)
|
||||
|
||||
@@ -173,30 +183,16 @@ class UnixCCompiler(CCompiler):
|
||||
ld_args.extend(extra_postargs)
|
||||
self.mkpath(os.path.dirname(output_filename))
|
||||
try:
|
||||
- if target_desc == CCompiler.EXECUTABLE:
|
||||
- linker = self.linker_exe[:]
|
||||
+ if target_lang == "c++":
|
||||
+ if target_desc == CCompiler.EXECUTABLE:
|
||||
+ linker = self.linker_exe_cxx[:]
|
||||
+ else:
|
||||
+ linker = self.linker_so_cxx[:]
|
||||
else:
|
||||
- linker = self.linker_so[:]
|
||||
- if target_lang == "c++" and self.compiler_cxx:
|
||||
- # skip over environment variable settings if /usr/bin/env
|
||||
- # is used to set up the linker's environment.
|
||||
- # This is needed on OSX. Note: this assumes that the
|
||||
- # normal and C++ compiler have the same environment
|
||||
- # settings.
|
||||
- i = 0
|
||||
- if os.path.basename(linker[0]) == "env":
|
||||
- i = 1
|
||||
- while '=' in linker[i]:
|
||||
- i += 1
|
||||
-
|
||||
- if os.path.basename(linker[i]) == 'ld_so_aix':
|
||||
- # AIX platforms prefix the compiler with the ld_so_aix
|
||||
- # script, so we need to adjust our linker index
|
||||
- offset = 1
|
||||
+ if target_desc == CCompiler.EXECUTABLE:
|
||||
+ linker = self.linker_exe[:]
|
||||
else:
|
||||
- offset = 0
|
||||
-
|
||||
- linker[i+offset] = self.compiler_cxx[i]
|
||||
+ linker = self.linker_so[:]
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
linker = _osx_support.compiler_fixup(linker, ld_args)
|
||||
--- a/Makefile.pre.in
|
||||
+++ b/Makefile.pre.in
|
||||
@@ -584,10 +584,10 @@ sharedmods: $(BUILDPYTHON) pybuilddir.txt Modules/_math.o
|
||||
*\ -s*|s*) quiet="-q";; \
|
||||
*) quiet="";; \
|
||||
esac; \
|
||||
- echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
|
||||
+ echo "$(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' CFLAGS='$(PY_CFLAGS)' \
|
||||
_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
|
||||
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build"; \
|
||||
- $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \
|
||||
+ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' CFLAGS='$(PY_CFLAGS)' \
|
||||
_TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
|
||||
$(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
From 1911995b1a1252d80bf2b9651840e185a1a6baf5 Mon Sep 17 00:00:00 2001
|
||||
From: Hong Xu <hong@topbug.net>
|
||||
Date: Thu, 25 Jul 2019 10:25:55 -0700
|
||||
Subject: [PATCH] On all posix systems, not just Darwin, set LDSHARED (if not
|
||||
set) according to CC
|
||||
|
||||
This patch is slightly different from https://bugs.python.org/issue24935
|
||||
, except that we now handle LDSHARED according to CC on all posix
|
||||
systems, not just Darwin or Linux.
|
||||
---
|
||||
Lib/distutils/sysconfig.py | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
|
||||
index 37feae5df7..9fdce6896d 100644
|
||||
--- a/Lib/distutils/sysconfig.py
|
||||
+++ b/Lib/distutils/sysconfig.py
|
||||
@@ -199,10 +199,10 @@ def customize_compiler(compiler):
|
||||
|
||||
if 'CC' in os.environ:
|
||||
newcc = os.environ['CC']
|
||||
- if (sys.platform == 'darwin'
|
||||
+ if (os.name == 'posix'
|
||||
and 'LDSHARED' not in os.environ
|
||||
and ldshared.startswith(cc)):
|
||||
- # On OS X, if CC is overridden, use that as the default
|
||||
+ # On POSIX systems, if CC is overridden, use that as the default
|
||||
# command for LDSHARED as well
|
||||
ldshared = newcc + ldshared[len(cc):]
|
||||
cc = newcc
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
From 66f492d2eda94bd64db833839a325caf6ba0fed5 Mon Sep 17 00:00:00 2001
|
||||
From: Greg Roodt <greg@canva.com>
|
||||
Date: Wed, 9 Dec 2020 17:59:24 +1100
|
||||
Subject: [PATCH] Don't use ldconfig
|
||||
|
||||
---
|
||||
Lib/ctypes/util.py | 77 ++--------------------------------------------
|
||||
1 file changed, 2 insertions(+), 75 deletions(-)
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index 0c2510e161..7fb98af308 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -100,53 +100,7 @@ elif os.name == "posix":
|
||||
return thefile.read(4) == elf_header
|
||||
|
||||
def _findLib_gcc(name):
|
||||
- # Run GCC's linker with the -t (aka --trace) option and examine the
|
||||
- # library name it prints out. The GCC command will fail because we
|
||||
- # haven't supplied a proper program with main(), but that does not
|
||||
- # matter.
|
||||
- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name))
|
||||
-
|
||||
- c_compiler = shutil.which('gcc')
|
||||
- if not c_compiler:
|
||||
- c_compiler = shutil.which('cc')
|
||||
- if not c_compiler:
|
||||
- # No C compiler available, give up
|
||||
- return None
|
||||
-
|
||||
- temp = tempfile.NamedTemporaryFile()
|
||||
- try:
|
||||
- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name]
|
||||
-
|
||||
- env = dict(os.environ)
|
||||
- env['LC_ALL'] = 'C'
|
||||
- env['LANG'] = 'C'
|
||||
- try:
|
||||
- proc = subprocess.Popen(args,
|
||||
- stdout=subprocess.PIPE,
|
||||
- stderr=subprocess.STDOUT,
|
||||
- env=env)
|
||||
- except OSError: # E.g. bad executable
|
||||
- return None
|
||||
- with proc:
|
||||
- trace = proc.stdout.read()
|
||||
- finally:
|
||||
- try:
|
||||
- temp.close()
|
||||
- except FileNotFoundError:
|
||||
- # Raised if the file was already removed, which is the normal
|
||||
- # behaviour of GCC if linking fails
|
||||
- pass
|
||||
- res = re.findall(expr, trace)
|
||||
- if not res:
|
||||
- return None
|
||||
-
|
||||
- for file in res:
|
||||
- # Check if the given file is an elf file: gcc can report
|
||||
- # some files that are linker scripts and not actual
|
||||
- # shared objects. See bpo-41976 for more details
|
||||
- if not _is_elf(file):
|
||||
- continue
|
||||
- return os.fsdecode(file)
|
||||
+ return None
|
||||
|
||||
|
||||
if sys.platform == "sunos5":
|
||||
@@ -268,34 +222,7 @@ elif os.name == "posix":
|
||||
else:
|
||||
|
||||
def _findSoname_ldconfig(name):
|
||||
- import struct
|
||||
- if struct.calcsize('l') == 4:
|
||||
- machine = os.uname().machine + '-32'
|
||||
- else:
|
||||
- machine = os.uname().machine + '-64'
|
||||
- mach_map = {
|
||||
- 'x86_64-64': 'libc6,x86-64',
|
||||
- 'ppc64-64': 'libc6,64bit',
|
||||
- 'sparc64-64': 'libc6,64bit',
|
||||
- 's390x-64': 'libc6,64bit',
|
||||
- 'ia64-64': 'libc6,IA-64',
|
||||
- }
|
||||
- abi_type = mach_map.get(machine, 'libc6')
|
||||
-
|
||||
- # XXX assuming GLIBC's ldconfig (with option -p)
|
||||
- regex = r'\s+(lib%s\.[^\s]+)\s+\(%s'
|
||||
- regex = os.fsencode(regex % (re.escape(name), abi_type))
|
||||
- try:
|
||||
- with subprocess.Popen(['/sbin/ldconfig', '-p'],
|
||||
- stdin=subprocess.DEVNULL,
|
||||
- stderr=subprocess.DEVNULL,
|
||||
- stdout=subprocess.PIPE,
|
||||
- env={'LC_ALL': 'C', 'LANG': 'C'}) as p:
|
||||
- res = re.search(regex, p.stdout.read())
|
||||
- if res:
|
||||
- return os.fsdecode(res.group(1))
|
||||
- except OSError:
|
||||
- pass
|
||||
+ return None
|
||||
|
||||
def _findLib_ld(name):
|
||||
# See issue #9998 for why this is needed
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
diff --git a/setup.py b/setup.py
|
||||
index 04eb6b2..2e1160d 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -1981,8 +1981,8 @@ class PyBuildExt(build_ext):
|
||||
# Rather than complicate the code below, detecting and building
|
||||
# AquaTk is a separate method. Only one Tkinter will be built on
|
||||
# Darwin - either AquaTk, if it is found, or X11 based Tk.
|
||||
- if (MACOS and self.detect_tkinter_darwin()):
|
||||
- return True
|
||||
+ # if (MACOS and self.detect_tkinter_darwin()):
|
||||
+ # return True
|
||||
|
||||
# Assume we haven't found any of the libraries or include files
|
||||
# The versions with dots are used on Unix, and the versions without
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
From 66f492d2eda94bd64db833839a325caf6ba0fed5 Mon Sep 17 00:00:00 2001
|
||||
From: Greg Roodt <greg@canva.com>
|
||||
Date: Wed, 9 Dec 2020 17:59:24 +1100
|
||||
Subject: [PATCH] Don't use ldconfig
|
||||
|
||||
---
|
||||
Lib/ctypes/util.py | 77 ++--------------------------------------------
|
||||
1 file changed, 2 insertions(+), 75 deletions(-)
|
||||
|
||||
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
|
||||
index 0c2510e161..7fb98af308 100644
|
||||
--- a/Lib/ctypes/util.py
|
||||
+++ b/Lib/ctypes/util.py
|
||||
@@ -100,53 +100,7 @@ elif os.name == "posix":
|
||||
return thefile.read(4) == elf_header
|
||||
|
||||
def _findLib_gcc(name):
|
||||
- # Run GCC's linker with the -t (aka --trace) option and examine the
|
||||
- # library name it prints out. The GCC command will fail because we
|
||||
- # haven't supplied a proper program with main(), but that does not
|
||||
- # matter.
|
||||
- expr = os.fsencode(r'[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name))
|
||||
-
|
||||
- c_compiler = shutil.which('gcc')
|
||||
- if not c_compiler:
|
||||
- c_compiler = shutil.which('cc')
|
||||
- if not c_compiler:
|
||||
- # No C compiler available, give up
|
||||
- return None
|
||||
-
|
||||
- temp = tempfile.NamedTemporaryFile()
|
||||
- try:
|
||||
- args = [c_compiler, '-Wl,-t', '-o', temp.name, '-l' + name]
|
||||
-
|
||||
- env = dict(os.environ)
|
||||
- env['LC_ALL'] = 'C'
|
||||
- env['LANG'] = 'C'
|
||||
- try:
|
||||
- proc = subprocess.Popen(args,
|
||||
- stdout=subprocess.PIPE,
|
||||
- stderr=subprocess.STDOUT,
|
||||
- env=env)
|
||||
- except OSError: # E.g. bad executable
|
||||
- return None
|
||||
- with proc:
|
||||
- trace = proc.stdout.read()
|
||||
- finally:
|
||||
- try:
|
||||
- temp.close()
|
||||
- except FileNotFoundError:
|
||||
- # Raised if the file was already removed, which is the normal
|
||||
- # behaviour of GCC if linking fails
|
||||
- pass
|
||||
- res = re.findall(expr, trace)
|
||||
- if not res:
|
||||
- return None
|
||||
-
|
||||
- for file in res:
|
||||
- # Check if the given file is an elf file: gcc can report
|
||||
- # some files that are linker scripts and not actual
|
||||
- # shared objects. See bpo-41976 for more details
|
||||
- if not _is_elf(file):
|
||||
- continue
|
||||
- return os.fsdecode(file)
|
||||
+ return None
|
||||
|
||||
|
||||
if sys.platform == "sunos5":
|
||||
@@ -268,34 +222,7 @@ elif os.name == "posix":
|
||||
else:
|
||||
|
||||
def _findSoname_ldconfig(name):
|
||||
- import struct
|
||||
- if struct.calcsize('l') == 4:
|
||||
- machine = os.uname().machine + '-32'
|
||||
- else:
|
||||
- machine = os.uname().machine + '-64'
|
||||
- mach_map = {
|
||||
- 'x86_64-64': 'libc6,x86-64',
|
||||
- 'ppc64-64': 'libc6,64bit',
|
||||
- 'sparc64-64': 'libc6,64bit',
|
||||
- 's390x-64': 'libc6,64bit',
|
||||
- 'ia64-64': 'libc6,IA-64',
|
||||
- }
|
||||
- abi_type = mach_map.get(machine, 'libc6')
|
||||
-
|
||||
- # XXX assuming GLIBC's ldconfig (with option -p)
|
||||
- regex = r'\s+(lib%s\.[^\s]+)\s+\(%s'
|
||||
- regex = os.fsencode(regex % (re.escape(name), abi_type))
|
||||
- try:
|
||||
- with subprocess.Popen(['/sbin/ldconfig', '-p'],
|
||||
- stdin=subprocess.DEVNULL,
|
||||
- stderr=subprocess.DEVNULL,
|
||||
- stdout=subprocess.PIPE,
|
||||
- env={'LC_ALL': 'C', 'LANG': 'C'}) as p:
|
||||
- res = re.search(regex, p.stdout.read())
|
||||
- if res:
|
||||
- return os.fsdecode(res.group(1))
|
||||
- except OSError:
|
||||
- pass
|
||||
+ return None
|
||||
|
||||
def _findLib_ld(name):
|
||||
# See issue #9998 for why this is needed
|
||||
--
|
||||
2.24.3 (Apple Git-128)
|
||||
507
pkgs/development/interpreters/python/cpython/default.nix
Normal file
507
pkgs/development/interpreters/python/cpython/default.nix
Normal file
|
|
@ -0,0 +1,507 @@
|
|||
{ lib, stdenv, fetchurl, fetchpatch
|
||||
, bzip2
|
||||
, expat
|
||||
, libffi
|
||||
, gdbm
|
||||
, xz
|
||||
, mailcap, mimetypesSupport ? true
|
||||
, ncurses
|
||||
, openssl
|
||||
, readline
|
||||
, sqlite
|
||||
, tcl ? null, tk ? null, tix ? null, libX11 ? null, xorgproto ? null, x11Support ? false
|
||||
, bluez ? null, bluezSupport ? false
|
||||
, zlib
|
||||
, tzdata ? null
|
||||
, self
|
||||
, configd
|
||||
, autoreconfHook
|
||||
, autoconf-archive
|
||||
, pkg-config
|
||||
, python-setup-hook
|
||||
, nukeReferences
|
||||
# For the Python package set
|
||||
, packageOverrides ? (self: super: {})
|
||||
, pkgsBuildBuild
|
||||
, pkgsBuildHost
|
||||
, pkgsBuildTarget
|
||||
, pkgsHostHost
|
||||
, pkgsTargetTarget
|
||||
, sourceVersion
|
||||
, sha256
|
||||
, passthruFun
|
||||
, bash
|
||||
, stripConfig ? false
|
||||
, stripIdlelib ? false
|
||||
, stripTests ? false
|
||||
, stripTkinter ? false
|
||||
, rebuildBytecode ? true
|
||||
, stripBytecode ? true
|
||||
, includeSiteCustomize ? true
|
||||
, static ? stdenv.hostPlatform.isStatic
|
||||
, enableOptimizations ? false
|
||||
# enableNoSemanticInterposition is a subset of the enableOptimizations flag that doesn't harm reproducibility.
|
||||
# clang starts supporting `-fno-sematic-interposition` with version 10
|
||||
, enableNoSemanticInterposition ? (!stdenv.cc.isClang || (stdenv.cc.isClang && lib.versionAtLeast stdenv.cc.version "10"))
|
||||
# enableLTO is a subset of the enableOptimizations flag that doesn't harm reproducibility.
|
||||
# enabling LTO on 32bit arch causes downstream packages to fail when linking
|
||||
# enabling LTO on *-darwin causes python3 to fail when linking.
|
||||
, enableLTO ? stdenv.is64bit && stdenv.isLinux
|
||||
, reproducibleBuild ? false
|
||||
, pythonAttr ? "python${sourceVersion.major}${sourceVersion.minor}"
|
||||
} @ inputs:
|
||||
|
||||
# Note: this package is used for bootstrapping fetchurl, and thus
|
||||
# cannot use fetchpatch! All mutable patches (generated by GitHub or
|
||||
# cgit) that are needed here should be included directly in Nixpkgs as
|
||||
# files.
|
||||
|
||||
assert x11Support -> tcl != null
|
||||
&& tk != null
|
||||
&& xorgproto != null
|
||||
&& libX11 != null;
|
||||
|
||||
assert bluezSupport -> bluez != null;
|
||||
|
||||
assert lib.assertMsg (reproducibleBuild -> stripBytecode)
|
||||
"Deterministic builds require stripping bytecode.";
|
||||
|
||||
assert lib.assertMsg (reproducibleBuild -> (!enableOptimizations))
|
||||
"Deterministic builds are not achieved when optimizations are enabled.";
|
||||
|
||||
assert lib.assertMsg (reproducibleBuild -> (!rebuildBytecode))
|
||||
"Deterministic builds are not achieved when (default unoptimized) bytecode is created.";
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
buildPackages = pkgsBuildHost;
|
||||
inherit (passthru) pythonForBuild;
|
||||
|
||||
tzdataSupport = tzdata != null && passthru.pythonAtLeast "3.9";
|
||||
|
||||
passthru = let
|
||||
# When we override the interpreter we also need to override the spliced versions of the interpreter
|
||||
inputs' = lib.filterAttrs (_: v: ! lib.isDerivation v) inputs;
|
||||
override = attr: let python = attr.override (inputs' // { self = python; }); in python;
|
||||
in passthruFun rec {
|
||||
inherit self sourceVersion packageOverrides;
|
||||
implementation = "cpython";
|
||||
libPrefix = "python${pythonVersion}";
|
||||
executable = libPrefix;
|
||||
pythonVersion = with sourceVersion; "${major}.${minor}";
|
||||
sitePackages = "lib/${libPrefix}/site-packages";
|
||||
inherit hasDistutilsCxxPatch;
|
||||
pythonOnBuildForBuild = override pkgsBuildBuild.${pythonAttr};
|
||||
pythonOnBuildForHost = override pkgsBuildHost.${pythonAttr};
|
||||
pythonOnBuildForTarget = override pkgsBuildTarget.${pythonAttr};
|
||||
pythonOnHostForHost = override pkgsHostHost.${pythonAttr};
|
||||
pythonOnTargetForTarget = if lib.hasAttr pythonAttr pkgsTargetTarget then (override pkgsTargetTarget.${pythonAttr}) else {};
|
||||
};
|
||||
|
||||
version = with sourceVersion; "${major}.${minor}.${patch}${suffix}";
|
||||
|
||||
nativeBuildInputs = optionals (!stdenv.isDarwin) [
|
||||
autoreconfHook
|
||||
pkg-config
|
||||
autoconf-archive # needed for AX_CHECK_COMPILE_FLAG
|
||||
] ++ [
|
||||
nukeReferences
|
||||
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
buildPackages.stdenv.cc
|
||||
pythonForBuild
|
||||
] ++ optionals (stdenv.cc.isClang && (enableLTO || enableOptimizations)) [
|
||||
stdenv.cc.cc.libllvm.out
|
||||
];
|
||||
|
||||
buildInputs = filter (p: p != null) ([
|
||||
zlib bzip2 expat xz libffi gdbm sqlite readline ncurses openssl ]
|
||||
++ optionals x11Support [ tcl tk libX11 xorgproto ]
|
||||
++ optionals (bluezSupport && stdenv.isLinux) [ bluez ]
|
||||
++ optionals stdenv.isDarwin [ configd ])
|
||||
++ optionals tzdataSupport [ tzdata ]; # `zoneinfo` module
|
||||
|
||||
hasDistutilsCxxPatch = !(stdenv.cc.isGNU or false);
|
||||
|
||||
pythonForBuildInterpreter = if stdenv.hostPlatform == stdenv.buildPlatform then
|
||||
"$out/bin/python"
|
||||
else pythonForBuild.interpreter;
|
||||
|
||||
# The CPython interpreter contains a _sysconfigdata_<platform specific suffix>
|
||||
# module that is imported by the sysconfig and distutils.sysconfig modules.
|
||||
# The sysconfigdata module is generated at build time and contains settings
|
||||
# required for building Python extension modules, such as include paths and
|
||||
# other compiler flags. By default, the sysconfigdata module is loaded from
|
||||
# the currently running interpreter (ie. the build platform interpreter), but
|
||||
# when cross-compiling we want to load it from the host platform interpreter.
|
||||
# This can be done using the _PYTHON_SYSCONFIGDATA_NAME environment variable.
|
||||
# The _PYTHON_HOST_PLATFORM variable also needs to be set to get the correct
|
||||
# platform suffix on extension modules. The correct values for these variables
|
||||
# are not documented, and must be derived from the configure script (see links
|
||||
# below).
|
||||
sysconfigdataHook = with stdenv.hostPlatform; with passthru; let
|
||||
# https://github.com/python/cpython/blob/e488e300f5c01289c10906c2e53a8e43d6de32d8/configure.ac#L428
|
||||
# The configure script uses "arm" as the CPU name for all 32-bit ARM
|
||||
# variants when cross-compiling, but native builds include the version
|
||||
# suffix, so we do the same.
|
||||
pythonHostPlatform = "${parsed.kernel.name}-${parsed.cpu.name}";
|
||||
|
||||
# https://github.com/python/cpython/blob/e488e300f5c01289c10906c2e53a8e43d6de32d8/configure.ac#L724
|
||||
multiarchCpu =
|
||||
if isAarch32 then
|
||||
if parsed.cpu.significantByte.name == "littleEndian" then "arm" else "armeb"
|
||||
else if isx86_32 then "i386"
|
||||
else parsed.cpu.name;
|
||||
pythonAbiName =
|
||||
# python's build doesn't differentiate between musl and glibc in its
|
||||
# abi detection, our wrapper should match.
|
||||
if stdenv.hostPlatform.isMusl then
|
||||
replaceStrings [ "musl" ] [ "gnu" ] parsed.abi.name
|
||||
else parsed.abi.name;
|
||||
multiarch =
|
||||
if isDarwin then "darwin"
|
||||
else "${multiarchCpu}-${parsed.kernel.name}-${pythonAbiName}";
|
||||
|
||||
abiFlags = optionalString (isPy36 || isPy37) "m";
|
||||
|
||||
# https://github.com/python/cpython/blob/e488e300f5c01289c10906c2e53a8e43d6de32d8/configure.ac#L78
|
||||
pythonSysconfigdataName = "_sysconfigdata_${abiFlags}_${parsed.kernel.name}_${multiarch}";
|
||||
in ''
|
||||
sysconfigdataHook() {
|
||||
if [ "$1" = '${placeholder "out"}' ]; then
|
||||
export _PYTHON_HOST_PLATFORM='${pythonHostPlatform}'
|
||||
export _PYTHON_SYSCONFIGDATA_NAME='${pythonSysconfigdataName}'
|
||||
fi
|
||||
}
|
||||
|
||||
addEnvHooks "$hostOffset" sysconfigdataHook
|
||||
'';
|
||||
|
||||
in with passthru; stdenv.mkDerivation {
|
||||
pname = "python3";
|
||||
inherit version;
|
||||
|
||||
inherit nativeBuildInputs;
|
||||
buildInputs = [ bash ] ++ buildInputs; # bash is only for patchShebangs
|
||||
|
||||
src = fetchurl {
|
||||
url = with sourceVersion; "https://www.python.org/ftp/python/${major}.${minor}.${patch}/Python-${version}.tar.xz";
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
prePatch = optionalString stdenv.isDarwin ''
|
||||
substituteInPlace configure --replace '`/usr/bin/arch`' '"i386"'
|
||||
'' + optionalString (pythonOlder "3.9" && stdenv.isDarwin && x11Support) ''
|
||||
# Broken on >= 3.9; replaced with ./3.9/darwin-tcl-tk.patch
|
||||
substituteInPlace setup.py --replace /Library/Frameworks /no-such-path
|
||||
'';
|
||||
|
||||
patches = [
|
||||
# Disable the use of ldconfig in ctypes.util.find_library (since
|
||||
# ldconfig doesn't work on NixOS), and don't use
|
||||
# ctypes.util.find_library during the loading of the uuid module
|
||||
# (since it will do a futile invocation of gcc (!) to find
|
||||
# libuuid, slowing down program startup a lot).
|
||||
(./. + "/${sourceVersion.major}.${sourceVersion.minor}/no-ldconfig.patch")
|
||||
# Make sure that the virtualenv activation scripts are
|
||||
# owner-writable, so venvs can be recreated without permission
|
||||
# errors.
|
||||
./virtualenv-permissions.patch
|
||||
] ++ optionals mimetypesSupport [
|
||||
# Make the mimetypes module refer to the right file
|
||||
./mimetypes.patch
|
||||
] ++ optionals (isPy35 || isPy36) [
|
||||
# Determinism: Write null timestamps when compiling python files.
|
||||
./3.5/force_bytecode_determinism.patch
|
||||
] ++ optionals isPy35 [
|
||||
# Backports support for LD_LIBRARY_PATH from 3.6
|
||||
./3.5/ld_library_path.patch
|
||||
] ++ optionals (isPy35 || isPy36 || isPy37) [
|
||||
# Backport a fix for discovering `rpmbuild` command when doing `python setup.py bdist_rpm` to 3.5, 3.6, 3.7.
|
||||
# See: https://bugs.python.org/issue11122
|
||||
./3.7/fix-hardcoded-path-checking-for-rpmbuild.patch
|
||||
# The workaround is for unittests on Win64, which we don't support.
|
||||
# It does break aarch64-darwin, which we do support. See:
|
||||
# * https://bugs.python.org/issue35523
|
||||
# * https://github.com/python/cpython/commit/e6b247c8e524
|
||||
./3.7/no-win64-workaround.patch
|
||||
] ++ optionals (pythonAtLeast "3.7") [
|
||||
# Fix darwin build https://bugs.python.org/issue34027
|
||||
./3.7/darwin-libutil.patch
|
||||
] ++ optionals (pythonOlder "3.8") [
|
||||
# Backport from CPython 3.8 of a good list of tests to run for PGO.
|
||||
(
|
||||
if isPy36 || isPy37 then
|
||||
./3.6/profile-task.patch
|
||||
else
|
||||
./3.5/profile-task.patch
|
||||
)
|
||||
] ++ optionals (pythonAtLeast "3.9" && pythonOlder "3.11" && stdenv.isDarwin) [
|
||||
# Stop checking for TCL/TK in global macOS locations
|
||||
./3.9/darwin-tcl-tk.patch
|
||||
] ++ optionals (isPy3k && hasDistutilsCxxPatch) [
|
||||
# Fix for http://bugs.python.org/issue1222585
|
||||
# Upstream distutils is calling C compiler to compile C++ code, which
|
||||
# only works for GCC and Apple Clang. This makes distutils to call C++
|
||||
# compiler when needed.
|
||||
(
|
||||
if isPy35 then
|
||||
./3.5/python-3.x-distutils-C++.patch
|
||||
else if pythonAtLeast "3.7" && pythonOlder "3.11" then
|
||||
./3.7/python-3.x-distutils-C++.patch
|
||||
else if pythonAtLeast "3.11" then
|
||||
./3.11/python-3.x-distutils-C++.patch
|
||||
else
|
||||
fetchpatch {
|
||||
url = "https://bugs.python.org/file48016/python-3.x-distutils-C++.patch";
|
||||
sha256 = "1h18lnpx539h5lfxyk379dxwr8m2raigcjixkf133l4xy3f4bzi2";
|
||||
}
|
||||
)
|
||||
] ++ [
|
||||
# LDSHARED now uses $CC instead of gcc. Fixes cross-compilation of extension modules.
|
||||
./3.8/0001-On-all-posix-systems-not-just-Darwin-set-LDSHARED-if.patch
|
||||
# Use sysconfigdata to find headers. Fixes cross-compilation of extension modules.
|
||||
(
|
||||
if isPy36 then
|
||||
./3.6/fix-finding-headers-when-cross-compiling.patch
|
||||
else
|
||||
./3.7/fix-finding-headers-when-cross-compiling.patch
|
||||
)
|
||||
] ++ optionals (isPy36) [
|
||||
# Backport a fix for ctypes.util.find_library.
|
||||
./3.6/find_library.patch
|
||||
];
|
||||
|
||||
postPatch = ''
|
||||
substituteInPlace Lib/subprocess.py \
|
||||
--replace "'/bin/sh'" "'${bash}/bin/sh'"
|
||||
'' + optionalString mimetypesSupport ''
|
||||
substituteInPlace Lib/mimetypes.py \
|
||||
--replace "@mime-types@" "${mailcap}"
|
||||
'' + optionalString (x11Support && (tix != null)) ''
|
||||
substituteInPlace "Lib/tkinter/tix.py" --replace "os.environ.get('TIX_LIBRARY')" "os.environ.get('TIX_LIBRARY') or '${tix}/lib'"
|
||||
'';
|
||||
|
||||
CPPFLAGS = concatStringsSep " " (map (p: "-I${getDev p}/include") buildInputs);
|
||||
LDFLAGS = concatStringsSep " " (map (p: "-L${getLib p}/lib") buildInputs);
|
||||
LIBS = "${optionalString (!stdenv.isDarwin) "-lcrypt"}";
|
||||
NIX_LDFLAGS = lib.optionalString (stdenv.cc.isGNU && !stdenv.hostPlatform.isStatic) ({
|
||||
"glibc" = "-lgcc_s";
|
||||
"musl" = "-lgcc_eh";
|
||||
}."${stdenv.hostPlatform.libc}" or "");
|
||||
# Determinism: We fix the hashes of str, bytes and datetime objects.
|
||||
PYTHONHASHSEED=0;
|
||||
|
||||
configureFlags = [
|
||||
"--without-ensurepip"
|
||||
"--with-system-expat"
|
||||
"--with-system-ffi"
|
||||
] ++ optionals (!static) [
|
||||
"--enable-shared"
|
||||
] ++ optionals enableOptimizations [
|
||||
"--enable-optimizations"
|
||||
] ++ optionals enableLTO [
|
||||
"--with-lto"
|
||||
] ++ optionals (pythonOlder "3.7") [
|
||||
# This is unconditionally true starting in CPython 3.7.
|
||||
"--with-threads"
|
||||
] ++ optionals (sqlite != null && isPy3k) [
|
||||
"--enable-loadable-sqlite-extensions"
|
||||
] ++ optionals (openssl != null) [
|
||||
"--with-openssl=${openssl.dev}"
|
||||
] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
"ac_cv_buggy_getaddrinfo=no"
|
||||
# Assume little-endian IEEE 754 floating point when cross compiling
|
||||
"ac_cv_little_endian_double=yes"
|
||||
"ac_cv_big_endian_double=no"
|
||||
"ac_cv_mixed_endian_double=no"
|
||||
"ac_cv_x87_double_rounding=yes"
|
||||
"ac_cv_tanh_preserves_zero_sign=yes"
|
||||
# Generally assume that things are present and work
|
||||
"ac_cv_posix_semaphores_enabled=yes"
|
||||
"ac_cv_broken_sem_getvalue=no"
|
||||
"ac_cv_wchar_t_signed=yes"
|
||||
"ac_cv_rshift_extends_sign=yes"
|
||||
"ac_cv_broken_nice=no"
|
||||
"ac_cv_broken_poll=no"
|
||||
"ac_cv_working_tzset=yes"
|
||||
"ac_cv_have_long_long_format=yes"
|
||||
"ac_cv_have_size_t_format=yes"
|
||||
"ac_cv_computed_gotos=yes"
|
||||
"ac_cv_file__dev_ptmx=yes"
|
||||
"ac_cv_file__dev_ptc=yes"
|
||||
] ++ optionals stdenv.hostPlatform.isLinux [
|
||||
# Never even try to use lchmod on linux,
|
||||
# don't rely on detecting glibc-isms.
|
||||
"ac_cv_func_lchmod=no"
|
||||
] ++ optionals tzdataSupport [
|
||||
"--with-tzpath=${tzdata}/share/zoneinfo"
|
||||
] ++ optional static "LDFLAGS=-static";
|
||||
|
||||
preConfigure = ''
|
||||
for i in /usr /sw /opt /pkg; do # improve purity
|
||||
substituteInPlace ./setup.py --replace $i /no-such-path
|
||||
done
|
||||
'' + optionalString stdenv.isDarwin ''
|
||||
# Override the auto-detection in setup.py, which assumes a universal build
|
||||
export PYTHON_DECIMAL_WITH_MACHINE=${if stdenv.isAarch64 then "uint128" else "x64"}
|
||||
'' + optionalString (isPy3k && pythonOlder "3.7") ''
|
||||
# Determinism: The interpreter is patched to write null timestamps when compiling Python files
|
||||
# so Python doesn't try to update the bytecode when seeing frozen timestamps in Nix's store.
|
||||
export DETERMINISTIC_BUILD=1;
|
||||
'' + optionalString stdenv.hostPlatform.isMusl ''
|
||||
export NIX_CFLAGS_COMPILE+=" -DTHREAD_STACK_SIZE=0x100000"
|
||||
'' +
|
||||
|
||||
# enableNoSemanticInterposition essentially sets that CFLAG -fno-semantic-interposition
|
||||
# which changes how symbols are looked up. This essentially means we can't override
|
||||
# libpython symbols via LD_PRELOAD anymore. This is common enough as every build
|
||||
# that uses --enable-optimizations has the same "issue".
|
||||
#
|
||||
# The Fedora wiki has a good article about their journey towards enabling this flag:
|
||||
# https://fedoraproject.org/wiki/Changes/PythonNoSemanticInterpositionSpeedup
|
||||
optionalString enableNoSemanticInterposition ''
|
||||
export CFLAGS_NODIST="-fno-semantic-interposition"
|
||||
'';
|
||||
|
||||
setupHook = python-setup-hook sitePackages;
|
||||
|
||||
postInstall = let
|
||||
# References *not* to nuke from (sys)config files
|
||||
keep-references = concatMapStringsSep " " (val: "-e ${val}") ([
|
||||
(placeholder "out")
|
||||
] ++ optionals tzdataSupport [
|
||||
tzdata
|
||||
]);
|
||||
in ''
|
||||
# needed for some packages, especially packages that backport functionality
|
||||
# to 2.x from 3.x
|
||||
for item in $out/lib/${libPrefix}/test/*; do
|
||||
if [[ "$item" != */test_support.py*
|
||||
&& "$item" != */test/support
|
||||
&& "$item" != */test/libregrtest
|
||||
&& "$item" != */test/regrtest.py* ]]; then
|
||||
rm -rf "$item"
|
||||
else
|
||||
echo $item
|
||||
fi
|
||||
done
|
||||
touch $out/lib/${libPrefix}/test/__init__.py
|
||||
|
||||
ln -s "$out/include/${executable}m" "$out/include/${executable}"
|
||||
|
||||
# Determinism: Windows installers were not deterministic.
|
||||
# We're also not interested in building Windows installers.
|
||||
find "$out" -name 'wininst*.exe' | xargs -r rm -f
|
||||
|
||||
# Use Python3 as default python
|
||||
ln -s "$out/bin/idle3" "$out/bin/idle"
|
||||
ln -s "$out/bin/pydoc3" "$out/bin/pydoc"
|
||||
ln -s "$out/bin/python3" "$out/bin/python"
|
||||
ln -s "$out/bin/python3-config" "$out/bin/python-config"
|
||||
ln -s "$out/lib/pkgconfig/python3.pc" "$out/lib/pkgconfig/python.pc"
|
||||
|
||||
# Get rid of retained dependencies on -dev packages, and remove
|
||||
# some $TMPDIR references to improve binary reproducibility.
|
||||
# Note that the .pyc file of _sysconfigdata.py should be regenerated!
|
||||
for i in $out/lib/${libPrefix}/_sysconfigdata*.py $out/lib/${libPrefix}/config-${sourceVersion.major}${sourceVersion.minor}*/Makefile; do
|
||||
sed -i $i -e "s|$TMPDIR|/no-such-path|g"
|
||||
done
|
||||
|
||||
# Further get rid of references. https://github.com/NixOS/nixpkgs/issues/51668
|
||||
find $out/lib/python*/config-* -type f -print -exec nuke-refs ${keep-references} '{}' +
|
||||
find $out/lib -name '_sysconfigdata*.py*' -print -exec nuke-refs ${keep-references} '{}' +
|
||||
|
||||
# Make the sysconfigdata module accessible on PYTHONPATH
|
||||
# This allows build Python to import host Python's sysconfigdata
|
||||
mkdir -p "$out/${sitePackages}"
|
||||
ln -s "$out/lib/${libPrefix}/"_sysconfigdata*.py "$out/${sitePackages}/"
|
||||
|
||||
# debug info can't be separated from a static library and would otherwise be
|
||||
# left in place by a separateDebugInfo build. force its removal here to save
|
||||
# space in output.
|
||||
$STRIP -S $out/lib/${libPrefix}/config-*/libpython*.a || true
|
||||
'' + optionalString stripConfig ''
|
||||
rm -R $out/bin/python*-config $out/lib/python*/config-*
|
||||
'' + optionalString stripIdlelib ''
|
||||
# Strip IDLE (and turtledemo, which uses it)
|
||||
rm -R $out/bin/idle* $out/lib/python*/{idlelib,turtledemo}
|
||||
'' + optionalString stripTkinter ''
|
||||
rm -R $out/lib/python*/tkinter
|
||||
'' + optionalString stripTests ''
|
||||
# Strip tests
|
||||
rm -R $out/lib/python*/test $out/lib/python*/**/test{,s}
|
||||
'' + optionalString includeSiteCustomize ''
|
||||
# Include a sitecustomize.py file
|
||||
cp ${../sitecustomize.py} $out/${sitePackages}/sitecustomize.py
|
||||
|
||||
'' + optionalString stripBytecode ''
|
||||
# Determinism: deterministic bytecode
|
||||
# First we delete all old bytecode.
|
||||
find $out -type d -name __pycache__ -print0 | xargs -0 -I {} rm -rf "{}"
|
||||
'' + optionalString rebuildBytecode ''
|
||||
# Python 3.7 implements PEP 552, introducing support for deterministic bytecode.
|
||||
# compileall uses the therein introduced checked-hash method by default when
|
||||
# `SOURCE_DATE_EPOCH` is set.
|
||||
# We exclude lib2to3 because that's Python 2 code which fails
|
||||
# We build 3 levels of optimized bytecode. Note the default level, without optimizations,
|
||||
# is not reproducible yet. https://bugs.python.org/issue29708
|
||||
# Not creating bytecode will result in a large performance loss however, so we do build it.
|
||||
find $out -name "*.py" | ${pythonForBuildInterpreter} -m compileall -q -f -x "lib2to3" -i -
|
||||
find $out -name "*.py" | ${pythonForBuildInterpreter} -O -m compileall -q -f -x "lib2to3" -i -
|
||||
find $out -name "*.py" | ${pythonForBuildInterpreter} -OO -m compileall -q -f -x "lib2to3" -i -
|
||||
'' + ''
|
||||
# *strip* shebang from libpython gdb script - it should be dual-syntax and
|
||||
# interpretable by whatever python the gdb in question is using, which may
|
||||
# not even match the major version of this python. doing this after the
|
||||
# bytecode compilations for the same reason - we don't want bytecode generated.
|
||||
mkdir -p $out/share/gdb
|
||||
sed '/^#!/d' Tools/gdb/libpython.py > $out/share/gdb/libpython.py
|
||||
'';
|
||||
|
||||
preFixup = lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) ''
|
||||
# Ensure patch-shebangs uses shebangs of host interpreter.
|
||||
export PATH=${lib.makeBinPath [ "$out" ]}:$PATH
|
||||
'';
|
||||
|
||||
# Add CPython specific setup-hook that configures distutils.sysconfig to
|
||||
# always load sysconfigdata from host Python.
|
||||
postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
|
||||
cat << "EOF" >> "$out/nix-support/setup-hook"
|
||||
${sysconfigdataHook}
|
||||
EOF
|
||||
'';
|
||||
|
||||
# Enforce that we don't have references to the OpenSSL -dev package, which we
|
||||
# explicitly specify in our configure flags above.
|
||||
disallowedReferences =
|
||||
lib.optionals (openssl != null && !static) [ openssl.dev ]
|
||||
++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
||||
# Ensure we don't have references to build-time packages.
|
||||
# These typically end up in shebangs.
|
||||
pythonForBuild buildPackages.bash
|
||||
];
|
||||
|
||||
separateDebugInfo = true;
|
||||
|
||||
inherit passthru;
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
meta = {
|
||||
homepage = "http://python.org";
|
||||
description = "A high-level dynamically-typed programming language";
|
||||
longDescription = ''
|
||||
Python is a remarkably powerful dynamic programming language that
|
||||
is used in a wide variety of application domains. Some of its key
|
||||
distinguishing features include: clear, readable syntax; strong
|
||||
introspection capabilities; intuitive object orientation; natural
|
||||
expression of procedural code; full modularity, supporting
|
||||
hierarchical packages; exception-based error handling; and very
|
||||
high level dynamic data types.
|
||||
'';
|
||||
license = licenses.psfl;
|
||||
platforms = with platforms; linux ++ darwin;
|
||||
maintainers = with maintainers; [ fridh ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# This file was generated and will be overwritten by ./generate.sh
|
||||
|
||||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "python27-docs-html";
|
||||
version = "2.7.16";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://docs.python.org/ftp/python/doc/${version}/python-${version}-docs-html.tar.bz2";
|
||||
sha256 = "1razs1grzhai65ihaiyph8kz6ncjkgp1gsn3c8v7kanf13lqim02";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/doc/python27
|
||||
cp -R ./ $out/share/doc/python27/html
|
||||
'';
|
||||
meta = {
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# This file was generated and will be overwritten by ./generate.sh
|
||||
|
||||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "python27-docs-pdf-a4";
|
||||
version = "2.7.16";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://docs.python.org/ftp/python/doc/${version}/python-${version}-docs-pdf-a4.tar.bz2";
|
||||
sha256 = "14ml1ynrlbhg43737bdsb8k5y39wsffqj4iwhylhb8n8l5dplfdq";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/doc/python27
|
||||
cp -R ./ $out/share/doc/python27/pdf-a4
|
||||
'';
|
||||
meta = {
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# This file was generated and will be overwritten by ./generate.sh
|
||||
|
||||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "python27-docs-pdf-letter";
|
||||
version = "2.7.16";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://docs.python.org/ftp/python/doc/${version}/python-${version}-docs-pdf-letter.tar.bz2";
|
||||
sha256 = "019i8n48m71mn31v8d85kkwyqfgcgqnqh506y4a7fcgf656bajs0";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/doc/python27
|
||||
cp -R ./ $out/share/doc/python27/pdf-letter
|
||||
'';
|
||||
meta = {
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# This file was generated and will be overwritten by ./generate.sh
|
||||
|
||||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "python27-docs-text";
|
||||
version = "2.7.16";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://docs.python.org/ftp/python/doc/${version}/python-${version}-docs-text.tar.bz2";
|
||||
sha256 = "1da7swlykvc013684nywycinfz3v8dqkcmv0zj8p7l5lyi5mq03r";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/doc/python27
|
||||
cp -R ./ $out/share/doc/python27/text
|
||||
'';
|
||||
meta = {
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# This file was generated and will be overwritten by ./generate.sh
|
||||
|
||||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "python37-docs-html";
|
||||
version = "3.7.2";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://docs.python.org/ftp/python/doc/${version}/python-${version}-docs-html.tar.bz2";
|
||||
sha256 = "19wbrawpdam09fmyipfy92sxwn1rl93v8jkfqsfx028qhvzf0422";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/doc/python37
|
||||
cp -R ./ $out/share/doc/python37/html
|
||||
'';
|
||||
meta = {
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# This file was generated and will be overwritten by ./generate.sh
|
||||
|
||||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "python37-docs-pdf-a4";
|
||||
version = "3.7.2";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://docs.python.org/ftp/python/doc/${version}/python-${version}-docs-pdf-a4.tar.bz2";
|
||||
sha256 = "0vdx762m30hjaabn6w88awcj2qpbz0b6z59zn9wmamd35k59lfba";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/doc/python37
|
||||
cp -R ./ $out/share/doc/python37/pdf-a4
|
||||
'';
|
||||
meta = {
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# This file was generated and will be overwritten by ./generate.sh
|
||||
|
||||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "python37-docs-pdf-letter";
|
||||
version = "3.7.2";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://docs.python.org/ftp/python/doc/${version}/python-${version}-docs-pdf-letter.tar.bz2";
|
||||
sha256 = "17g57vlyvqx0k916q84q2pcx7y8myw0fda9fvg9kh0ph930c837x";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/doc/python37
|
||||
cp -R ./ $out/share/doc/python37/pdf-letter
|
||||
'';
|
||||
meta = {
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# This file was generated and will be overwritten by ./generate.sh
|
||||
|
||||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "python37-docs-text";
|
||||
version = "3.7.2";
|
||||
|
||||
src = fetchurl {
|
||||
url = "http://docs.python.org/ftp/python/doc/${version}/python-${version}-docs-text.tar.bz2";
|
||||
sha256 = "0h50rlr8jclwfxa106b42q2vn2ynp219c4zsy5qz65n5m3b7y1g2";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/doc/python37
|
||||
cp -R ./ $out/share/doc/python37/text
|
||||
'';
|
||||
meta = {
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
let
|
||||
pythonDocs = {
|
||||
html = {
|
||||
recurseForDerivations = true;
|
||||
python27 = import ./2.7-html.nix {
|
||||
inherit stdenv fetchurl lib;
|
||||
};
|
||||
python37 = import ./3.7-html.nix {
|
||||
inherit stdenv fetchurl lib;
|
||||
};
|
||||
};
|
||||
pdf_a4 = {
|
||||
recurseForDerivations = true;
|
||||
python27 = import ./2.7-pdf-a4.nix {
|
||||
inherit stdenv fetchurl lib;
|
||||
};
|
||||
python37 = import ./3.7-pdf-a4.nix {
|
||||
inherit stdenv fetchurl lib;
|
||||
};
|
||||
};
|
||||
pdf_letter = {
|
||||
recurseForDerivations = true;
|
||||
python27 = import ./2.7-pdf-letter.nix {
|
||||
inherit stdenv fetchurl lib;
|
||||
};
|
||||
python37 = import ./3.7-pdf-letter.nix {
|
||||
inherit stdenv fetchurl lib;
|
||||
};
|
||||
};
|
||||
text = {
|
||||
recurseForDerivations = true;
|
||||
python27 = import ./2.7-text.nix {
|
||||
inherit stdenv fetchurl lib;
|
||||
};
|
||||
python37 = import ./3.7-text.nix {
|
||||
inherit stdenv fetchurl lib;
|
||||
};
|
||||
};
|
||||
}; in pythonDocs
|
||||
59
pkgs/development/interpreters/python/cpython/docs/generate.sh
Executable file
59
pkgs/development/interpreters/python/cpython/docs/generate.sh
Executable file
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
TYPES="html pdf-a4 pdf-letter text"
|
||||
URL=http://docs.python.org/ftp/python/doc/VERSION/python-VERSION-docs-TYPE.tar.bz2
|
||||
VERSIONS=$(for major in 2 3; do curl https://docs.python.org/$major/archives/ 2>/dev/null | perl -l -n -e'/<a href="python-([23].[0-9].[0-9]+)-docs-html.tar.bz2/ && print $1' | tail -n 1; done)
|
||||
echo "Generating expressions for:
|
||||
${VERSIONS}
|
||||
"
|
||||
|
||||
|
||||
cat >default.nix <<EOF
|
||||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
let
|
||||
pythonDocs = {
|
||||
EOF
|
||||
|
||||
for type in $TYPES; do
|
||||
cat >>default.nix <<EOF
|
||||
${type/-/_} = {
|
||||
recurseForDerivations = true;
|
||||
EOF
|
||||
|
||||
for version in $VERSIONS; do
|
||||
major=$(echo -n ${version}| cut -d. -f1)
|
||||
minor=$(echo -n ${version}| cut -d. -f2)
|
||||
outfile=${major}.${minor}-${type}.nix
|
||||
hash=
|
||||
if [ -e ${outfile} ]; then
|
||||
currentversion=$(grep "url =" ${outfile} |cut -d/ -f7)
|
||||
if [ ${version} = ${currentversion} ]; then
|
||||
hash=$(grep sha256 ${outfile} | cut -d'"' -f2)
|
||||
fi
|
||||
fi
|
||||
echo "Generating ${outfile}"
|
||||
url=$(echo -n $URL |sed -e "s,VERSION,${version},g" -e "s,TYPE,${type},")
|
||||
sha=$(nix-prefetch-url ${url} ${hash})
|
||||
|
||||
sed -e "s,VERSION,${version}," \
|
||||
-e "s,MAJOR,${major}," \
|
||||
-e "s,MINOR,${minor}," \
|
||||
-e "s,TYPE,${type}," \
|
||||
-e "s,URL,${url}," \
|
||||
-e "s,SHA,${sha}," < template.nix > ${outfile}
|
||||
|
||||
attrname=python${major}${minor}
|
||||
cat >>default.nix <<EOF
|
||||
${attrname} = import ./${major}.${minor}-${type}.nix {
|
||||
inherit stdenv fetchurl lib;
|
||||
};
|
||||
EOF
|
||||
|
||||
echo "done."
|
||||
echo
|
||||
done
|
||||
echo " };" >> default.nix
|
||||
done
|
||||
|
||||
echo "}; in pythonDocs" >> default.nix
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# This file was generated and will be overwritten by ./generate.sh
|
||||
|
||||
{ stdenv, fetchurl, lib }:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "pythonMAJORMINOR-docs-TYPE-VERSION";
|
||||
src = fetchurl {
|
||||
url = URL;
|
||||
sha256 = "SHA";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/doc/pythonMAJORMINOR
|
||||
cp -R ./ $out/share/doc/pythonMAJORMINOR/TYPE
|
||||
'';
|
||||
meta = {
|
||||
maintainers = [ ];
|
||||
};
|
||||
}
|
||||
23
pkgs/development/interpreters/python/cpython/mimetypes.patch
Normal file
23
pkgs/development/interpreters/python/cpython/mimetypes.patch
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
diff --git i/Lib/mimetypes.py w/Lib/mimetypes.py
|
||||
index f3343c8..ab5b886 100644
|
||||
--- i/Lib/mimetypes.py
|
||||
+++ w/Lib/mimetypes.py
|
||||
@@ -40,16 +40,8 @@
|
||||
]
|
||||
|
||||
knownfiles = [
|
||||
- "/etc/mime.types",
|
||||
- "/etc/httpd/mime.types", # Mac OS X
|
||||
- "/etc/httpd/conf/mime.types", # Apache
|
||||
- "/etc/apache/mime.types", # Apache 1
|
||||
- "/etc/apache2/mime.types", # Apache 2
|
||||
- "/usr/local/etc/httpd/conf/mime.types",
|
||||
- "/usr/local/lib/netscape/mime.types",
|
||||
- "/usr/local/etc/httpd/conf/mime.types", # Apache 1.2
|
||||
- "/usr/local/etc/mime.types", # Apache 1.3
|
||||
- ]
|
||||
+ "@mime-types@/etc/mime.types",
|
||||
+]
|
||||
|
||||
inited = False
|
||||
_db = None
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py
|
||||
index caa7285..ad666ac 100644
|
||||
--- a/Lib/venv/__init__.py
|
||||
+++ b/Lib/venv/__init__.py
|
||||
@@ -379,7 +379,7 @@ class EnvBuilder:
|
||||
if data is not None:
|
||||
with open(dstfile, 'wb') as f:
|
||||
f.write(data)
|
||||
- shutil.copymode(srcfile, dstfile)
|
||||
+ os.chmod(dstfile, 0o644)
|
||||
|
||||
|
||||
def create(env_dir, system_site_packages=False, clear=False,
|
||||
Loading…
Add table
Add a link
Reference in a new issue