Supporting multiple python runtimes with automake

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

Supporting multiple python runtimes with automake

Yuval Turgeman
Hi,

I added 2 macros (AM_PATH_PYTHON2 and AM_PATH_PYTHON3) to support both
python2 and python3 on the same system.  It works in the same way that
AM_PATH_PYTHON works (just a small wrapper around it).  Please notice that
AM_PATH_PYTHON and AM_PATH_PYTHONx can't be called together.

The motive for doing this is Fedora Packaging Guidelines for Python (
https://fedoraproject.org/wiki/Packaging:Python) which requires a package
to be built for both runtimes.

Thanks,
Yuval.

0001-python.m4-supporing-multiple-python-runtimes.patch (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Supporting multiple python runtimes with automake

Sandro Bonazzola
2018-01-30 11:26 GMT+01:00 Yuval Turgeman <[hidden email]>:

> Hi,
>
> I added 2 macros (AM_PATH_PYTHON2 and AM_PATH_PYTHON3) to support both
> python2 and python3 on the same system.  It works in the same way that
> AM_PATH_PYTHON works (just a small wrapper around it).  Please notice that
> AM_PATH_PYTHON and AM_PATH_PYTHONx can't be called together.
>
> The motive for doing this is Fedora Packaging Guidelines for Python (
> https://fedoraproject.org/wiki/Packaging:Python) which requires a package
> to be built for both runtimes.
>

Are you planning to use this for installing python2 and python3 artifacts
in a single make install call instead of having to go through 2 runs of
configure / make / make install ?




>
> Thanks,
> Yuval.
>



--

SANDRO BONAZZOLA

ASSOCIATE MANAGER, SOFTWARE ENGINEERING, EMEA ENG VIRTUALIZATION R&D

Red Hat EMEA <https://www.redhat.com/>
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
Reply | Threaded
Open this post in threaded view
|

Re: Supporting multiple python runtimes with automake

Yuval Turgeman-2
On Tue, Jan 30, 2018 at 2:22 PM, Sandro Bonazzola <[hidden email]>
wrote:

>
>
> 2018-01-30 11:26 GMT+01:00 Yuval Turgeman <[hidden email]>:
>
>> Hi,
>>
>> I added 2 macros (AM_PATH_PYTHON2 and AM_PATH_PYTHON3) to support both
>> python2 and python3 on the same system.  It works in the same way that
>> AM_PATH_PYTHON works (just a small wrapper around it).  Please notice that
>> AM_PATH_PYTHON and AM_PATH_PYTHONx can't be called together.
>>
>> The motive for doing this is Fedora Packaging Guidelines for Python (
>> https://fedoraproject.org/wiki/Packaging:Python) which requires a
>> package to be built for both runtimes.
>>
>
> Are you planning to use this for installing python2 and python3 artifacts
> in a single make install call instead of having to go through 2 runs of
> configure / make / make install ?
>


Yes, the alternative to this is to run everything twice with a different
`PYTHON=` value, unless I'm missing something and there's an easier way
that would make this patch irrelevant.




>
>
>
>>
>> Thanks,
>> Yuval.
>>
>
>
>
> --
>
> SANDRO BONAZZOLA
>
> ASSOCIATE MANAGER, SOFTWARE ENGINEERING, EMEA ENG VIRTUALIZATION R&D
>
> Red Hat EMEA <https://www.redhat.com/>
> <https://red.ht/sig>
> TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Supporting multiple python runtimes with automake

Mathieu Lirzin
Hello,

Yuval Turgeman <[hidden email]> writes:

> On Tue, Jan 30, 2018 at 2:22 PM, Sandro Bonazzola <[hidden email]>
> wrote:
>
>> 2018-01-30 11:26 GMT+01:00 Yuval Turgeman <[hidden email]>:
>>
>>> I added 2 macros (AM_PATH_PYTHON2 and AM_PATH_PYTHON3) to support both
>>> python2 and python3 on the same system.  It works in the same way that
>>> AM_PATH_PYTHON works (just a small wrapper around it).  Please notice that
>>> AM_PATH_PYTHON and AM_PATH_PYTHONx can't be called together.
>>>
>>> The motive for doing this is Fedora Packaging Guidelines for Python (
>>> https://fedoraproject.org/wiki/Packaging:Python) which requires a
>>> package to be built for both runtimes.
>>>
>>
>> Are you planning to use this for installing python2 and python3 artifacts
>> in a single make install call instead of having to go through 2 runs of
>> configure / make / make install ?
>>
>
> Yes, the alternative to this is to run everything twice with a different
> `PYTHON=` value, unless I'm missing something and there's an easier way
> that would make this patch irrelevant.

Could you explain why re-running the configuration phase with different
‘PYTHON’ values does not fit your use-case?

--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37

Reply | Threaded
Open this post in threaded view
|

Re: Supporting multiple python runtimes with automake

Yuval Turgeman-2
Because when I want to package an rpm, I have a single %build and %install
in my spec, so my second call to configure will override the first, and
then i will need to run make install.  So the process would be result in
something like

(from %build)
configure PYTHON=/usr/bin/python2
make
configure PYTHON=/usr/bin/python3
make
(from %install)
make install

which wont work (unless we move make install to %build i guess).  With this
patch, a single configure would nail both pythons, and make install would
install the relevant files to their correct location.

(Please dont mind the syntax here, writing from a smartphone...)

On Tue, Jan 30, 2018 at 5:52 PM, Mathieu Lirzin <[hidden email]> wrote:

> Hello,
>
> Yuval Turgeman <[hidden email]> writes:
>
> > On Tue, Jan 30, 2018 at 2:22 PM, Sandro Bonazzola <[hidden email]>
> > wrote:
> >
> >> 2018-01-30 11:26 GMT+01:00 Yuval Turgeman <[hidden email]>:
> >>
> >>> I added 2 macros (AM_PATH_PYTHON2 and AM_PATH_PYTHON3) to support both
> >>> python2 and python3 on the same system.  It works in the same way that
> >>> AM_PATH_PYTHON works (just a small wrapper around it).  Please notice
> that
> >>> AM_PATH_PYTHON and AM_PATH_PYTHONx can't be called together.
> >>>
> >>> The motive for doing this is Fedora Packaging Guidelines for Python (
> >>> https://fedoraproject.org/wiki/Packaging:Python) which requires a
> >>> package to be built for both runtimes.
> >>>
> >>
> >> Are you planning to use this for installing python2 and python3
> artifacts
> >> in a single make install call instead of having to go through 2 runs of
> >> configure / make / make install ?
> >>
> >
> > Yes, the alternative to this is to run everything twice with a different
> > `PYTHON=` value, unless I'm missing something and there's an easier way
> > that would make this patch irrelevant.
>
> Could you explain why re-running the configuration phase with different
> ‘PYTHON’ values does not fit your use-case?
>
> --
> Mathieu Lirzin
> GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Supporting multiple python runtimes with automake

Mathieu Lirzin
Yuval Turgeman <[hidden email]> writes:

> Because when I want to package an rpm, I have a single %build and
> %install in my spec, so my second call to configure will override the
> first, and then i will need to run make install. So the process would
> be result in something like
>
> (from %build)
> configure PYTHON=/usr/bin/python2
> make
> configure PYTHON=/usr/bin/python3
> make
> (from %install)
> make install
>
> which wont work (unless we move make install to %build i guess). With
> this patch, a single configure would nail both pythons, and make
> install would install the relevant files to their correct location.

What could be done is to use out-of-tree “VPATH” builds [1] to configure
and build with both python versions in different directories in the
‘%build’ phase and run ‘make install’ in each of these directories in
the ’%install’ phase.

Maybe something like this (totally untested :-)):
--8<---------------cut here---------------start------------->8---
%build
mkdir py2 && cd py2
../%configure PYTHON=/path/to/python2
%make_build
cd ..
mkdir py3 && cd py3
../%configure PYTHON=/path/to/python3
%make_build
cd ..

%install
%make_install -C py2
%make_install -C py3
--8<---------------cut here---------------end--------------->8---

It seems not ideal to handle distro specific packaging guidelines on the
upstream configuration side.  As a consequence I would rather avoid
adding macros to be run at configure time.

WDYT?

[1] https://www.gnu.org/software/automake/manual/html_node/VPATH-Builds.html

--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37

Reply | Threaded
Open this post in threaded view
|

Re: Supporting multiple python runtimes with automake

Yuval Turgeman-2
Hi,

Thanks for the feedback !  What you described is what we are doing today,
it does the job nicely, I just thought it would be nice to avoid 2 calls.
Honestly, both VPATH and my patch feel a little hackish to me, and the
existing way is not really that painful, I guess.  Your call, I will not be
offended if this gets rejected, as I wasnt 100% sure I should post this
anyway, but since I already played with it one night, I thought why not :)

Thanks !


On Jan 31, 2018 8:49 PM, "Mathieu Lirzin" <[hidden email]> wrote:

Yuval Turgeman <[hidden email]> writes:

> Because when I want to package an rpm, I have a single %build and
> %install in my spec, so my second call to configure will override the
> first, and then i will need to run make install. So the process would
> be result in something like
>
> (from %build)
> configure PYTHON=/usr/bin/python2
> make
> configure PYTHON=/usr/bin/python3
> make
> (from %install)
> make install
>
> which wont work (unless we move make install to %build i guess). With
> this patch, a single configure would nail both pythons, and make
> install would install the relevant files to their correct location.

What could be done is to use out-of-tree “VPATH” builds [1] to configure
and build with both python versions in different directories in the
‘%build’ phase and run ‘make install’ in each of these directories in
the ’%install’ phase.

Maybe something like this (totally untested :-)):
--8<---------------cut here---------------start------------->8---
%build
mkdir py2 && cd py2
../%configure PYTHON=/path/to/python2
%make_build
cd ..
mkdir py3 && cd py3
../%configure PYTHON=/path/to/python3
%make_build
cd ..

%install
%make_install -C py2
%make_install -C py3
--8<---------------cut here---------------end--------------->8---

It seems not ideal to handle distro specific packaging guidelines on the
upstream configuration side.  As a consequence I would rather avoid
adding macros to be run at configure time.

WDYT?

[1] https://www.gnu.org/software/automake/manual/html_node/VPATH-Builds.html

--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37
Reply | Threaded
Open this post in threaded view
|

Re: Supporting multiple python runtimes with automake

Mathieu Lirzin
Hi Yuval,

Yuval Turgeman <[hidden email]> writes:

> Thanks for the feedback ! What you described is what we are doing
> today, it does the job nicely, I just thought it would be nice to
> avoid 2 calls. Honestly, both VPATH and my patch feel a little hackish
> to me, and the existing way is not really that painful, I guess. Your
> call, I will not be offended if this gets rejected, as I wasnt 100%
> sure I should post this anyway, but since I already played with it one
> night, I thought why not :)

I would rather stick to a single AM_PATH_PYTHON for Python.  :-)

Thanks for your patch anyway.  If you have other ideas regarding how
Python support in Automake could be improved, feel free to share your
ideas on <[hidden email]> or your patches on this list.

Sorry for the delay.

--
Mathieu Lirzin
GPG: F2A3 8D7E EB2B 6640 5761  070D 0ADE E100 9460 4D37