Python site-packages tricks (was: Re: rpms/scons/devel scons.spec,1.3,1.4)

Ville Skyttä ville.skytta at iki.fi
Tue Jan 25 22:09:48 UTC 2005


On Tue, 2005-01-25 at 20:36 +0100, Thorsten Leemhuis wrote:
> Am Dienstag, den 25.01.2005, 20:21 +0100 schrieb Matthias Saou:

> > Shouldn't this use the sysconfig.get_python_lib(foo) trick (that Ville
> > showed me) to get the arch independant python lib path instead?
> 
> Good question; Ville what is that for a trick?

I don't know if it's much of a trick, but see spectemplate-python.spec
in fedora-rpmdevtools.  It applies to most Python extension packages out
there that use Python's distutils, and install stuff into site-packages
dirs.  In the scons case, things are not installed to the site-packages
dirs, it seems, so the "trick" doesn't apply AFAICT.

Anyway the idea is to find out the dirs where Python's distutils will
install stuff into by asking Python and using those in %files instead of
inventing/hardcoding the dirs oneself.

One common build failure with Python extension packages is that the
packager assumes %{_libdir}/python%{something}/site-packages/[...] as
the target dir.  This will fail for all noarch Python packages when
built on x86_64.  There, noarch stuff ends up
in /usr/lib/pythonX.X/[...], and arch-dependent
to /usr/lib64/pythonX.X/[...].  Python makes a distinction between arch-
specific and arch-independent packages, and the Python spec template has
%{python_sitearch} and %{python_sitelib} accordingly.

The names correspond to the macros rpm has had for Perl for a long time.
There are open RFE's in Bugzilla to get these %{python_site*} macros
applied to upstream rpm's default macros file.

This strategy should be future proof in the way that if the site-
packages or parts of it moves elsewhere (for example, the arch-
independent parts to /usr/share/[...]) one day, a simple package rebuild
for the extensions should suffice.  It'll also take care of Python
version changes for free.

Further, spectemplate-python.spec uses the %{__python} macro for
everything, so this stuff should apply to custom Python installations;
one just does a "rpmbuild --rebuild --define
'__python /path/to/custom/pythonX' ..." and things should work regarding
this bit.

(I intend to document this to the WIP packagers-handbook in
cvs.fedora.us soon(tm).)




More information about the fedora-extras-commits mailing list