gcc: preserve CXXFLAGS_FOR_TARGET
[buildroot-gz.git] / package / python3 / 0016-Add-importlib-fix-for-PEP-3147-issue.patch
blob02f1d164f756dbf1137df83cc11a183539ec4453
1 From 1153f503a38daf6388021575f1ad6ce8b702911b Mon Sep 17 00:00:00 2001
2 From: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
3 Date: Wed, 23 Dec 2015 11:46:14 +0100
4 Subject: [PATCH] Add importlib fix for PEP 3147 issue
6 Python 3 has a new standard for installing .pyc file, called PEP
7 3147. Unfortunately, this standard requires both the .py and .pyc
8 files to be installed for a Python module to be found. This is quite
9 annoying on space-constrained embedded systems, since the .py file is
10 technically not required for execution.
12 This patch changes cache_from_source() and source_from_cache() in
13 importlib to get rid of the "__pycache__" directory.
14 This effectively disables PEP 3147 for:
16 * The python standard library
17 * Packages built with distutils or setuptools
18 * Packages built with automake that use the `py-compile` helper
20 Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
21 ---
22 Lib/importlib/_bootstrap.py | 26 +++++---------------------
23 1 file changed, 5 insertions(+), 21 deletions(-)
25 diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
26 index 5b91c05..a1755ec 100644
27 --- a/Lib/importlib/_bootstrap.py
28 +++ b/Lib/importlib/_bootstrap.py
29 @@ -444,8 +444,6 @@ def cache_from_source(path, debug_override=None):
30 If debug_override is not None, then it must be a boolean and is used in
31 place of sys.flags.optimize.
33 - If sys.implementation.cache_tag is None then NotImplementedError is raised.
35 """
36 debug = not sys.flags.optimize if debug_override is None else debug_override
37 if debug:
38 @@ -454,33 +452,19 @@ def cache_from_source(path, debug_override=None):
39 suffixes = OPTIMIZED_BYTECODE_SUFFIXES
40 head, tail = _path_split(path)
41 base, sep, rest = tail.rpartition('.')
42 - tag = sys.implementation.cache_tag
43 - if tag is None:
44 - raise NotImplementedError('sys.implementation.cache_tag is None')
45 - filename = ''.join([(base if base else rest), sep, tag, suffixes[0]])
46 - return _path_join(head, _PYCACHE, filename)
47 + filename = ''.join([(base if base else rest), suffixes[0]])
48 + return _path_join(head, filename)
51 def source_from_cache(path):
52 """Given the path to a .pyc./.pyo file, return the path to its .py file.
54 The .pyc/.pyo file does not need to exist; this simply returns the path to
55 - the .py file calculated to correspond to the .pyc/.pyo file. If path does
56 - not conform to PEP 3147 format, ValueError will be raised. If
57 - sys.implementation.cache_tag is None then NotImplementedError is raised.
58 + the .py file calculated to correspond to the .pyc/.pyo file.
60 """
61 - if sys.implementation.cache_tag is None:
62 - raise NotImplementedError('sys.implementation.cache_tag is None')
63 - head, pycache_filename = _path_split(path)
64 - head, pycache = _path_split(head)
65 - if pycache != _PYCACHE:
66 - raise ValueError('{} not bottom-level directory in '
67 - '{!r}'.format(_PYCACHE, path))
68 - if pycache_filename.count('.') != 2:
69 - raise ValueError('expected only 2 dots in '
70 - '{!r}'.format(pycache_filename))
71 - base_filename = pycache_filename.partition('.')[0]
72 + head, filename = _path_split(path)
73 + base_filename = filename.partition('.')[0]
74 return _path_join(head, base_filename + SOURCE_SUFFIXES[0])
77 --
78 2.6.4