python: Fix creating RPMs from Python packages

This should enable (manual) building of RPMs from python projects using
the `python setup.py bdist_rpm` command on systems where `rpmbuild` is
not located in `/usr/bin/`. (e.g. NixOS)
The discovery of the rpmbuild command was fixed upstream in Python 3.8,
so this commit backports the relevant patch to our currently supported
Python 3 versions.

Fixes: #85204

authored by Josef Kemetmüller and committed by Frederik Rietdijk 3818cd90 603ce3e2

Changed files
+34
pkgs
development
+30
pkgs/development/interpreters/python/cpython/3.7/fix-hardcoded-path-checking-for-rpmbuild.patch
···
··· 1 + From a612c481f6116955d420db5ae1fe4c1eb93eb2f2 Mon Sep 17 00:00:00 2001 2 + From: Marcin Niemira <marcin.niemira@gmail.com> 3 + Date: Sun, 9 Jun 2019 07:05:06 +1000 4 + Subject: [PATCH] bpo-11122: fix hardcoded path checking for rpmbuild in 5 + bdist_rpm.py (GH-10594) (cherry picked from commit 6 + 45a14942c969ed508b35abd5e116cb18f84ce5b4) 7 + 8 + Co-authored-by: Marcin Niemira <marcin.niemira@gmail.com> 9 + --- 10 + Lib/distutils/command/bdist_rpm.py | 5 +---- 11 + .../next/Library/2018-11-12-19-08-50.bpo-11122.Gj7BQn.rst | 1 + 12 + 2 files changed, 2 insertions(+), 4 deletions(-) 13 + create mode 100644 Misc/NEWS.d/next/Library/2018-11-12-19-08-50.bpo-11122.Gj7BQn.rst 14 + 15 + diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py 16 + index 20ca7ac6dcffa..74381cc69a6ce 100644 17 + --- a/Lib/distutils/command/bdist_rpm.py 18 + +++ b/Lib/distutils/command/bdist_rpm.py 19 + @@ -309,10 +309,7 @@ def run(self): 20 + 21 + # build package 22 + log.info("building RPMs") 23 + - rpm_cmd = ['rpm'] 24 + - if os.path.exists('/usr/bin/rpmbuild') or \ 25 + - os.path.exists('/bin/rpmbuild'): 26 + - rpm_cmd = ['rpmbuild'] 27 + + rpm_cmd = ['rpmbuild'] 28 + 29 + if self.source_only: # what kind of RPMs? 30 + rpm_cmd.append('-bs')
+4
pkgs/development/interpreters/python/cpython/default.nix
··· 103 ] ++ optionals isPy35 [ 104 # Backports support for LD_LIBRARY_PATH from 3.6 105 ./3.5/ld_library_path.patch 106 ] ++ optionals (isPy37 || isPy38) [ 107 # Fix darwin build https://bugs.python.org/issue34027 108 ./3.7/darwin-libutil.patch
··· 103 ] ++ optionals isPy35 [ 104 # Backports support for LD_LIBRARY_PATH from 3.6 105 ./3.5/ld_library_path.patch 106 + ] ++ optionals (isPy35 || isPy36 || isPy37) [ 107 + # Backport a fix for discovering `rpmbuild` command when doing `python setup.py bdist_rpm` to 3.5, 3.6, 3.7. 108 + # See: https://bugs.python.org/issue11122 109 + ./3.7/fix-hardcoded-path-checking-for-rpmbuild.patch 110 ] ++ optionals (isPy37 || isPy38) [ 111 # Fix darwin build https://bugs.python.org/issue34027 112 ./3.7/darwin-libutil.patch