X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=pakfire%2Fpatches%2F0006-python-Byte-compile-all-files-in-sitelib.patch;fp=pakfire%2Fpatches%2F0006-python-Byte-compile-all-files-in-sitelib.patch;h=0000000000000000000000000000000000000000;hb=5185dcd49e70aacbdfb358fdfc8506eba2c03923;hp=070aa4749c6b6e3f81684617e177dba1918a35e8;hpb=8cd4ef584f302521dd5f6a9da75a6d20dc6f9cb9;p=people%2Fms%2Fipfire-3.x.git diff --git a/pakfire/patches/0006-python-Byte-compile-all-files-in-sitelib.patch b/pakfire/patches/0006-python-Byte-compile-all-files-in-sitelib.patch deleted file mode 100644 index 070aa4749..000000000 --- a/pakfire/patches/0006-python-Byte-compile-all-files-in-sitelib.patch +++ /dev/null @@ -1,167 +0,0 @@ -From e9e430d4fd5b09327f57651726ffac1b7874ae01 Mon Sep 17 00:00:00 2001 -From: Michael Tremer -Date: Wed, 3 Oct 2012 00:45:11 +0200 -Subject: [PATCH 6/6] python: Byte-compile all files in sitelib. - -For files which are located elsewhere, it is required -to call: - python_bytecompile ... (Python 2) -or - python3_bytecompile ... (Python 3) ---- - macros/build.macro | 12 ++++++- - macros/python.macro | 3 ++ - tools/py-compile | 90 +++++++++++++++++++++++++++++------------------------ - 3 files changed, 64 insertions(+), 41 deletions(-) - -diff --git a/macros/build.macro b/macros/build.macro -index 6987068..4e4d830 100644 ---- a/macros/build.macro -+++ b/macros/build.macro -@@ -46,7 +46,17 @@ def MACRO_INSTALL_LOGROTATE_FILES - end - - def MACRO_PYTHON_COMPILE -- # XXX TODO -+ if [ -x "%{python3}" ]; then -+ %{python3_bytecompile} \ -+ %{BUILDROOT}%{python3_sitearch} \ -+ %{BUILDROOT}%{python3_sitelib} -+ fi -+ -+ if [ -x "%{python}" ]; then -+ %{python_bytecompile} \ -+ %{BUILDROOT}%{python_sitearch} \ -+ %{BUILDROOT}%{python_sitelib} -+ fi - end - - MACRO_PERL_CLEANUP -diff --git a/macros/python.macro b/macros/python.macro -index 1b417f2..15c1209 100644 ---- a/macros/python.macro -+++ b/macros/python.macro -@@ -1,7 +1,9 @@ - # A bunch of predefined things for Python. -+python_bytecompile_script = /usr/lib/pakfire/py-compile - - # Python 3 constants. - python3 = /usr/bin/python3 -+python3_bytecompile = %{python_bytecompile_script} --python=%{python3} - - python3_sitearch = %(%{python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))") - python3_sitelib = %(%{python3} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") -@@ -9,6 +11,7 @@ python3_version = %(%{python3} -c "import sys; sys.stdout.write(sys.version[:3] - - # Python 2 constants. - python = /usr/bin/python2 -+python_bytecompile = %{python_bytecompile_script} --python=%{python} - - python_sitearch = %(%{python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)") - python_sitelib = %(%{python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()") -diff --git a/tools/py-compile b/tools/py-compile -index 66c33ed..5ccd8f9 100755 ---- a/tools/py-compile -+++ b/tools/py-compile -@@ -1,48 +1,58 @@ - #!/bin/sh - --PYTHON=$(which python 2>/dev/null) -+python_interpreter="python" -+paths="" -+ -+while [ $# -gt 0 ]; do -+ case "${1}" in -+ --python=*) -+ python_interpreter=${1#--python=} -+ ;; -+ *) -+ paths="${paths} ${1}" -+ ;; -+ esac -+ shift -+done - --if [ -z "${PYTHON}" ]; then -- # Python is not present. Fail silently. -- exit 0 -+if [ -z "${paths}" ]; then -+ echo >&2 "No path specified!" -+ exit 1 - fi - --files="" --for i in $*; do -- if [ -e ${i}c ] && [ -e ${i}o ]; then -- continue # all files we want are already there -- fi -- files="$files $i" --done -+if [ "${python_interpreter:0:1}" != "/" ]; then -+ python_interpreter=$(which ${python_interpreter} 2>/dev/null) -+fi - --if [ -z "${files}" ]; then -- # No files need to be proceeded. -- exit 0 -+if [ ! -x "${python_interpreter}" ]; then -+ echo >&2 "Python interpreter is not executable: ${python_interpreter}" -+ exit 1 - fi - --$PYTHON -c " --import sys, os, string, py_compile -- --files = '''$files''' --print 'Byte-compiling python modules...' --for file in string.split(files): -- if not os.path.exists(file) or not (len(file) >= 3 and file[-3:] == '.py'): -- continue -- print file, -- sys.stdout.flush() -- py_compile.compile(file) --print" || exit $? -- --# this will fail for python < 1.5, but that doesn't matter ... --$PYTHON -O -c " --import sys, os, string, py_compile -- --files = '''$files''' --print 'Byte-compiling python modules (optimised versions) ...' --for file in string.split(files): -- if not os.path.exists(file) or not (len(file) >= 3 and file[-3:] == '.py'): -- continue -- print file, -- sys.stdout.flush() -- py_compile.compile(file) --print" 2>/dev/null || : -+tempfile=$(mktemp) -+trap "rm -f ${tempfile}" EXIT -+ -+cat > ${tempfile} <