[opensuse-packaging] Separating python modules into packages
Morning all, I need to separate one module from a build of a python package into a separate package. This is usually not a big act, e.g. in C-programs. Python packaging seems to be different from that What normally happens is that you have a file section with: %files [some more definitions] %{python_sitelib}/* Where the last command puts everything under /usr/lib/python3.x/.... Done. After having defined a new package in the spec file I wanted to separate the files: %files -n %{name}-orthanc %{python_sitelib}/health-orthanc* -> This results in a 'file not found error': [ 34s] /home/abuild/rpmbuild/BUILDROOT/gnuhealth-3.5-0.x86_64/health- orthanc* No surprise, as this is not the location for the module. So, I've defined a variable to keep the path: %define t_path $(ls -d /usr/lib/python3.* )/site-packages/trytond/modules that expands nicely e.g. in the Installation section: echo %{t_path} [ 29s] ++ ls -d /usr/lib/python3.6 [ 29s] + echo /usr/lib/python3.6/site-packages/trytond/modules [ 29s] /usr/lib/python3.6/site-packages/trytond/modules but in the files section: %files -n %{name}-orthanc %{t_path}/health-orthanc* [ 38s] Processing files: gnuhealth-orthanc-3.5-0.noarch [ 38s] error: File must begin with "/": $(ls [ 38s] error: File must begin with "/": -d [ 38s] error: File must begin with "/": )/site-packages/trytond/modules/ health-orthanc* At the moment I'm a bit stuck. Anyone with a better idea or an example? Thanks Axel -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Hi Axel,
I need to separate one module from a build of a python package into a separate package.
First question: which Python version(s)? Is this package for Python 3 only or do you need to support both (2 and 3)?
[...] No surprise, as this is not the location for the module. So, I've defined a variable to keep the path: %define t_path $(ls -d /usr/lib/python3.* )/site-packages/trytond/modules
That definition looks wrong to me. ;) I guess you already have the "python-rpm-macros" package as build requirement. Shell expansions is tricky, so I would better rely on these Python macros. If you need Python3 only, I would try to redefine the variable like this: %define t_path %{python3_sitelib}/trytond/modules Here is an overview of these macros: https://github.com/openSUSE/python-rpm-macros As I don't know your project, I'm not 100% sure what else you need.
[...]
Good luck, hope that helps. -- Gruß/Regards, Thomas Schraitle ---------------------------------------------------------------------- SUSE LINUX GmbH (o< Maxfeldstrasse 5 /\\ Documentation Specialist 90409 Nuernberg, Germany _\_v http://www.suse.com https://github.com/tomschr GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nürnberg) -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Hello Thomas. Am Freitag, 27. September 2019, 08:59:27 CEST schrieb Thomas Schraitle:
I need to separate one module from a build of a python package into a separate package.
First question: which Python version(s)? Is this package for Python 3 only or do you need to support both (2 and 3)?
Python3 only
[...] No surprise, as this is not the location for the module. So, I've defined a variable to keep the path: %define t_path $(ls -d /usr/lib/python3.* )/site-packages/trytond/modules
That definition looks wrong to me. ;)
but it worked in a shell environment :-)
I guess you already have the "python-rpm-macros" package as build requirement. Shell expansions is tricky, so I would better rely on these Python macros.
If you need Python3 only, I would try to redefine the variable like this:
%define t_path %{python3_sitelib}/trytond/modules
Yes! That fixed it, thanks a lot!
Here is an overview of these macros:
I will look into this. One last question - to not get the files twice, is there a smarter way than %exclude in the files section for every definition from the subpackage?
As I don't know your project, I'm not 100% sure what else you need.
https://build.opensuse.org/package/show/Application:ERP:Tryton:5.0/gnuhealth At the moment it seems to work :-) Thanks again Axel -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
Hello, Am Freitag, 27. September 2019, 11:10:54 CEST schrieb Axel Braun:
Am Freitag, 27. September 2019, 08:59:27 CEST schrieb Thomas Schraitle:
Here is an overview of these macros: https://github.com/openSUSE/python-rpm-macros
I will look into this.
One last question - to not get the files twice, is there a smarter way than %exclude in the files section for every definition from the subpackage?
Generic answer without having looked at your package: IMHO the need for %exclude means that you use too many / too generic wildcards. ... and after looking at your specfile, I still think so ;-) You have (shortened to the relevant parts) %files -n %{name}-orthanc %{python3_sitelib}/%{name}_orthanc* %{python3_sitelib}/trytond/modules/health_orthanc* %files %defattr(744,root,root) As a sidenote - why 744? That (executable only for root, readable for everybody) doesn't really make sense IMHO, 755 or 644 are much more common. [...] %exclude %{python3_sitelib}/%{name}_orthanc* %exclude %{python3_sitelib}/trytond/modules/health_orthanc* %{python_sitelib}/* Here we have the problem - drop %{python_sitelib}/* and replace it with more specific lines that catch whatever should go into that package. Sometimes[1] I even go the extreme way and list every single file. That's a bit more work in the beginning, but helps to catch packaging regressions (missing files) and changes (additional files installed by make install). Regards, Christian Boltz [1] I do this for most parts of the AppArmor package, and it helped more than once ;-) -- Ein Update ist meines Wissens die Erhöhung der Versionsnummer. Ob sich dabei die Qualität auch erhöht, ist manchmal fraglich. [Martin Ereth in suse-linux] -- To unsubscribe, e-mail: opensuse-packaging+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse-packaging+owner@opensuse.org
participants (3)
-
Axel Braun
-
Christian Boltz
-
Thomas Schraitle