Fix handling of Python wheels by pythondistdeps.py --provides (#1421776)

This commit is contained in:
Tomas Orsava 2017-02-16 11:31:33 +01:00
parent d2ed0e9c50
commit cef3bf8220
2 changed files with 50 additions and 1 deletions

View File

@ -0,0 +1,43 @@
From ff395f4a820497a443baa6cd0198c49b06207c3f Mon Sep 17 00:00:00 2001
From: Tomas Orsava <torsava@redhat.com>
Date: Thu, 16 Feb 2017 11:36:29 +0100
Subject: [PATCH] Fix pythondistdeps.py --provides for Python wheels
As Python wheels do not contain targetted Python version in the directory/file
name of their metadata like Python eggs do, and since the Python version is not
contained in the metadata either, it is necessary to get it from elsewhere.
Here it is parsed from the path the metadata resides at
(e.g. /usr/lib/pythonX.Y/site-packages/...)
---
scripts/pythondistdeps.py | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/scripts/pythondistdeps.py b/scripts/pythondistdeps.py
index e4b99e2..d44210c 100644
--- a/scripts/pythondistdeps.py
+++ b/scripts/pythondistdeps.py
@@ -107,10 +107,17 @@ for f in files:
path_item = f
metadata = FileMetadata(f)
dist = Distribution.from_location(path_item, dist_name, metadata)
- # Check if py_version is defined in the file
+ # Check if py_version is defined in the metadata file/directory name
if not dist.py_version:
- warn("Version for {!r} has not been found".format(dist), RuntimeWarning)
- continue
+ # Try to parse the Python version from the path the metadata
+ # resides at (e.g. /usr/lib/pythonX.Y/site-packages/...)
+ import re
+ res = re.search(r"/python(?P<pyver>\d+\.\d)/", path_item)
+ if res:
+ dist.py_version = res.group('pyver')
+ else:
+ warn("Version for {!r} has not been found".format(dist), RuntimeWarning)
+ continue
if (Provides_PyMajorVer_Variant or legacy_Provides or legacy) and Provides:
# Get the Python major version
pyver_major = dist.py_version.split('.')[0]
--
2.11.0

View File

@ -29,7 +29,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
Release: %{?snapver:0.%{snapver}.}1%{?dist}
Release: %{?snapver:0.%{snapver}.}2%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2
@ -61,6 +61,9 @@ Patch137: rpm-4.13.x-pythondistdeps.py-show-warning-if-version-is-not-fou.patch
Patch138: rpm-4.13.x-pythondistdeps.py-skip-.egg-link-files.patch
Patch139: rpm-4.13.x-pythondistdeps.py-add-forgotten-import.patch
Patch140: rpm-4.13.x-brp-python-bytecompile-Python3-only.patch
# Upstream PR: https://github.com/rpm-software-management/rpm/pull/154
# rhbz#1421776
Patch141: rpm-4.13.x-pythondistdeps.py-fix-processing-wheels.patch
# Fedora-specific (python3) patch (RHBZ #1405483)
Patch200: rpm-4.13.x-pythondistdeps-python3.patch
@ -566,6 +569,9 @@ exit 0
%doc doc/librpm/html/*
%changelog
* Thu Feb 16 2017 Tomas Orsava <torsava@redhat.com> - 4.13.0.1-2
- Fix handling of Python wheels by pythondistdeps.py --provides (#1421776)
* Thu Feb 16 2017 Panu Matilainen <pmatilai@redhat.com> - 4.13.0.1-1
- Update to 4.13.0.1 ((http://rpm.org/wiki/Releases/4.13.0)