[opensuse-packaging] How to Build and Package Python 3 Packages?
Hi, in my repository I package a lot of Python packages almost exclusively for version 2.x. I use the template described in [1] which works pretty well in most cases. So far, so good. However, I haven't found anything that covers how to build Python 3 packages. As most projects probably will consider either switching to the new version or supporting both versions, I think this will become more and more important. Maybe I missed something, but at the moment it seems to me, the details are not fully described. Maybe some friendly developer can give me some recommendations: 1. Are there any RPM macros definied for Python3? In /usr/lib/rpm/macros there are the usual suspects like py_prefix, py_libdir, etc. However, these macros are definied for Python2.x only. I haven't found macros for Python3 yet. Do I have to define it myself or where can I find them? What is recommended in this case? 2. What is the official naming schema for Python 3 packages? I saw that some packages in the OBS starts with the prefix "python3-" which I think is a good idea. Is this a convention or an official policy? Is it expected that Python2 packages will be renamed to "python2-" and Python3 packages become "python-"? Similar to the KDE3/KDE4 package renaming? (My impression is this will not happen soon.) 3. How to build packages in OBS which are written for Python 2.x and 3.x? I maintain the package python-lxml[2]. The source can be build for both versions which is good. :) I tried some variations but in the end I wrote two spec files: python- lxml.spec and python3-lxml.spec and committed it. However, OBS seems to build only the packages for python-lxml and doesn't look at the python3-lxml.spec. Do I have to create another project? If possible, I would like to keep everything in one project. Any recommendations here? 4. Anything else which is important for building Python 3.x packages? Thanks, Tom -------- [1] http://en.opensuse.org/Packaging/Python [2] https://build.opensuse.org/package/show?package=python- lxml&project=home%3Athomas-schraitle -- Thomas Schraitle ---------------------------------------------------------------------- SUSE LINUX GmbH >o) Documentation Specialist Maxfeldstrasse 5 /\\ 90409 Nuernberg _\_v http://en.opensuse.org/Documentation_Team http://developer.novell.com/wiki/index.php/Lessons_for_Lizards http://lizards.opensuse.org/author/thomas-schraitle/ --------------------------------------------------------------------- -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
hi, thank you for bringing this up. Packaging for python3 is a rather new topic and it's not very well researched. I invite everyone interested to contribute to creation of python3 packaging conventions. To your questions: Dne 13.3.2010 11:20, Thomas Schraitle napsal(a):
1. Are there any RPM macros definied for Python3?
In /usr/lib/rpm/macros there are the usual suspects like py_prefix, py_libdir, etc. However, these macros are definied for Python2.x only. I haven't found macros for Python3 yet. Do I have to define it myself or where can I find them? What is recommended in this case?
Macros for python3 will be added to python3 package, and probably to RPM later on as well. They're not there yet - my bad. I will try to take time and add them soon. At the moment it's best to define the macros in your sources. I am not sure about naming scheme yet, we should consult this with Fedora (and possibly Mandriva, but i'm not sure how much they're interested). I'm adding Pavol Rusnak to CC, as he is in contact with Fedora packagers. It probably makes sense to call the macros %py3_something and %python3_something.
2. What is the official naming schema for Python 3 packages?
I saw that some packages in the OBS starts with the prefix "python3-" which I think is a good idea. Is this a convention or an official policy? Is it expected that Python2 packages will be renamed to "python2-" and Python3 packages become "python-"? Similar to the KDE3/KDE4 package renaming? (My impression is this will not happen soon.)
As the policy is not defined yet, "python3-" prefix is just a convention. But it will be included in the policy, so please use this naming scheme. There is no plan for KDE-like renaming in the foreseeable future.
3. How to build packages in OBS which are written for Python 2.x and 3.x?
I maintain the package python-lxml[2]. The source can be build for both versions which is good. :) I tried some variations but in the end I wrote two spec files: python- lxml.spec and python3-lxml.spec and committed it.
At the moment it is not possible to build from the same spec. I don't have any idea how to do it. Suggestions are welcome. You would still need two different packages because of python version requirements, though.
However, OBS seems to build only the packages for python-lxml and doesn't look at the python3-lxml.spec. Do I have to create another project? If possible, I would like to keep everything in one project. Any recommendations here?
Create a new package in the same project, name it python3-lxml and link to python-lxml. It will pick up the other spec and build it. See how python-base and python-doc are built in d:l:py:Factory.
4. Anything else which is important for building Python 3.x packages?
Python3 is not split yet, and i am not sure about noarch support in it. I was working on it, but it is not finished yet. That is all that comes to mind. Ideas, anyone? regards m. -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
On 03/15/2010 06:13 PM, Jan Matejek wrote:
Ideas, anyone?
Fedora already updated their Packaging documentation with info how to deal with Python 3: http://fedoraproject.org/wiki/Packaging:Python I will try to summarize the main points: * Python 2.6 is still default * python runtime packages provide python(abi) symbols (in versions 2.6 and 3.1 at the moment), modules require the respective symbols (via rpm auto-dependency-generator) * to build a package containing pythonX module you need to add pythonX-devel to BuildRequires (python2-devel/python3-devel or both when package provides module for both versions) * new macros: %__python3, %python3_sitelib, %python3_sitearch More precise info is available from the wiki. If it is possible and desired I think we could try to align to Fedora again. -- Best Regards / S pozdravom, Pavol RUSNAK SUSE LINUX, s.r.o openSUSE Boosters Team Lihovarska 1060/12 PGP 0xA6917144 19000 Praha 9, CR prusnak[at]suse.cz http://www.suse.cz -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Hi, On Monday 15 March 2010 Pavol Rusnak wrote:
On 03/15/2010 06:13 PM, Jan Matejek wrote:
Ideas, anyone?
Fedora already updated their Packaging documentation with info how to deal with Python 3: http://fedoraproject.org/wiki/Packaging:Python
I will try to summarize the main points:
* Python 2.6 is still default * python runtime packages provide python(abi) symbols (in versions 2.6 and 3.1 at the moment), modules require the respective symbols (via rpm auto-dependency-generator) * to build a package containing pythonX module you need to add pythonX-devel to BuildRequires (python2-devel/python3-devel or both when package provides module for both versions) * new macros: %__python3, %python3_sitelib, %python3_sitearch
More precise info is available from the wiki.
If it is possible and desired I think we could try to align to Fedora again.
Thanks Pavol for your information! :-) I've added a summary in http://en.opensuse.org/Packaging/Python about Python 3 module. Feel free to change or adapt it. :) -- Regards, Thomas Schraitle ---------------------------------------------------------------------- SUSE LINUX Products GmbH (o< Tel: +49-(0)911-740 53 131 Maxfeldstrasse 5 /\\ Documentation Specialist 90409 Nuernberg, Germany _\_v http://www.suse.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
Hi Jan, thanks for your help and valuable feedback! :-) Monday 15 March 2010
thank you for bringing this up. Packaging for python3 is a rather new topic and it's not very well researched. I invite everyone interested to contribute to creation of python3 packaging conventions.
Maybe we could summerize the essense of this thread into a Wiki page? I have to finish another project first, but I can write something up.
To your questions: [...]
However, OBS seems to build only the packages for python-lxml and doesn't look at the python3-lxml.spec. Do I have to create another project? If possible, I would like to keep everything in one project. Any recommendations here?
Create a new package in the same project, name it python3-lxml and link to python-lxml. It will pick up the other spec and build it.
Thanks, indeed this does the job. Good trick! :-)
See how python-base and python-doc are built in d:l:py:Factory.
Will do. Thanks! -- Thomas Schraitle ---------------------------------------------------------------------- SUSE LINUX GmbH >o) Documentation Specialist Maxfeldstrasse 5 /\\ 90409 Nuernberg _\_v http://en.opensuse.org/Documentation_Team http://developer.novell.com/wiki/index.php/Lessons_for_Lizards http://lizards.opensuse.org/author/thomas-schraitle/ --------------------------------------------------------------------- -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-packaging+help@opensuse.org
participants (3)
-
Jan Matejek
-
Pavol Rusnak
-
Thomas Schraitle