diff options
author | Kubilay Kocak <koobs@FreeBSD.org> | 2016-01-08 16:45:09 +0000 |
---|---|---|
committer | Kubilay Kocak <koobs@FreeBSD.org> | 2016-01-08 16:45:09 +0000 |
commit | 474ff0ec6ac0f38e948e345cd9650ed808204dc2 (patch) | |
tree | b14d8368654ff10811b2639080582589ce4e3316 /lang/python27 | |
parent | d00fd2e745869e25c02840168613563936749458 (diff) | |
download | ports-474ff0ec6ac0f38e948e345cd9650ed808204dc2.tar.gz ports-474ff0ec6ac0f38e948e345cd9650ed808204dc2.zip |
lang/python{27,3*}: Backport patch in upstream issue20397
In certain situations, file references (.py[co]) for Python files that
fail to compile with compileall() are still added to distutils --record
output.
This output is used for pkg-plist generation and must only contain
references to files that will be installed.
One example of a failure condition is when a Python 2/3 compatible
package containing a file containing Python 3.x only code is built with
Python 2.x, such as Gunicorn's _gaiohttp.py [1]
This change backports patches submitted against upstream issue 20397 [2]
that has not yet been committed.
- For Python 2.7 and 3.5, backport both install_lib and test
- For Python 3.2, 3.3 and 3.4, only backport install_lib
[1] https://svnweb.freebsd.org/changeset/ports/404558
[2] https://bugs.python.org/issue20397
Thank you to Brendan Molloy for producing and submitting the patches
against upstream sources.
Reviewed by: sbz (python)
MFH: 2016Q1
Differential Revision: D4832
Notes
Notes:
svn path=/head/; revision=405569
Diffstat (limited to 'lang/python27')
-rw-r--r-- | lang/python27/Makefile | 1 | ||||
-rw-r--r-- | lang/python27/files/patch-Lib_distutils_command_install__lib.py | 34 | ||||
-rw-r--r-- | lang/python27/files/patch-Lib_distutils_tests_test__install__lib.py | 30 |
3 files changed, 65 insertions, 0 deletions
diff --git a/lang/python27/Makefile b/lang/python27/Makefile index 70190f5185ab..eea02f1c8436 100644 --- a/lang/python27/Makefile +++ b/lang/python27/Makefile @@ -2,6 +2,7 @@ PORTNAME= python27 PORTVERSION= ${PYTHON_PORTVERSION} +PORTREVISION= 1 CATEGORIES= lang python ipv6 MASTER_SITES= PYTHON/ftp/python/${PORTVERSION} DISTNAME= Python-${PORTVERSION} diff --git a/lang/python27/files/patch-Lib_distutils_command_install__lib.py b/lang/python27/files/patch-Lib_distutils_command_install__lib.py new file mode 100644 index 000000000000..f7dfb21c8336 --- /dev/null +++ b/lang/python27/files/patch-Lib_distutils_command_install__lib.py @@ -0,0 +1,34 @@ +From 9934ce31b8447667f71c211e559a8de71e8263db Mon Sep 17 00:00:00 2001 +From: Brendan Molloy <brendan@bbqsrc.net> +Date: Mon, 4 Jan 2016 23:14:06 +1100 +Subject: [PATCH] Check bytecode file actually exists and tests + +Should solve issue 20397, where using the --record argument results +in files that failed to generate bytecode files are added to the +record file nonetheless. +--- + Lib/distutils/command/install_lib.py | 17 +++++++++++++---- + Lib/distutils/tests/test_install_lib.py | 8 ++++++-- + 2 files changed, 19 insertions(+), 6 deletions(-) + +--- Lib/distutils/command/install_lib.py.orig 2015-12-05 19:46:56 UTC ++++ Lib/distutils/command/install_lib.py +@@ -168,10 +168,14 @@ class install_lib(Command): + ext = os.path.splitext(os.path.normcase(py_file))[1] + if ext != PYTHON_SOURCE_EXTENSION: + continue +- if self.compile: +- bytecode_files.append(py_file + "c") +- if self.optimize > 0: +- bytecode_files.append(py_file + "o") ++ ++ pyc_file = py_file + "c" ++ if self.compile and os.path.isfile(pyc_file): ++ bytecode_files.append(pyc_file) ++ ++ pyo_file = py_file + "o" ++ if self.optimize > 0 and os.path.isfile(pyo_file): ++ bytecode_files.append(pyo_file) + + return bytecode_files + diff --git a/lang/python27/files/patch-Lib_distutils_tests_test__install__lib.py b/lang/python27/files/patch-Lib_distutils_tests_test__install__lib.py new file mode 100644 index 000000000000..9313cf2e211e --- /dev/null +++ b/lang/python27/files/patch-Lib_distutils_tests_test__install__lib.py @@ -0,0 +1,30 @@ +From 9934ce31b8447667f71c211e559a8de71e8263db Mon Sep 17 00:00:00 2001 +From: Brendan Molloy <brendan@bbqsrc.net> +Date: Mon, 4 Jan 2016 23:14:06 +1100 +Subject: [PATCH] Check bytecode file actually exists and tests + +Should solve issue 20397, where using the --record argument results +in files that failed to generate bytecode files are added to the +record file nonetheless. +--- + Lib/distutils/command/install_lib.py | 17 +++++++++++++---- + Lib/distutils/tests/test_install_lib.py | 8 ++++++-- + 2 files changed, 19 insertions(+), 6 deletions(-) + +--- Lib/distutils/tests/test_install_lib.py.orig 2015-12-05 19:46:57 UTC ++++ Lib/distutils/tests/test_install_lib.py +@@ -64,8 +64,12 @@ class InstallLibTestCase(support.Tempdir + cmd.distribution.packages = [pkg_dir] + cmd.distribution.script_name = 'setup.py' + +- # get_output should return 4 elements +- self.assertGreaterEqual(len(cmd.get_outputs()), 2) ++ # Create rubbish, uncompilable file ++ f = os.path.join(pkg_dir, 'rubbish.py') ++ self.write_file(f, 'rubbish()') ++ ++ # get_output should return 3 elements ++ self.assertEqual(len(cmd.get_outputs()), 3) + + def test_get_inputs(self): + pkg_dir, dist = self.create_dist() |