From 7cf326913fbbe9d52953342f1e9062f2cb0b3271 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Mon, 22 Aug 2016 16:12:03 +0200 Subject: [PATCH] Backport fixes to ignore .egg-link files in Python dependency generator Signed-off-by: Igor Gnatenko --- ...y-show-warning-if-version-is-not-fou.patch | 29 +++++++++++ ...thondistdeps.py-skip-.egg-link-files.patch | 50 +++++++++++++++++++ ...y-skip-distribution-metadata-if-ther.patch | 44 ++++++++++++++++ rpm.spec | 10 +++- 4 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 rpm-4.13.x-pythondistdeps.py-show-warning-if-version-is-not-fou.patch create mode 100644 rpm-4.13.x-pythondistdeps.py-skip-.egg-link-files.patch create mode 100644 rpm-4.13.x-pythondistdeps.py-skip-distribution-metadata-if-ther.patch diff --git a/rpm-4.13.x-pythondistdeps.py-show-warning-if-version-is-not-fou.patch b/rpm-4.13.x-pythondistdeps.py-show-warning-if-version-is-not-fou.patch new file mode 100644 index 0000000..0db2977 --- /dev/null +++ b/rpm-4.13.x-pythondistdeps.py-show-warning-if-version-is-not-fou.patch @@ -0,0 +1,29 @@ +From 2f51022e1586a9b3ac8036b23995074b00910475 Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Mon, 22 Aug 2016 12:55:50 +0200 +Subject: [PATCH 2/3] pythondistdeps.py: show warning if version is not found + in metadata + +In 49197c930bb6090d0fca4089ea75ec9d10e62f99 we introduced skipping +metadata which has no version, but it's better to show some warning. + +Signed-off-by: Igor Gnatenko +--- + scripts/pythondistdeps.py | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/scripts/pythondistdeps.py b/scripts/pythondistdeps.py +index 54905c3..d7226e0 100755 +--- a/scripts/pythondistdeps.py ++++ b/scripts/pythondistdeps.py +@@ -110,6 +110,7 @@ for f in files: + dist = Distribution.from_location(path_item, dist_name, metadata) + # Check if py_version is defined in the file + if not dist.py_version: ++ warnings.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 +-- +2.9.3 + diff --git a/rpm-4.13.x-pythondistdeps.py-skip-.egg-link-files.patch b/rpm-4.13.x-pythondistdeps.py-skip-.egg-link-files.patch new file mode 100644 index 0000000..a555ed5 --- /dev/null +++ b/rpm-4.13.x-pythondistdeps.py-skip-.egg-link-files.patch @@ -0,0 +1,50 @@ +From 83e4d44b802d39dfbd407488c0d9f629799b809c Mon Sep 17 00:00:00 2001 +From: Igor Gnatenko +Date: Mon, 22 Aug 2016 12:56:05 +0200 +Subject: [PATCH 3/3] pythondistdeps.py: skip .egg-link files + +From setuptools's documentation: +These files are not eggs, strictly speaking. They simply provide a way +to reference an egg that is not physically installed in the desired +location. They exist primarily as a cross-platform alternative to +symbolic links, to support "installing" code that is being developed in +a different location than the desired installation location. + +If we read .egg-link using pkg_resources.Distribution it will +never have version as it is just list of directories which should be +taken into account. + +We could change into that directories and add eggs from those locations +for parsing, but RPM's dependency generator already passing all files +from built RPM so it just does not make any sense to traverse those +directories. + +After all written above, let's just ignore .egg-link files. + +Signed-off-by: Igor Gnatenko +--- + scripts/pythondistdeps.py | 2 -- + 1 file changed, 2 deletions(-) + +diff --git a/scripts/pythondistdeps.py b/scripts/pythondistdeps.py +index d7226e0..76017f3 100755 +--- a/scripts/pythondistdeps.py ++++ b/scripts/pythondistdeps.py +@@ -89,14 +89,12 @@ for f in files: + lower_dir = dirname(lower) + if lower_dir.endswith('.egg') or \ + lower_dir.endswith('.egg-info') or \ +- lower_dir.endswith('.egg-link') or \ + lower_dir.endswith('.dist-info'): + lower = lower_dir + f = dirname(f) + # Determine provide, requires, conflicts & recommends based on egg/dist metadata + if lower.endswith('.egg') or \ + lower.endswith('.egg-info') or \ +- lower.endswith('.egg-link') or \ + lower.endswith('.dist-info'): + # This import is very slow, so only do it if needed + from pkg_resources import Distribution, FileMetadata, PathMetadata +-- +2.9.3 + diff --git a/rpm-4.13.x-pythondistdeps.py-skip-distribution-metadata-if-ther.patch b/rpm-4.13.x-pythondistdeps.py-skip-distribution-metadata-if-ther.patch new file mode 100644 index 0000000..4279f9c --- /dev/null +++ b/rpm-4.13.x-pythondistdeps.py-skip-distribution-metadata-if-ther.patch @@ -0,0 +1,44 @@ +From 49197c930bb6090d0fca4089ea75ec9d10e62f99 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Neal=20Gompa=20=28=E3=83=8B=E3=83=BC=E3=83=AB=E3=83=BB?= + =?UTF-8?q?=E3=82=B3=E3=82=99=E3=83=B3=E3=83=8F=E3=82=9A=29?= + +Date: Sat, 20 Aug 2016 11:01:06 -0400 +Subject: [PATCH 1/3] pythondistdeps.py: skip distribution metadata if there is + no version + +For example, reading .egg-link using pkg_resources.Distribution returns +actual metadata, but it does not contain version. It returns traceback like: + +File "/usr/lib/rpm/pythondistdeps.py", line 113, in + pyver_major = dist.py_version.split('.')[0] +AttributeError: 'NoneType' object has no attribute 'split' +Traceback (most recent call last): + File "/usr/lib/rpm/pythondistdeps.py", line 113, in + pyver_major = dist.py_version.split('.')[0] +AttributeError: 'NoneType' object has no attribute 'split' + +Let's just skip such errors as we can't do much about that. + +Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1368673 +Reported-and-tested-by: Igor Gnatenko +--- + scripts/pythondistdeps.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/scripts/pythondistdeps.py b/scripts/pythondistdeps.py +index 8a2f43d..54905c3 100755 +--- a/scripts/pythondistdeps.py ++++ b/scripts/pythondistdeps.py +@@ -108,6 +108,9 @@ 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 ++ if not dist.py_version: ++ 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.9.3 + diff --git a/rpm.spec b/rpm.spec index 6d2ff2b..c79481b 100644 --- a/rpm.spec +++ b/rpm.spec @@ -29,7 +29,7 @@ Summary: The RPM package management system Name: rpm Version: %{rpmver} -Release: %{?snapver:0.%{snapver}.}42%{?dist} +Release: %{?snapver:0.%{snapver}.}43%{?dist} Group: System Environment/Base Url: http://www.rpm.org/ Source0: http://rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2 @@ -88,6 +88,9 @@ Patch132: rpm-4.13.0-_buildhost-macro.diff Patch133: rpm-4.13.x-pythondistdeps.patch Patch134: rpm-4.13.x-pythondistdeps-Makefile.patch Patch135: rpm-4.13.x-pythondistdeps-fileattr.patch +Patch136: rpm-4.13.x-pythondistdeps.py-skip-distribution-metadata-if-ther.patch +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 # These are not yet upstream Patch302: rpm-4.7.1-geode-i686.patch @@ -594,7 +597,10 @@ exit 0 %doc doc/librpm/html/* %changelog -* Fri Aug 12 2016 Florian Festi - 4.4.13.0-0.rc1.42 +* Mon Aug 22 2016 Igor Gnatenko - 4.13.0-0.rc1.43 +- Backport fixes to ignore .egg-link files in Python dependency generator + +* Fri Aug 12 2016 Florian Festi - 4.13.0-0.rc1.42 - Enable --majorver-provides in Python dependency generator * Tue Aug 09 2016 Igor Gnatenko - 4.13.0-0.rc1.41