Bug 1369486

Summary: %python2_version{,_nodots} macros fail when evaluated on Python 2.6 in EPEL-6
Product: [Fedora] Fedora EPEL Reporter: Tomas Orsava <torsava>
Component: python-rpm-macrosAssignee: Jason Tibbitts <j>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: el6CC: cstratak, j, orion, python-sig, TicoTimo, torsava
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-rpm-macros-3-11.el6 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-03 00:49:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tomas Orsava 2016-08-23 14:21:26 UTC
Description of problem:
Macro %python2_version and it's little brother %python2_version_nodots evaluate to Python code that crashes on Python 2.6 that is included in EPEL-6.

Version-Release number of selected component (if applicable):
python-rpm-macros-3-6.el6.1

How reproducible:
Every time

Steps to Reproduce:
1. rpm -E "%python2_version"

Actual results:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'tuple' object has no attribute 'major'

Expected results:
2.6

Additional info:

Suggested fix: Use the older definition of %python2_version:
%python_version %(%{__python2} -c "import sys; sys.stdout.write(sys.version[:3])")

And an appropriate adjustment for _nodots.

Comment 1 Jason Tibbitts 2016-08-23 17:08:10 UTC
Well, crap, someone asked for those.  (They haven't been in EL6 before.)  I added them with the caveat that they test them.  They said they were OK, so I pushed them.

I'll fix them up.  Will you promise to test for me?

Comment 2 Tomas Orsava 2016-08-23 17:12:28 UTC
Yeah, no problem!

Comment 3 Jason Tibbitts 2016-08-23 17:38:12 UTC
So, uh, I'm confusing this with the python macros I added to EPEL5.  There have been python macros in epel-rpm-macros-6 for quite some time.  I will remove those, but.. I'll not touch these.

Comment 4 Tomas Orsava 2016-08-24 10:47:32 UTC
If the python macros (with a working definition of %python2_version) are removed from epel-rpm-macros-6, it is imperative that this bug gets fixed or builds will start failing due to it as spec files start to rely on the %python2_version defined in this package python-rpm-macros.

If nobody else prefers to do it, I volunteer.

Comment 5 Jason Tibbitts 2016-08-24 12:55:52 UTC
I'm actually working on them now.

But currently I see that even on el6 python3-rpm-macros exist, which makes absolutely no sense as they can't possibly work.  Of course, I would just have a completely separate spec file for the el6 package since it's so different, but I'm not sure that Orion would like that since he likes to keep one spec for everything.  So I'll wait to talk to him first; maybe he wants to have el6 versions of the macros checked in as separate files and ifdefs in the spec.  

Personally I just have different versions of the same files checked in on different branches but....

Anyway, I'll try to catch Orion on IRC.

Comment 6 Tomas Orsava 2016-08-24 13:24:25 UTC
Roger, I'll leave it up to your capable hands.

Here's my suggestion for the two failing macros:
%python2_version %(%{__python2} -c "import sys; sys.stdout.write(sys.version[:3])")
%python2_version_nodots %(%{__python2} -c "import sys; sys.stdout.write(sys.version[:3:2])")

Tested to work on RHEL-6.

Comment 7 Orion Poplawski 2016-08-24 16:06:47 UTC
I'm fine with the el6 branch diverging for python-rpm-macros.  There are already significant differences on the different branchs.

I'm not sure it's worth worrying about the python-3-rpm-macros sub-package.  Nothing should require it.  And if anyone were crazy enough to build python34 for EPEL6 they would be there (I just tried that and I think it will build with some tweaks).

Comment 8 Jason Tibbitts 2016-08-24 18:57:07 UTC
OK.  Given that I was adding the nil defines, I figured I needed to put them somewhere.  If python3 does make it to el6, we can always just remove them and maintainers will have less work to do.

Comment 9 Tomas Orsava 2016-09-12 10:26:43 UTC
Hi, can I ask what's the status on this bug?

Comment 10 Jason Tibbitts 2016-09-15 13:54:58 UTC
I add it to my list every day but never manage to make it down that far.

The hitch is that for some reason the the python macros package spits out a python3 subpackage, which doesn't (currently) have any use.  If I removed the subpackage I'd have to obsolete it and, well, I don't know if it's of any use to anyone.

But I still want to nil out those python 3 stubs.

I think the plan is:

Fix the python macros package with your fixes.

Remove all python macros from epel-rpm-macros _except_ the two python 3 stubs that are there.

Add a dependency on the python2 macros to epel-rpm-macros so that the python macros are (still) always present.

I'm going to promise to get this done today.  If there's an issue with that plan, I can just unpush the update.

Comment 11 Tomas Orsava 2016-09-15 15:18:50 UTC
Wouldn't it be best to put the Python 3 stubs into the python3-rpm-macros subpackage? In that case you don't have to remove and obsolete it.

Then I you can make epel-rpm-macros depend on all the four python-rpm-macros subpackages (python-rpm-macros, python2-rpm-macros, python3-rpm-macros, python-srpm-macros).

Having two Python 3 stubs in epel-rpm-macros, and the rest of Python macros in python-rpm-macros seems inconsistent and hard to find.

Comment 12 Tomas Orsava 2016-09-15 15:20:15 UTC
P.S. If you want, I can push the changes to python-rpm-macros myself, and prepare a patch you can push to epel-rpm-macros, so you can do more important/pressing things.

Comment 13 Jason Tibbitts 2016-09-15 15:48:54 UTC
The thing is, I don't know what that python3 package is used for or why it has ever been generated.  I could remove the macros from it completely, I guess.  Is there any point at all in having them there?  If someone does try to do python3 in el6 then I'm sure they can come back.

Comment 14 Tomas Orsava 2016-09-15 16:56:44 UTC
I believe it was there because the EPEL-6 and EPEL-7 branches were merged, likely by mistake. I think you can safely remove the content of the python3 macro file and put the two stubs there.

Comment 15 Orion Poplawski 2016-09-15 17:26:40 UTC
Yeah, it just got merged down there.  Personally I don't see the harm of just leaving it there - nothing requires it (I said as much in comment #7). Leave the stubs in epel-rpm-macros because that provides compatibility and always needs to be there.

Comment 16 Jason Tibbitts 2016-09-15 20:43:05 UTC
Yeah, I completely lost the context, sorry.

Now, for a really fun thing, the python macros packages place the macros in /usr/lib/rpm/macros.d.  Which is a directory that isn't provided by any package, and I don't believe is even used by the version of RPM on EL6.  %rpmmacrodir should the correct thing on all releases.

So I've fixed that all up and brought over a fix for the issue with Amazon Linux (https://bugzilla.redhat.com/show_bug.cgi?id=1347019).  Bodhi will spam this bug shortly.

Comment 17 Fedora Update System 2016-09-15 22:09:00 UTC
epel-rpm-macros-6-13 python-rpm-macros-3-11.el6 has been submitted as an update to Fedora EPEL 6. https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-d59560b5a8

Comment 18 Fedora Update System 2016-09-16 23:47:21 UTC
epel-rpm-macros-6-13, python-rpm-macros-3-11.el6 has been pushed to the Fedora EPEL 6 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-d59560b5a8

Comment 19 Tim Orling 2016-10-01 19:01:12 UTC
Just because I felt like it, I created a Docker container to test this:

git clone http://ttorling.fedorapeople.org/git/epel6-testing-container.git/

Comment 20 Fedora Update System 2016-10-03 00:49:37 UTC
epel-rpm-macros-6-13, python-rpm-macros-3-11.el6 has been pushed to the Fedora EPEL 6 stable repository. If problems still persist, please make note of it in this bug report.