#8 Fix %py_byte_compile macro
Merged a year ago by churchyard. Opened a year ago by torsava.
rpms/ torsava/python-rpm-macros py_byte_compile  into  master

file modified
+1 -1

@@ -21,5 +21,5 @@ 

      find $bytecode_compilation_path -type f -a -name "*.py" -print0 | xargs -0 $python_binary -O -c 'import py_compile, sys; [py_compile.compile(f, dfile=f.partition("$RPM_BUILD_ROOT")[2], optimize=opt) for opt in range(2) for f in sys.argv[1:]]' || :\

  }\

  \

- [[ "%1" == *python3* ]] || py2_byte_compile "%1" "%2" && py3_byte_compile "%1" "%2" \

+ [[ "%1" != *python3* ]] && py2_byte_compile "%1" "%2" || py3_byte_compile "%1" "%2" \

  %{nil}

file modified
+5 -1

@@ -1,6 +1,6 @@ 

  Name:           python-rpm-macros

  Version:        3

- Release:        31%{?dist}

+ Release:        32%{?dist}

  Summary:        The unversioned Python RPM macros

  

  License:        MIT

@@ -71,6 +71,10 @@ 

  

  

  %changelog

+ * Tue Jul 10 2018 Tomas Orsava <torsava@redhat.com> - 3-32

+ - Fix %%py_byte_compile macro: when invoked with a Python 2 binary it also

+   mistakenly ran py3_byte_compile

+ 

  * Tue Jul 03 2018 Miro Hrončok <mhroncok@redhat.com> - 3-31

  - Add %%python3_platform useful for PYTHONPATH on arched builds

  

When invoked with a Python 2 binary it also mistakenly ran py3_byte_compile.

Koji scratch build: https://koji.fedoraproject.org/koji/taskinfo?taskID=28106191

rebased onto f961fbb

a year ago

actually not, it's still wrong

you should swap py2 and py3 in code.

Fixed a bug in the implementation.

Previously:

$ [[ "/usr/bin/python" == *python3* ]] || echo py2_byte_compile "%1" "%2" && echo py3_byte_compile "%1" "%2"
py2_byte_compile %1 %2
py3_byte_compile %1 %2

$ [[ "/usr/bin/python2" == *python3* ]] || echo py2_byte_compile "%1" "%2" && echo py3_byte_compile "%1" "%2"
py2_byte_compile %1 %2
py3_byte_compile %1 %2

$ [[ "/usr/bin/python3" == *python3* ]] || echo py2_byte_compile "%1" "%2" && echo py3_byte_compile "%1" "%2"
py3_byte_compile %1 %2

Now:

$ [[ "/usr/bin/python" != *python3* ]] && echo py2_byte_compile "%1" "%2" || echo py3_byte_compile "%1" "%2"
py2_byte_compile %1 %2

$ [[ "/usr/bin/python2" != *python3* ]] && echo py2_byte_compile "%1" "%2" || echo py3_byte_compile "%1" "%2"
py2_byte_compile %1 %2

$ [[ "/usr/bin/python3" != *python3* ]] && echo py2_byte_compile "%1" "%2" || echo py3_byte_compile "%1" "%2"
py3_byte_compile %1 %2

actually not, it's still wrong

I've spotted the error and @torsava did a fix and amended the change to f961fbb

I did some rudimentary testing in mock with rpm --eval and it seems to work :)

Pull-Request has been merged by churchyard

a year ago