Bug 1254728 - Passing arguments to %py*_compile and friends
Passing arguments to %py*_compile and friends
Product: Fedora
Classification: Fedora
Component: python (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Charalampos Stratakis
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2015-08-18 13:43 EDT by Thomas Spura
Modified: 2017-10-31 11:15 EDT (History)
13 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2017-10-31 11:15:42 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Thomas Spura 2015-08-18 13:43:34 EDT
The following bug report was entered into the track of fpc:

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 13:53:02 EDT
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 10:24:39 EDT
(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 10:40:15 EDT
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 09:38:37 EST
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 08:04:45 EST
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 08:38:48 EST
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:
Comment 7 Fedora End Of Life 2017-07-25 15:10:44 EDT
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 04:13:50 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 27 development cycle.
Changing version to '27'.
Comment 9 Petr Viktorin 2017-10-31 11:15:42 EDT
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!

Note You need to log in before you can comment on or make changes to this bug.