#4 Move macros.pybytecompile from python3-devel
Merged 6 years ago by churchyard. Opened 6 years ago by churchyard.
rpms/ churchyard/python-rpm-macros pybytecompile  into  master

file added
+25
@@ -0,0 +1,25 @@ 

+ # Note that the path could itself be a python file, or a directory

+ 

+ # Python's compile_all module only works on directories, and requires a max

+ # recursion depth

+ 

+ # Note that the py_byte_compile macro should work for python2 as well

+ # Which unfortunately makes the definition more complicated than it should be

+ # The condition should be reversed once /usr/bin/python is python3!

+ 

+ %py_byte_compile()\

+ py2_byte_compile () {\

+     python_binary="%1"\

+     bytecode_compilation_path="%2"\

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

+     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]) for f in sys.argv[1:]]' || :\

+ }\

+ \

+ py3_byte_compile () {\

seems like missing %

this is a shell function, not a macro definition.

+     python_binary="%1"\

+     bytecode_compilation_path="%2"\

+     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" \

+ %{nil}

file modified
+7 -2
@@ -1,6 +1,6 @@ 

  Name:           python-rpm-macros

  Version:        3

- Release:        28%{?dist}

+ Release:        29%{?dist}

  Summary:        The unversioned Python RPM macros

  

  License:        MIT
@@ -8,6 +8,7 @@ 

  Source1:        macros.python-srpm

  Source2:        macros.python2

  Source3:        macros.python3

+ Source4:        macros.pybytecompile

  

  BuildArch:      noarch

  # For %%python3_pkgversion used in %%python_provide
@@ -51,12 +52,13 @@ 

  

  %install

  mkdir -p %{buildroot}/%{rpmmacrodir}

- install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} \

+ install -m 644 %{SOURCE0} %{SOURCE1} %{SOURCE2} %{SOURCE3} %{SOURCE4} \

    %{buildroot}/%{rpmmacrodir}/

  

  

  %files

  %{rpmmacrodir}/macros.python

+ %{rpmmacrodir}/macros.pybytecompile

  

  %files -n python-srpm-macros

  %{rpmmacrodir}/macros.python-srpm
@@ -69,6 +71,9 @@ 

  

  

  %changelog

+ * Wed Apr 18 2018 Miro Hrončok <mhroncok@redhat.com> - 3-29

+ - move macros.pybytecompile from python3-devel

+ 

  * Fri Apr 06 2018 Tomas Orsava <torsava@redhat.com> - 3-28

  - Fix the %%py_dist_name macro to not convert dots (".") into dashes, so that

    submodules can be addressed as well

cc @pviktori

this is a shell function, not a macro definition.

Metadata Update from @churchyard:
- Request assigned

6 years ago

rebased onto 7391367

6 years ago

Tested and it works. I can see the macro working by following the instructions outlined here: https://src.fedoraproject.org/rpms/python37/pull-request/3#

Also removed the macros.pybytecompile3.6 and it still works. So overall looks good to me.

Please bump the release though before merging, as there was another fix on top.

9 new commits added

  • Move macros.pybytecompile from python3-devel
  • Make the pybytecompile version agnostic again
  • Fix the py_byte_compile macro to work on Python 2
  • Fix syntax error in %py_byte_compile macro (rhbz#1433569)
  • Update macros.pybytecompile to 3.6
  • Update %py_byte_compile macro
  • Rename macros to 3.5
  • Update macros.pybytecompile to 3.4
  • Introduce macros.pybytecompile
6 years ago

Pull-Request has been merged by churchyard

6 years ago