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

Ville Skyttä ville.skytta at iki.fi
Thu Jan 27 07:08:54 UTC 2005


On Wed, 2005-01-26 at 19:44 +0100, Dag Wieers wrote:
> On Wed, 26 Jan 2005, Ville Skyttä wrote:

> > 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.
> 
> We're using the following macros for that:
> 
> %define python_sitearch %(python -c 'from distutils import sysconfig; print sysconfig.get_python_lib()')
> %define python_sitelib %(python -c 'from distutils import sysconfig; print sysconfig.get_python_lib(1)')
> 
> Is this what you are using too ?

Almost.  Your version above has the argument to get_python_lib reversed;
with no arguments it returns the arch-independent path ("sitelib"), and
with 1 the arch-dependent path ("sitearch").  Additionally, your version
uses "python" instead of "%{__python}" which takes away a bit of the
flexibility.

Here's what's in fedora-rpmdevtools' spectemplate-python.spec:

%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}





More information about the fedora-extras-commits mailing list