python3: bump to 3.5.1
The major changes in terms of Buildroot packaging are:
- Due to PEP488, Python no longer generates .pyc (unoptimized) and
.pyo (optimized) byte-code files. Instead, it generates <foo>.pyc,
<foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the
--disable-pyo-build option and kept only the --disable-pyc-build
option, which completely disables building all .pyc files. In
addition, since the optimized .opt-X.pyc files don't work if the
corresponding un-optimized .pyc file is not present, we are for the
moment unconditionally removing the optimized ones (keeping both
the unoptimized and optimized ones doubles the required filesystem
size!). So basically we preserve the behavior we had before this
commit:
BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py
BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc
BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc
To achieve this, the TARGET_FINALIZE_HOOKS are reworked:
PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in
the BR2_PACKAGE_PYTHON3_PYC_ONLY case.
PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files
in the BR2_PACKAGE_PYTHON3_PY_ONLY case.
PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the
optimized *.opt-1.pyc and *.opt-2.pyc files, which is done
unconditionally.
- The PEP3147 disabling patch had to be significantly reworked due to
the code having changed heavily. The code was moved into a
_bootstrap_external.py, which is a "frozen" Python module, i.e a
module generated into a .h file at compile time using the
_freeze_importlib program.
- Due to the above, we now need to regenerate importlib.h at build
time. Unfortunately, for the target Python _freeze_importlib is
built for the target, so we can't run it on the build machine. To
fix this, we copy the _freeze_importlib program from the
host-python in $(HOST_DIR), and then patch the target python to use
it. Since the same solution can be used for 'pgen', we do it, and
avoid having to touch the graminit.{c,h} files.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-05-01 22:15:12 +02:00
|
|
|
From d2b5be9a0627e38d2280ef865dab3e74b7d2bde4 Mon Sep 17 00:00:00 2001
|
2016-01-04 19:23:28 +01:00
|
|
|
From: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
|
|
|
|
Date: Wed, 23 Dec 2015 11:46:14 +0100
|
|
|
|
Subject: [PATCH] Add importlib fix for PEP 3147 issue
|
2015-11-14 16:54:30 +01:00
|
|
|
|
|
|
|
Python 3 has a new standard for installing .pyc file, called PEP
|
|
|
|
3147. Unfortunately, this standard requires both the .py and .pyc
|
|
|
|
files to be installed for a Python module to be found. This is quite
|
|
|
|
annoying on space-constrained embedded systems, since the .py file is
|
|
|
|
technically not required for execution.
|
|
|
|
|
|
|
|
This patch changes cache_from_source() and source_from_cache() in
|
|
|
|
importlib to get rid of the "__pycache__" directory.
|
|
|
|
This effectively disables PEP 3147 for:
|
|
|
|
|
|
|
|
* The python standard library
|
|
|
|
* Packages built with distutils or setuptools
|
|
|
|
* Packages built with automake that use the `py-compile` helper
|
|
|
|
|
|
|
|
Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
|
2016-01-04 19:23:28 +01:00
|
|
|
---
|
python3: bump to 3.5.1
The major changes in terms of Buildroot packaging are:
- Due to PEP488, Python no longer generates .pyc (unoptimized) and
.pyo (optimized) byte-code files. Instead, it generates <foo>.pyc,
<foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the
--disable-pyo-build option and kept only the --disable-pyc-build
option, which completely disables building all .pyc files. In
addition, since the optimized .opt-X.pyc files don't work if the
corresponding un-optimized .pyc file is not present, we are for the
moment unconditionally removing the optimized ones (keeping both
the unoptimized and optimized ones doubles the required filesystem
size!). So basically we preserve the behavior we had before this
commit:
BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py
BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc
BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc
To achieve this, the TARGET_FINALIZE_HOOKS are reworked:
PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in
the BR2_PACKAGE_PYTHON3_PYC_ONLY case.
PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files
in the BR2_PACKAGE_PYTHON3_PY_ONLY case.
PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the
optimized *.opt-1.pyc and *.opt-2.pyc files, which is done
unconditionally.
- The PEP3147 disabling patch had to be significantly reworked due to
the code having changed heavily. The code was moved into a
_bootstrap_external.py, which is a "frozen" Python module, i.e a
module generated into a .h file at compile time using the
_freeze_importlib program.
- Due to the above, we now need to regenerate importlib.h at build
time. Unfortunately, for the target Python _freeze_importlib is
built for the target, so we can't run it on the build machine. To
fix this, we copy the _freeze_importlib program from the
host-python in $(HOST_DIR), and then patch the target python to use
it. Since the same solution can be used for 'pgen', we do it, and
avoid having to touch the graminit.{c,h} files.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-05-01 22:15:12 +02:00
|
|
|
Lib/importlib/_bootstrap_external.py | 37 +++++-------------------------------
|
|
|
|
1 file changed, 5 insertions(+), 32 deletions(-)
|
2015-11-14 16:54:30 +01:00
|
|
|
|
python3: bump to 3.5.1
The major changes in terms of Buildroot packaging are:
- Due to PEP488, Python no longer generates .pyc (unoptimized) and
.pyo (optimized) byte-code files. Instead, it generates <foo>.pyc,
<foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the
--disable-pyo-build option and kept only the --disable-pyc-build
option, which completely disables building all .pyc files. In
addition, since the optimized .opt-X.pyc files don't work if the
corresponding un-optimized .pyc file is not present, we are for the
moment unconditionally removing the optimized ones (keeping both
the unoptimized and optimized ones doubles the required filesystem
size!). So basically we preserve the behavior we had before this
commit:
BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py
BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc
BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc
To achieve this, the TARGET_FINALIZE_HOOKS are reworked:
PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in
the BR2_PACKAGE_PYTHON3_PYC_ONLY case.
PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files
in the BR2_PACKAGE_PYTHON3_PY_ONLY case.
PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the
optimized *.opt-1.pyc and *.opt-2.pyc files, which is done
unconditionally.
- The PEP3147 disabling patch had to be significantly reworked due to
the code having changed heavily. The code was moved into a
_bootstrap_external.py, which is a "frozen" Python module, i.e a
module generated into a .h file at compile time using the
_freeze_importlib program.
- Due to the above, we now need to regenerate importlib.h at build
time. Unfortunately, for the target Python _freeze_importlib is
built for the target, so we can't run it on the build machine. To
fix this, we copy the _freeze_importlib program from the
host-python in $(HOST_DIR), and then patch the target python to use
it. Since the same solution can be used for 'pgen', we do it, and
avoid having to touch the graminit.{c,h} files.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-05-01 22:15:12 +02:00
|
|
|
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
|
|
|
|
index 616b17f..e30129c 100644
|
|
|
|
--- a/Lib/importlib/_bootstrap_external.py
|
|
|
|
+++ b/Lib/importlib/_bootstrap_external.py
|
|
|
|
@@ -255,8 +255,6 @@ def cache_from_source(path, debug_override=None, *, optimization=None):
|
|
|
|
a True value is the same as setting 'optimization' to the empty string
|
|
|
|
while a False value is equivalent to setting 'optimization' to '1'.
|
2015-11-14 16:54:30 +01:00
|
|
|
|
|
|
|
- If sys.implementation.cache_tag is None then NotImplementedError is raised.
|
|
|
|
-
|
|
|
|
"""
|
python3: bump to 3.5.1
The major changes in terms of Buildroot packaging are:
- Due to PEP488, Python no longer generates .pyc (unoptimized) and
.pyo (optimized) byte-code files. Instead, it generates <foo>.pyc,
<foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the
--disable-pyo-build option and kept only the --disable-pyc-build
option, which completely disables building all .pyc files. In
addition, since the optimized .opt-X.pyc files don't work if the
corresponding un-optimized .pyc file is not present, we are for the
moment unconditionally removing the optimized ones (keeping both
the unoptimized and optimized ones doubles the required filesystem
size!). So basically we preserve the behavior we had before this
commit:
BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py
BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc
BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc
To achieve this, the TARGET_FINALIZE_HOOKS are reworked:
PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in
the BR2_PACKAGE_PYTHON3_PYC_ONLY case.
PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files
in the BR2_PACKAGE_PYTHON3_PY_ONLY case.
PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the
optimized *.opt-1.pyc and *.opt-2.pyc files, which is done
unconditionally.
- The PEP3147 disabling patch had to be significantly reworked due to
the code having changed heavily. The code was moved into a
_bootstrap_external.py, which is a "frozen" Python module, i.e a
module generated into a .h file at compile time using the
_freeze_importlib program.
- Due to the above, we now need to regenerate importlib.h at build
time. Unfortunately, for the target Python _freeze_importlib is
built for the target, so we can't run it on the build machine. To
fix this, we copy the _freeze_importlib program from the
host-python in $(HOST_DIR), and then patch the target python to use
it. Since the same solution can be used for 'pgen', we do it, and
avoid having to touch the graminit.{c,h} files.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-05-01 22:15:12 +02:00
|
|
|
if debug_override is not None:
|
|
|
|
_warnings.warn('the debug_override parameter is deprecated; use '
|
|
|
|
@@ -267,10 +265,7 @@ def cache_from_source(path, debug_override=None, *, optimization=None):
|
|
|
|
optimization = '' if debug_override else 1
|
2015-11-14 16:54:30 +01:00
|
|
|
head, tail = _path_split(path)
|
|
|
|
base, sep, rest = tail.rpartition('.')
|
|
|
|
- tag = sys.implementation.cache_tag
|
|
|
|
- if tag is None:
|
|
|
|
- raise NotImplementedError('sys.implementation.cache_tag is None')
|
python3: bump to 3.5.1
The major changes in terms of Buildroot packaging are:
- Due to PEP488, Python no longer generates .pyc (unoptimized) and
.pyo (optimized) byte-code files. Instead, it generates <foo>.pyc,
<foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the
--disable-pyo-build option and kept only the --disable-pyc-build
option, which completely disables building all .pyc files. In
addition, since the optimized .opt-X.pyc files don't work if the
corresponding un-optimized .pyc file is not present, we are for the
moment unconditionally removing the optimized ones (keeping both
the unoptimized and optimized ones doubles the required filesystem
size!). So basically we preserve the behavior we had before this
commit:
BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py
BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc
BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc
To achieve this, the TARGET_FINALIZE_HOOKS are reworked:
PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in
the BR2_PACKAGE_PYTHON3_PYC_ONLY case.
PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files
in the BR2_PACKAGE_PYTHON3_PY_ONLY case.
PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the
optimized *.opt-1.pyc and *.opt-2.pyc files, which is done
unconditionally.
- The PEP3147 disabling patch had to be significantly reworked due to
the code having changed heavily. The code was moved into a
_bootstrap_external.py, which is a "frozen" Python module, i.e a
module generated into a .h file at compile time using the
_freeze_importlib program.
- Due to the above, we now need to regenerate importlib.h at build
time. Unfortunately, for the target Python _freeze_importlib is
built for the target, so we can't run it on the build machine. To
fix this, we copy the _freeze_importlib program from the
host-python in $(HOST_DIR), and then patch the target python to use
it. Since the same solution can be used for 'pgen', we do it, and
avoid having to touch the graminit.{c,h} files.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-05-01 22:15:12 +02:00
|
|
|
- almost_filename = ''.join([(base if base else rest), sep, tag])
|
|
|
|
+ almost_filename = ''.join([(base if base else rest)])
|
|
|
|
if optimization is None:
|
|
|
|
if sys.flags.optimize == 0:
|
|
|
|
optimization = ''
|
|
|
|
@@ -281,39 +276,17 @@ def cache_from_source(path, debug_override=None, *, optimization=None):
|
|
|
|
if not optimization.isalnum():
|
|
|
|
raise ValueError('{!r} is not alphanumeric'.format(optimization))
|
|
|
|
almost_filename = '{}.{}{}'.format(almost_filename, _OPT, optimization)
|
|
|
|
- return _path_join(head, _PYCACHE, almost_filename + BYTECODE_SUFFIXES[0])
|
|
|
|
+ return _path_join(head, almost_filename + BYTECODE_SUFFIXES[0])
|
2015-11-14 16:54:30 +01:00
|
|
|
|
|
|
|
|
|
|
|
def source_from_cache(path):
|
python3: bump to 3.5.1
The major changes in terms of Buildroot packaging are:
- Due to PEP488, Python no longer generates .pyc (unoptimized) and
.pyo (optimized) byte-code files. Instead, it generates <foo>.pyc,
<foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the
--disable-pyo-build option and kept only the --disable-pyc-build
option, which completely disables building all .pyc files. In
addition, since the optimized .opt-X.pyc files don't work if the
corresponding un-optimized .pyc file is not present, we are for the
moment unconditionally removing the optimized ones (keeping both
the unoptimized and optimized ones doubles the required filesystem
size!). So basically we preserve the behavior we had before this
commit:
BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py
BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc
BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc
To achieve this, the TARGET_FINALIZE_HOOKS are reworked:
PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in
the BR2_PACKAGE_PYTHON3_PYC_ONLY case.
PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files
in the BR2_PACKAGE_PYTHON3_PY_ONLY case.
PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the
optimized *.opt-1.pyc and *.opt-2.pyc files, which is done
unconditionally.
- The PEP3147 disabling patch had to be significantly reworked due to
the code having changed heavily. The code was moved into a
_bootstrap_external.py, which is a "frozen" Python module, i.e a
module generated into a .h file at compile time using the
_freeze_importlib program.
- Due to the above, we now need to regenerate importlib.h at build
time. Unfortunately, for the target Python _freeze_importlib is
built for the target, so we can't run it on the build machine. To
fix this, we copy the _freeze_importlib program from the
host-python in $(HOST_DIR), and then patch the target python to use
it. Since the same solution can be used for 'pgen', we do it, and
avoid having to touch the graminit.{c,h} files.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-05-01 22:15:12 +02:00
|
|
|
"""Given the path to a .pyc. file, return the path to its .py file.
|
2015-11-14 16:54:30 +01:00
|
|
|
|
python3: bump to 3.5.1
The major changes in terms of Buildroot packaging are:
- Due to PEP488, Python no longer generates .pyc (unoptimized) and
.pyo (optimized) byte-code files. Instead, it generates <foo>.pyc,
<foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the
--disable-pyo-build option and kept only the --disable-pyc-build
option, which completely disables building all .pyc files. In
addition, since the optimized .opt-X.pyc files don't work if the
corresponding un-optimized .pyc file is not present, we are for the
moment unconditionally removing the optimized ones (keeping both
the unoptimized and optimized ones doubles the required filesystem
size!). So basically we preserve the behavior we had before this
commit:
BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py
BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc
BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc
To achieve this, the TARGET_FINALIZE_HOOKS are reworked:
PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in
the BR2_PACKAGE_PYTHON3_PYC_ONLY case.
PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files
in the BR2_PACKAGE_PYTHON3_PY_ONLY case.
PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the
optimized *.opt-1.pyc and *.opt-2.pyc files, which is done
unconditionally.
- The PEP3147 disabling patch had to be significantly reworked due to
the code having changed heavily. The code was moved into a
_bootstrap_external.py, which is a "frozen" Python module, i.e a
module generated into a .h file at compile time using the
_freeze_importlib program.
- Due to the above, we now need to regenerate importlib.h at build
time. Unfortunately, for the target Python _freeze_importlib is
built for the target, so we can't run it on the build machine. To
fix this, we copy the _freeze_importlib program from the
host-python in $(HOST_DIR), and then patch the target python to use
it. Since the same solution can be used for 'pgen', we do it, and
avoid having to touch the graminit.{c,h} files.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-05-01 22:15:12 +02:00
|
|
|
The .pyc file does not need to exist; this simply returns the path to
|
|
|
|
- the .py file calculated to correspond to the .pyc file. If path does
|
|
|
|
- not conform to PEP 3147/488 format, ValueError will be raised. If
|
2015-11-14 16:54:30 +01:00
|
|
|
- sys.implementation.cache_tag is None then NotImplementedError is raised.
|
python3: bump to 3.5.1
The major changes in terms of Buildroot packaging are:
- Due to PEP488, Python no longer generates .pyc (unoptimized) and
.pyo (optimized) byte-code files. Instead, it generates <foo>.pyc,
<foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the
--disable-pyo-build option and kept only the --disable-pyc-build
option, which completely disables building all .pyc files. In
addition, since the optimized .opt-X.pyc files don't work if the
corresponding un-optimized .pyc file is not present, we are for the
moment unconditionally removing the optimized ones (keeping both
the unoptimized and optimized ones doubles the required filesystem
size!). So basically we preserve the behavior we had before this
commit:
BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py
BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc
BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc
To achieve this, the TARGET_FINALIZE_HOOKS are reworked:
PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in
the BR2_PACKAGE_PYTHON3_PYC_ONLY case.
PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files
in the BR2_PACKAGE_PYTHON3_PY_ONLY case.
PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the
optimized *.opt-1.pyc and *.opt-2.pyc files, which is done
unconditionally.
- The PEP3147 disabling patch had to be significantly reworked due to
the code having changed heavily. The code was moved into a
_bootstrap_external.py, which is a "frozen" Python module, i.e a
module generated into a .h file at compile time using the
_freeze_importlib program.
- Due to the above, we now need to regenerate importlib.h at build
time. Unfortunately, for the target Python _freeze_importlib is
built for the target, so we can't run it on the build machine. To
fix this, we copy the _freeze_importlib program from the
host-python in $(HOST_DIR), and then patch the target python to use
it. Since the same solution can be used for 'pgen', we do it, and
avoid having to touch the graminit.{c,h} files.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-05-01 22:15:12 +02:00
|
|
|
-
|
|
|
|
+ the .py file calculated to correspond to the .pyc file.
|
2015-11-14 16:54:30 +01:00
|
|
|
"""
|
|
|
|
- if sys.implementation.cache_tag is None:
|
|
|
|
- raise NotImplementedError('sys.implementation.cache_tag is None')
|
|
|
|
- head, pycache_filename = _path_split(path)
|
|
|
|
- head, pycache = _path_split(head)
|
|
|
|
- if pycache != _PYCACHE:
|
|
|
|
- raise ValueError('{} not bottom-level directory in '
|
|
|
|
- '{!r}'.format(_PYCACHE, path))
|
python3: bump to 3.5.1
The major changes in terms of Buildroot packaging are:
- Due to PEP488, Python no longer generates .pyc (unoptimized) and
.pyo (optimized) byte-code files. Instead, it generates <foo>.pyc,
<foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the
--disable-pyo-build option and kept only the --disable-pyc-build
option, which completely disables building all .pyc files. In
addition, since the optimized .opt-X.pyc files don't work if the
corresponding un-optimized .pyc file is not present, we are for the
moment unconditionally removing the optimized ones (keeping both
the unoptimized and optimized ones doubles the required filesystem
size!). So basically we preserve the behavior we had before this
commit:
BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py
BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc
BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc
To achieve this, the TARGET_FINALIZE_HOOKS are reworked:
PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in
the BR2_PACKAGE_PYTHON3_PYC_ONLY case.
PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files
in the BR2_PACKAGE_PYTHON3_PY_ONLY case.
PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the
optimized *.opt-1.pyc and *.opt-2.pyc files, which is done
unconditionally.
- The PEP3147 disabling patch had to be significantly reworked due to
the code having changed heavily. The code was moved into a
_bootstrap_external.py, which is a "frozen" Python module, i.e a
module generated into a .h file at compile time using the
_freeze_importlib program.
- Due to the above, we now need to regenerate importlib.h at build
time. Unfortunately, for the target Python _freeze_importlib is
built for the target, so we can't run it on the build machine. To
fix this, we copy the _freeze_importlib program from the
host-python in $(HOST_DIR), and then patch the target python to use
it. Since the same solution can be used for 'pgen', we do it, and
avoid having to touch the graminit.{c,h} files.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-05-01 22:15:12 +02:00
|
|
|
- dot_count = pycache_filename.count('.')
|
|
|
|
- if dot_count not in {2, 3}:
|
|
|
|
- raise ValueError('expected only 2 or 3 dots in '
|
2015-11-14 16:54:30 +01:00
|
|
|
- '{!r}'.format(pycache_filename))
|
python3: bump to 3.5.1
The major changes in terms of Buildroot packaging are:
- Due to PEP488, Python no longer generates .pyc (unoptimized) and
.pyo (optimized) byte-code files. Instead, it generates <foo>.pyc,
<foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the
--disable-pyo-build option and kept only the --disable-pyc-build
option, which completely disables building all .pyc files. In
addition, since the optimized .opt-X.pyc files don't work if the
corresponding un-optimized .pyc file is not present, we are for the
moment unconditionally removing the optimized ones (keeping both
the unoptimized and optimized ones doubles the required filesystem
size!). So basically we preserve the behavior we had before this
commit:
BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py
BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc
BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc
To achieve this, the TARGET_FINALIZE_HOOKS are reworked:
PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in
the BR2_PACKAGE_PYTHON3_PYC_ONLY case.
PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files
in the BR2_PACKAGE_PYTHON3_PY_ONLY case.
PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the
optimized *.opt-1.pyc and *.opt-2.pyc files, which is done
unconditionally.
- The PEP3147 disabling patch had to be significantly reworked due to
the code having changed heavily. The code was moved into a
_bootstrap_external.py, which is a "frozen" Python module, i.e a
module generated into a .h file at compile time using the
_freeze_importlib program.
- Due to the above, we now need to regenerate importlib.h at build
time. Unfortunately, for the target Python _freeze_importlib is
built for the target, so we can't run it on the build machine. To
fix this, we copy the _freeze_importlib program from the
host-python in $(HOST_DIR), and then patch the target python to use
it. Since the same solution can be used for 'pgen', we do it, and
avoid having to touch the graminit.{c,h} files.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Reviewed-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-05-01 22:15:12 +02:00
|
|
|
- elif dot_count == 3:
|
|
|
|
- optimization = pycache_filename.rsplit('.', 2)[-2]
|
|
|
|
- if not optimization.startswith(_OPT):
|
|
|
|
- raise ValueError("optimization portion of filename does not start "
|
|
|
|
- "with {!r}".format(_OPT))
|
|
|
|
- opt_level = optimization[len(_OPT):]
|
|
|
|
- if not opt_level.isalnum():
|
|
|
|
- raise ValueError("optimization level {!r} is not an alphanumeric "
|
|
|
|
- "value".format(optimization))
|
2015-11-14 16:54:30 +01:00
|
|
|
- base_filename = pycache_filename.partition('.')[0]
|
|
|
|
+ head, filename = _path_split(path)
|
|
|
|
+ base_filename = filename.partition('.')[0]
|
|
|
|
return _path_join(head, base_filename + SOURCE_SUFFIXES[0])
|
|
|
|
|
|
|
|
|
2016-01-04 19:23:28 +01:00
|
|
|
--
|
|
|
|
2.6.4
|
|
|
|
|