Python Setuptools
Python packages can be installed with python setuptools, which uses distutils as the standard library. To do this generate a setup.py file, and then create a specfile just like you normally would. Normally, the specfile builds c, so to build python it needs to be altered a little bit. First add the following line to the very start of the specfile. I had to split into two because it is somewhat long.
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
The rest is the same except for the section where the package is built. Here is an example of part of one my specfiles.
%prep %setup -q %build %{__python} setup.py build %install rm -rf $RPM_BUILD_ROOT %{__python} setup.py install -O1 --skip-build --root $RPM_BUILD_ROOT %clean
rm -rf $RPM_BUILD_ROOT
As you may have noticed the %prep and %clean sections are still the same. When installing you have to tell distutils it doesn’t need to build, because it already has previously, and specify the root dir. I managed to figure this out by reverse engineering this pungi specfile.
Previous | Home |
May 3, 2010 at 4:47 pm |
Amazing tutorial!
I packaged an RPM for varnish 2.1.1-1. In case you are interested to obtain it, just contact me. You saved me lots of effort and time by this tutorial, thank you so much 🙂
September 17, 2011 at 6:38 am |
Appreciate your document. please help me out with this .
REQUIREMENT : i have already compiled java class files and jars are created out of it . my purpose is to create rpm which has to have that jar file along with xml files … thats it .. so for this what needs to be done . so in which section do we need to define that . ALso where to give all this things is it in spec file ?
%prep
%setup -q
%build
%{__python} setup.py build
%install
rm -rf $RPM_BUILD_ROOT
%{__python} setup.py install -O1 –skip-build –root $RPM_BUILD_ROOT
%cleanrm -rf $RPM_BUILD_ROOT
October 22, 2013 at 9:16 am |
Thanks for sharing this. The fungi spec file link is broken: I had to use http://oss.tresys.com/projects/clip/browser/packages/pungi/pungi.spec to have a look at it. Cheers.
October 22, 2013 at 9:18 am |
Thanks for sharing this! The fungi spec file link was broken: I found it at http://oss.tresys.com/projects/clip/browser/packages/pungi/pungi.spec. Cheers.
October 26, 2013 at 4:35 pm |
informative tutorial
April 15, 2014 at 9:34 am |
Good tutorial. But you have not mentioned about creating rpm after editing spec file. Is there a way to call spec file using inbuilt command “bdist_rpm” or should I have to use “rpmbuild” to generate package? In both the cases an example would have be helpful for new comer like me.
Nice tutorial though.