Skip to contentSkip to conversation

automake: omit compilation of pyc files on install

PATCH Applied Andreas Oberritter 2 participants 2 messages Feb 25, 2012 – Mar 5, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 automake: omit compilation of pyc files on install

* On install, automake calls py-compile, which previously compiled python source code to pyc and pyo, which both got packaged.
* The python interpreter in OE contains patches to enable optimization (pyo) by default:
04-default-is-optimized.patch 99-ignore-optimization-flag.patch
* automake created pyc files by calling py_compile.compile() and adding the c suffix manually, resulting in identical byte code for both pyc and pyo files.
* py-compile-compile-only-optimized-byte-code.patch applies to automake 1.11 and automake master, but older versions require a slightly modified patch. However, older versions are only pinned by chinook-compat and nylon, so I left them untouched.

The patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded) as of commit id aa4585c5065e05c759f16e1e8623fc7f40640f1b.

Modified to apply to automake version 1.11.2 and to include a patch header. Also renamed the patch.

---
 ...-compile-compile-only-optimized-byte-code.patch |   42 ++++++++++++++++++++
 meta/recipes-devtools/automake/automake_1.11.2.bb  |    5 +-
 2 files changed, 45 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-devtools/automake/automake/py-compile-compile-only-optimized-byte-code.patch
meta/recipes-devtools/automake/automake/py-compile-compile-only-optimized-byte-code.patch new file +42 -0
new file mode 100644
index 0000000..f09bfbc
@@ -0,0 +1,42 @@
+Upstream-Status: Inappropriate [embedded specific]
+
+* OE-Core's python creates the same binary output
+  for both pyc and pyo, so disable the creation of
+  pyc files by automake.
+
+Signed-off-by: Andreas Oberritter <[email protected]>
+---
+ lib/py-compile |   17 -----------------
+ 1 files changed, 0 insertions(+), 17 deletions(-)
+
+diff --git a/lib/py-compile b/lib/py-compile
+index 3f9d05b..101c814 100755
+--- a/lib/py-compile
++++ b/lib/py-compile
+@@ -101,23 +101,6 @@ else
+     filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
+ fi
+ 
+-$PYTHON -c "
+-import sys, os, py_compile
+-
+-files = '''$files'''
+-
+-sys.stdout.write('Byte-compiling python modules...\n')
+-for file in files.split():
+-    $pathtrans
+-    $filetrans
+-    if not os.path.exists(filepath) or not (len(filepath) >= 3
+-                                            and filepath[-3:] == '.py'):
+-	    continue
+-    sys.stdout.write(file)
+-    sys.stdout.flush()
+-    py_compile.compile(filepath, filepath + 'c', path)
+-sys.stdout.write('\n')" || exit $?
+-
+ # this will fail for python < 1.5, but that doesn't matter ...
+ $PYTHON -O -c "
+ import sys, os, py_compile
+-- 
+1.7.0.4
+
meta/recipes-devtools/automake/automake_1.11.2.bb +3 -2
index 4534c39..4271336 100644
@@ -37,9 +37,10 @@ PATHFIXPATCH_virtclass-nativesdk = ""
 SRC_URI += "${PATHFIXPATCH} \
 	    file://prefer-cpio-over-pax-for-ustar-archives.patch \
 	    file://python-libdir.patch \
-            file://automake_1.11.2_fix_for_pkglibexec_SCRIPTS.patch"
+            file://automake_1.11.2_fix_for_pkglibexec_SCRIPTS.patch \
+            file://py-compile-compile-only-optimized-byte-code.patch"
 
-PR = "r1"
+PR = "r2"
 SRC_URI[md5sum] = "18194e804d415767bae8f703c963d456"
 SRC_URI[sha256sum] = "4f46d1f9380c8a3506280750f630e9fc915cb1a435b724be56b499d016368718"
 
Signature · 1 line
1.7.5.4
Applied
#1 lore raw
Quoted 88 lines · Andreas Oberritter

* On install, automake calls py-compile, which previously compiled python source code to pyc and pyo, which both got packaged.
* The python interpreter in OE contains patches to enable optimization (pyo) by default:
04-default-is-optimized.patch 99-ignore-optimization-flag.patch
* automake created pyc files by calling py_compile.compile() and adding the c suffix manually, resulting in identical byte code for both pyc and pyo files.
* py-compile-compile-only-optimized-byte-code.patch applies to automake 1.11 and automake master, but older versions require a slightly modified patch. However, older versions are only pinned by chinook-compat and nylon, so I left them untouched.

The patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded) as of commit id aa4585c5065e05c759f16e1e8623fc7f40640f1b.

Modified to apply to automake version 1.11.2 and to include a patch header. Also renamed the patch.

---
  ...-compile-compile-only-optimized-byte-code.patch |   42 ++++++++++++++++++++
  meta/recipes-devtools/automake/automake_1.11.2.bb  |    5 +-
  2 files changed, 45 insertions(+), 2 deletions(-)

create mode 100644 meta/recipes-devtools/automake/automake/py-compile-compile-only-optimized-byte-code.patch

meta/recipes-devtools/automake/automake/py-compile-compile-only-optimized-byte-code.patch new file +42 -0
new file mode 100644
index 0000000..f09bfbc
@@ -0,0 +1,42 @@
+Upstream-Status: Inappropriate [embedded specific]
+
+* OE-Core's python creates the same binary output
+  for both pyc and pyo, so disable the creation of
+  pyc files by automake.
+
+Signed-off-by: Andreas Oberritter<[email protected]>
+---
+ lib/py-compile |   17 -----------------
+ 1 files changed, 0 insertions(+), 17 deletions(-)
+
+diff --git a/lib/py-compile b/lib/py-compile
+index 3f9d05b..101c814 100755
+--- a/lib/py-compile
++++ b/lib/py-compile
+@@ -101,23 +101,6 @@ else
+     filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
+ fi
+
+-$PYTHON -c "
+-import sys, os, py_compile
+-
+-files = '''$files'''
+-
+-sys.stdout.write('Byte-compiling python modules...\n')
+-for file in files.split():
+-    $pathtrans
+-    $filetrans
+-    if not os.path.exists(filepath) or not (len(filepath)>= 3
+-                                            and filepath[-3:] == '.py'):
+-	    continue
+-    sys.stdout.write(file)
+-    sys.stdout.flush()
+-    py_compile.compile(filepath, filepath + 'c', path)
+-sys.stdout.write('\n')" || exit $?
+-
+ # this will fail for python<  1.5, but that doesn't matter ...
+ $PYTHON -O -c "
+ import sys, os, py_compile
+--
+1.7.0.4
+
meta/recipes-devtools/automake/automake_1.11.2.bb +0 -0
index 4534c39..4271336 100644
@@ -37,9 +37,10 @@ PATHFIXPATCH_virtclass-nativesdk = ""
  SRC_URI += "${PATHFIXPATCH} \
  	    file://prefer-cpio-over-pax-for-ustar-archives.patch \

meta/recipes-devtools/automake/automake_1.11.2.bb PATHFIXPATCH_virtclass-nativesdk = "" · line 46

Quoted 10 lines
meta/recipes-devtools/automake/automake_1.11.2.bb +3 -2
  	    file://python-libdir.patch \
-            file://automake_1.11.2_fix_for_pkglibexec_SCRIPTS.patch"
+            file://automake_1.11.2_fix_for_pkglibexec_SCRIPTS.patch \
+            file://py-compile-compile-only-optimized-byte-code.patch"
 
-PR = "r1"
+PR = "r2"
  SRC_URI[md5sum] = "18194e804d415767bae8f703c963d456"
  SRC_URI[sha256sum] = "4f46d1f9380c8a3506280750f630e9fc915cb1a435b724be56b499d016368718"
 

Merged into OE-core

Thanks
Sau!