about summary refs log tree commit diff
path: root/pkgs/development/interpreters/python/cpython
diff options
context:
space:
mode:
authorJosef Kemetmüller <josef.kemetmueller@gmail.com>2020-04-14 13:50:11 +0200
committerFrederik Rietdijk <fridh@fridh.nl>2020-05-09 11:15:28 +0200
commit3818cd9049677c9fdc8fac07d12927bd92cb61ba (patch)
tree5ab78b0841277d982e0c57b2c6bb60eb1bb33e6b /pkgs/development/interpreters/python/cpython
parent603ce3e2599a66d3ce5266a1e7552a82d457d6fe (diff)
downloadnixlib-3818cd9049677c9fdc8fac07d12927bd92cb61ba.tar
nixlib-3818cd9049677c9fdc8fac07d12927bd92cb61ba.tar.gz
nixlib-3818cd9049677c9fdc8fac07d12927bd92cb61ba.tar.bz2
nixlib-3818cd9049677c9fdc8fac07d12927bd92cb61ba.tar.lz
nixlib-3818cd9049677c9fdc8fac07d12927bd92cb61ba.tar.xz
nixlib-3818cd9049677c9fdc8fac07d12927bd92cb61ba.tar.zst
nixlib-3818cd9049677c9fdc8fac07d12927bd92cb61ba.zip
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
Diffstat (limited to 'pkgs/development/interpreters/python/cpython')
-rw-r--r--pkgs/development/interpreters/python/cpython/3.7/fix-hardcoded-path-checking-for-rpmbuild.patch30
-rw-r--r--pkgs/development/interpreters/python/cpython/default.nix4
2 files changed, 34 insertions, 0 deletions
diff --git a/pkgs/development/interpreters/python/cpython/3.7/fix-hardcoded-path-checking-for-rpmbuild.patch b/pkgs/development/interpreters/python/cpython/3.7/fix-hardcoded-path-checking-for-rpmbuild.patch
new file mode 100644
index 000000000000..bb3d992612d3
--- /dev/null
+++ b/pkgs/development/interpreters/python/cpython/3.7/fix-hardcoded-path-checking-for-rpmbuild.patch
@@ -0,0 +1,30 @@
+From a612c481f6116955d420db5ae1fe4c1eb93eb2f2 Mon Sep 17 00:00:00 2001
+From: Marcin Niemira <marcin.niemira@gmail.com>
+Date: Sun, 9 Jun 2019 07:05:06 +1000
+Subject: [PATCH] bpo-11122: fix hardcoded path checking for rpmbuild in
+ bdist_rpm.py (GH-10594) (cherry picked from commit
+ 45a14942c969ed508b35abd5e116cb18f84ce5b4)
+
+Co-authored-by: Marcin Niemira <marcin.niemira@gmail.com>
+---
+ Lib/distutils/command/bdist_rpm.py                           | 5 +----
+ .../next/Library/2018-11-12-19-08-50.bpo-11122.Gj7BQn.rst    | 1 +
+ 2 files changed, 2 insertions(+), 4 deletions(-)
+ create mode 100644 Misc/NEWS.d/next/Library/2018-11-12-19-08-50.bpo-11122.Gj7BQn.rst
+
+diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
+index 20ca7ac6dcffa..74381cc69a6ce 100644
+--- a/Lib/distutils/command/bdist_rpm.py
++++ b/Lib/distutils/command/bdist_rpm.py
+@@ -309,10 +309,7 @@ def run(self):
+ 
+         # build package
+         log.info("building RPMs")
+-        rpm_cmd = ['rpm']
+-        if os.path.exists('/usr/bin/rpmbuild') or \
+-           os.path.exists('/bin/rpmbuild'):
+-            rpm_cmd = ['rpmbuild']
++        rpm_cmd = ['rpmbuild']
+ 
+         if self.source_only: # what kind of RPMs?
+             rpm_cmd.append('-bs')
diff --git a/pkgs/development/interpreters/python/cpython/default.nix b/pkgs/development/interpreters/python/cpython/default.nix
index 43d635f3a33a..3ad4021d6dfe 100644
--- a/pkgs/development/interpreters/python/cpython/default.nix
+++ b/pkgs/development/interpreters/python/cpython/default.nix
@@ -103,6 +103,10 @@ in with passthru; stdenv.mkDerivation {
   ] ++ optionals isPy35 [
     # Backports support for LD_LIBRARY_PATH from 3.6
     ./3.5/ld_library_path.patch
+  ] ++ optionals (isPy35 || isPy36 || isPy37) [
+    # Backport a fix for discovering `rpmbuild` command when doing `python setup.py bdist_rpm` to 3.5, 3.6, 3.7.
+    # See: https://bugs.python.org/issue11122
+    ./3.7/fix-hardcoded-path-checking-for-rpmbuild.patch
   ] ++ optionals (isPy37 || isPy38) [
     # Fix darwin build https://bugs.python.org/issue34027
     ./3.7/darwin-libutil.patch