Creating meta-packages for python2/3 from a single spec

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating meta-packages for python2/3 from a single spec

John Paul Adrian Glaubitz
Hi!

I am in the situation where I need to build two meta-packages from a single spec file,
one being named python2-$UPSTREAMNAME and the other being named python3-$UPSTREAMNAME.
These packages are supposed to pull the same set of packages, with the only difference
that python2-$UPSTREAMNAME pulls in the python2- packages while python3-$UPSTREAMNAME
pulls in the python3- packages.

The python2- and python3- binary packages are also created from a single spec file,
one example is python-azure-batch which can be found in [1]. In this spec file,
I'm using %python_subpackages from python-rpm-macros to generate the python2- and
python3- binary packages.

I tried using this technique for the meta-package as well. However, that didn't work
because python-rpm-macros expects a setup.py to be present which, of course, I don't
have in an effectively empty package.

So, I am wondering whether anyone has a clever idea how to solve this issue. I would
know how to do it for a Debian package, but my RPM background is not yet proficient
enough to come up with a solution for RPM :).

Thanks,
Adrian

> [1] https://build.opensuse.org/package/show/devel:languages:python/python-azure-batch
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Creating meta-packages for python2/3 from a single spec

jan matejek-4
hello,

On 18.8.2017 17:11, John Paul Adrian Glaubitz wrote:
> I tried using this technique for the meta-package as well. However, that didn't work
> because python-rpm-macros expects a setup.py to be present which, of course, I don't> have in an effectively empty package.

no, python-rpm-macros don't expect setup.py, they don't ever touch it unless you use %python_build

what error are you seeing? what you are trying to do looks valid and should work with singlespec
as is.

regards
m.


signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Creating meta-packages for python2/3 from a single spec

John Paul Adrian Glaubitz
Hi Jan!

On 08/21/2017 01:02 PM, jan matejek wrote:
> On 18.8.2017 17:11, John Paul Adrian Glaubitz wrote:
>> I tried using this technique for the meta-package as well. However, that didn't work
>> because python-rpm-macros expects a setup.py to be present which, of course, I don't> have in an effectively empty package.
>
> no, python-rpm-macros don't expect setup.py, they don't ever touch it unless you use %python_build

That's odd. I basically took the current version of my package [1], commented
out the Source directives and the %python_build directives and it fails with:

> what error are you seeing? what you are trying to do looks valid and should work with singlespec
> as is.

[   19s] + /usr/bin/python2 setup.py build '--executable=/usr/bin/python2 -s'
[   19s] /usr/bin/python2: can't open file 'setup.py': [Errno 2] No such file or directory
[   19s] error: Bad exit status from /var/tmp/rpm-tmp.f17BNP (%build)

I'm attaching a diff with the changes I made, then ran "osc build".

Adrian

> [1] https://build.opensuse.org/package/show/Cloud:Tools:azuresdkbreak/python-azure-sdk

python-azure-sdk-meta.diff (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Creating meta-packages for python2/3 from a single spec

jan matejek-5


On 21.8.2017 15:38, John Paul Adrian Glaubitz wrote:
> That's odd. I basically took the current version of my package [1], commented
> out the Source directives and the %python_build directives and it fails with:

rpm macros expand even in comments -- macros have higher priority than comments
%python_build expansions is multiline
so if you write #%python_build, you comment out its first line and get all the rest

you need to either delete the macro entirely, or escape it with an additional % sign:
#%%python_build

(you might get interesting results with the commented out %files section as well)

hope this helps
m.

>
>> what error are you seeing? what you are trying to do looks valid and should work with singlespec
>> as is.
>
> [   19s] + /usr/bin/python2 setup.py build '--executable=/usr/bin/python2 -s'
> [   19s] /usr/bin/python2: can't open file 'setup.py': [Errno 2] No such file or directory
> [   19s] error: Bad exit status from /var/tmp/rpm-tmp.f17BNP (%build)
>
> I'm attaching a diff with the changes I made, then ran "osc build".
>
> Adrian
>
>> [1] https://build.opensuse.org/package/show/Cloud:Tools:azuresdkbreak/python-azure-sdk


signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Creating meta-packages for python2/3 from a single spec

John Paul Adrian Glaubitz
On 08/21/2017 03:44 PM, jan matejek wrote:
> On 21.8.2017 15:38, John Paul Adrian Glaubitz wrote:
>> That's odd. I basically took the current version of my package [1], commented
>> out the Source directives and the %python_build directives and it fails with:
>
> rpm macros expand even in comments -- macros have higher priority than comments
> %python_build expansions is multiline
> so if you write #%python_build, you comment out its first line and get all the rest

Ooooh. Very interesting. I was not expecting that but it perfectly makes sense :).

> you need to either delete the macro entirely, or escape it with an additional % sign:
> #%%python_build

Got it.

> (you might get interesting results with the commented out %files section as well)
>
> hope this helps

Definitely. Thanks a lot for the quick help!

Adrian
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Creating meta-packages for python2/3 from a single spec

John Paul Adrian Glaubitz
On 08/21/2017 03:46 PM, John Paul Adrian Glaubitz wrote:
>> (you might get interesting results with the commented out %files section as well)
>>
>> hope this helps
>
> Definitely. Thanks a lot for the quick help!

Hmm. So, I have followed your advice and properly commented out %python_build and
so on. While it now builds fine, it actually just generates the source RPM.

I thoroughly checked whether I missed something obvious but I couldn't find
anything. With the changes in the diff, I just get the source RPM.

Any ideas?

Adrian

python-azure-sdk-meta.diff (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Creating meta-packages for python2/3 from a single spec

jan matejek-5
On 21.8.2017 16:41, John Paul Adrian Glaubitz wrote:

> On 08/21/2017 03:46 PM, John Paul Adrian Glaubitz wrote:
>>> (you might get interesting results with the commented out %files section as well)
>>>
>>> hope this helps
>>
>> Definitely. Thanks a lot for the quick help!
>
> Hmm. So, I have followed your advice and properly commented out %python_build and
> so on. While it now builds fine, it actually just generates the source RPM.
>
> I thoroughly checked whether I missed something obvious but I couldn't find
> anything. With the changes in the diff, I just get the source RPM.
You don't have any %files sections.
If you want a package, you need the appropriate %files section, even if they are empty. Otherwise
the package is not generated. In this case, simply uncomment the "%files %{python_files}" line.

(RPM only generates packages that have appropriate %files sections. This is actually useful for
singlespec: you get packages called "python-azure-sdk", but the resulting spec file doesn't have a
"%files" section for it, only "%files -n python3-azure-sdk" and "%files -n python2-azure-sdk", so
you get python2 package, python3 package, but no python- package.)

regards
m.

>
> Any ideas?
>
> Adrian


signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Creating meta-packages for python2/3 from a single spec

John Paul Adrian Glaubitz
On 08/21/2017 04:47 PM, jan matejek wrote:
> You don't have any %files sections.
> If you want a package, you need the appropriate %files section, even if they are empty. Otherwise
> the package is not generated. In this case, simply uncomment the "%files %{python_files}" line.

Indeed. That fixed it.

> (RPM only generates packages that have appropriate %files sections. This is actually useful for
> singlespec: you get packages called "python-azure-sdk", but the resulting spec file doesn't have a
> "%files" section for it, only "%files -n python3-azure-sdk" and "%files -n python2-azure-sdk", so
> you get python2 package, python3 package, but no python- package.)

Thanks for the explanation.

Adrian
--
To unsubscribe, e-mail: [hidden email]
To contact the owner, e-mail: [hidden email]