Bug 1254728

Summary: Passing arguments to %py*_compile and friends
Product: [Fedora] Fedora Reporter: Thomas Spura <tomspur>
Component: pythonAssignee: Charalampos Stratakis <cstratak>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 27CC: bkabrda, carl, dmalcolm, ivazqueznet, jberan, jonathansteffan, jorti, makowski.fedora, ncoghlan, pviktori, redhat-bugzilla, tomspur, tradej, ville.skytta
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-10-31 15:15:42 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 Thomas Spura 2015-08-18 17:43:34 UTC
The following bug report was entered into the track of fpc:
https://fedorahosted.org/fpc/ticket/557

From Ville Skyttä:
> I have a package (python-libdiscid) in which I'd like to be able to pass additional arguments to %py2_build. But the way it's currently defined practically prevents me from doing that.
> 
> The additional arguments are "build_ext -i build_sphinx"
> 
> First, the "()" after %py2_build in its definition make it error out because it thinks the -i above is an arg for the macro function, and looks like the macro is designed to take only one argument in the first place, not sure why. Second, after removing the parens and the %{?1}, the multiline style %expand definition breaks things because all the additional arguments end up on the next line.
> 
> So I suggest defining the macro simply as:
> 
> {{{
> %py2_build %{expand:CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}"}
> }}}
> 
> All on one line. This would fix my use case, I could just call %py2_build build_ext -i build_sphinx.
> 
> And actually, I'm not sure what the %{expand:...} is there for -- if it doesn't have a purpose, maybe it should be removed while at it.
> 
> In addition to %py2_build, the %py2_install, %py3_build, and %py3_install macros are similarly affected.

Comment 1 Thomas Spura 2015-08-18 17:53:02 UTC
In addition to the additional arguments, it is necessary to build in a defined build directory, see bug #1251464.

This seems to be working for the py_build macro:
%py2_build %{expand:CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} build --executable="%{__python2} %{py2_shbang_opts}" --build-lib=build/lib.%{_os}-%{_target_cpu}-%{python2_version}}

But as the install command doesn't understand --build-lib one would need something like this to work around that:
%py2_install %{expand:
CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install_lib -O1 --skip-build --root %{buildroot} --build-lib=build/lib.%{_os}-%{_target_cpu}-%{python2_version} \
CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install_headers -O1 --skip-build --root %{buildroot} --build-lib=build/lib.%{_os}-%{_target_cpu}-%{python2_version} \
CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install_scripts -O1 --skip-build --root %{buildroot} --build-lib=build/lib.%{_os}-%{_target_cpu}-%{python2_version} \
CFLAGS="%{optflags}" %{__python2} %{py_setup} %{?py_setup_args} install_data -O1 --skip-build --root %{buildroot} --build-lib=build/lib.%{_os}-%{_target_cpu}-%{python2_version} \
}

Do you also need additional arguments to the install command? Would the above work for you?

I don't know if the %expand can be removed.

Comment 2 Ville Skyttä 2015-09-16 14:24:39 UTC
(In reply to Thomas Spura from comment #1)

Not sure if these were questions to me, but I'll answer anyway.

> Do you also need additional arguments to the install command?

I haven't come across anything where I'd need it. But I see no reason to disallow them either.

> Would the above work for you?

Haven't tested, not sure if it applies to python-libdiscid -- it builds fine with just my proposed change as far as I can tell.

> I don't know if the %expand can be removed.

I *guess* it's there in order to have the macro expand only once per build, a micro-optimization for which I fail to see a reason as the macro is used only once anyway and it doesn't contain any shell execs or the like that would make it slow or anything.

Comment 3 Juan Orti 2015-09-16 14:40:15 UTC
I had to use a macro [1] to pass the arguments, because writing the arguments directly after %py3_install didn't work

This doesn't work:
%py3_install --my-parameter

This works:
%py3_install "--my-parameter"

This works:
%global my_parameters --my-parameter
%py3_install %my_parameters

[1] http://pkgs.fedoraproject.org/cgit/rhythmbox-ampache.git/tree/rhythmbox-ampache.spec#n30

Comment 4 Rémi Verschelde 2015-11-23 14:38:37 UTC
We're also having the same issue at Mageia's, and more than patching it ourselves we'd prefer to see a fix added upstream.

See this example for a use case where parsing %py3_install parameters would not work and had to be worked around as shown in comment 3: http://svnweb.mageia.org/packages/cauldron/auale/current/SPECS/auale.spec?r1=905081&r2=905080&pathrev=905081

Comment 5 Fedora Admin XMLRPC Client 2016-01-29 13:04:45 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 6 Jan Kurik 2016-02-24 13:38:48 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 24 development cycle.
Changing version to '24'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora24#Rawhide_Rebase

Comment 7 Fedora End Of Life 2017-07-25 19:10:44 UTC
This message is a reminder that Fedora 24 is nearing its end of life.
Approximately 2 (two) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 24. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '24'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 24 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 8 Jan Kurik 2017-08-15 08:13:50 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.

Comment 9 Petr Viktorin (pviktori) 2017-10-31 15:15:42 UTC
Sorry for everything being so quiet here; the issue fell through the cracks

%py2_build/%py2_install have been in the wild for some time already, and from the lack of updates here I gather that the shortcomings can be worked around (for the advanced use cases that need them).

I'm going to close this issue, but if you want us to take another look at it, please do reopen!