#1 Force python3 during build process
Opened 2 months ago by senderek. Modified 2 months ago
rpms/ senderek/jack-audio-connection-kit master  into  master

file added
+14

@@ -0,0 +1,14 @@ 

+ #!/usr/bin/bash

+ 

+ # Author:  Ralf Senderek, Ireland

+ # License: GPL2+

+ # Date:    20/7/2019

+ 

+ echo "Find python files ..."

+ FILES=$(grep -l "env python" $(find . -type f) )

+ for X in $(echo $FILES) 

+ do

+     echo changing: $X

+     sed -i '1s/#!\/usr\/bin\/env python/#!\/usr\/bin\/python3/' $X

+     sed -i '1s/#! \/usr\/bin\/env python/#!\/usr\/bin\/python3/' $X

+ done

@@ -11,7 +11,7 @@ 

  Summary:       The Jack Audio Connection Kit

  Name:          jack-audio-connection-kit

  Version:       1.9.12

- Release:       8%{?dist}

+ Release:       9%{?dist}

  # The entire source (~500 files) is a mixture of these three licenses

  License:       GPLv2 and GPLv2+ and LGPLv2+

  URL:           http://www.jackaudio.org

@@ -19,6 +19,7 @@ 

  Source1:       %{name}-README.Fedora

  Source2:       %{name}-script.pa

  Source3:       %{name}-limits.conf

+ Source4:       force_python3

  # No-date-footer hack to remove dates from doxygen documentation

  Patch0:        jack2-1.9.12-nodate.patch

  # Build fix

@@ -29,8 +30,6 @@ 

  Patch3:        jack-realtime-compat.patch

  # Remove binary junk from README

  Patch4:        jack2-1.9.12-nojunk.patch

- # Proper Python2 shebangs

- Patch5:        jack2-1.9.12-python-shebang.patch

  

  

  BuildRequires: alsa-lib-devel

@@ -48,7 +47,7 @@ 

  BuildRequires: ncurses-devel

  BuildRequires: opus-devel

  BuildRequires: pkgconfig

- BuildRequires: python2

+ BuildRequires: python3

  BuildRequires: readline-devel

  

  Requires(pre): shadow-utils

@@ -96,12 +95,17 @@ 

  %patch2 -p1 -b .nointernalapi

  %patch3 -p1 -b .priority

  %patch4 -p1 -b .nojunk

- %patch5 -p1 -b .shebang

  

  %build

  export CPPFLAGS="$RPM_OPT_FLAGS"

  export LDFLAGS="$RPM_LD_FLAGS"

  export PREFIX=%{_prefix}

+ 

+ # force python3 during build process

+ /usr/bin/bash %{SOURCE4}

+ # correct unintended runtime error caused by StopIteration in python3

+ sed -i 's/raise StopIteration/return/' ./waflib/Node.py

+ 

  ./waf configure \

     %{?_smp_mflags} \

     --mandir=%{_mandir}/man1 \

@@ -244,6 +248,9 @@ 

  

  

  %changelog

+ * Sat Jul 20 2019 Ralf Senderek <innovation@senderek.ie> - 1.9.12.9

+ - Force python3 during build process

+ 

  * Sun Feb 17 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 1.9.12-8

  - Rebuild for readline 8.0

  

This pull request switches to python3 during the build process. Fortunately upstream have already made sure, that the python scripts can be executed correctly with python3 (with one exception, see below) which is the right thing to do if you want to distribute your code to different OSes.

As we can expect upstream to stick to the "#!/usr/bin/env python" line and let the OS decide which python to use, in Fedora we have to switch the first line in every python script to /usr/bin/python3, which is what the additional script "force_python3" does.

The only line of code that is incompatible with python3 is line 540 in waflib/Node.py. Here the recursive function is terminated with a "raise StopIteration" exception, that works fine under python2, but causes a runtime error in python3 which is not intended here. Since Python 3.5 the StopIteration exception
is transformed into a RuntimeError (PEP479), so in order to terminate the recursive function it can safely be replaced with an ordinary return statement.