[Slackbuilds-users] [FYI]SlackBuild for python modules should be architecture dependent

Eric Hameleers alien at slackbuilds.org
Thu May 28 18:36:15 UTC 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Grissiom wrote:
> Hi folks,
> 
> While I was taking train this afternoon, a thought came up in my mind --
> SlackBuilds for python modules and many programs that written in pure
> python (say, decorator, pysetuptools, logilab-common etc) should be arch
> dependent. Maybe most of them are installed via "distutils", if you see
> something like "python setup.py install --root=$PKG", it will be the case.
> 
> I think setup.py just do what "./configure && make && make install" do
> -- detect the python installation structure, compile .py files to .pyc
> bytecodes. The bytecodes is platorm independent but the installation
> structure is not. So in slackware64, things will be installed into
> /usr/lib64/python2.6/site-packages/xxx but in slackware, things will be
> installed into /usr/lib/python2.6/site-packages/xxx. The conclusion is
> the files in the package in arch indenpendent but the direcory structure
> is arch dependent.
> 
> After some hack, I found a solution for this: write the SlackBuilds like
> this:
> ....
> if [ "$ARCH" = "i486" ]; then
>   SLKCFLAGS="-O2 -march=i486 -mtune=i686"
>   LIBDIRSUFFIX=""
> elif [ "$ARCH" = "i686" ]; then
>   SLKCFLAGS="-O2 -march=i686 -mtune=i686"
>   LIBDIRSUFFIX=""
> elif [ "$ARCH" = "x86_64" ]; then
>   SLKCFLAGS="-O2 -fPIC"
>   LIBDIRSUFFIX="64"
> fi
> ....
> ....
> python setup.py install --prefix=/usr
> --install-lib=/usr/lib${LIBDIRSUFFIX}/python2.6/site-packages/ --root=$PKG
> ....
> 
> Thus the package will install files to /usr/lib for 32bit slack and
> /usr/lib64 for slackware64.(note python in slackware12.2 is still 2.5.x
> you may need to adjust the install command for 12.2)
> 
> Saying so much, I hope I have expressed my idea clearly and it will do
> some help.

Hi Grissiom

If you write a SlackBuild that installs purepython files which are
architecture independent you will indeed still have a "lib vs lib64"
difference in the final package depending on the architecture you
create the package on.
But since we are SlackBuilds.org and not LinuxPackages.net we do not
have to worry about where the final package gets built and installed -
the person who compiles it will know.

So, the purepython package can be "noarch" as long as you determine
the install-lib using Python itself:

PYTHONLIB=$( python -c "from distutils.sysconfig import
get_python_lib; print get_python_lib()" )

This will yield "/usr/lib/python2.5/site-packages" on Slackware 12.2
and "/usr/lib64/python2.6/site-packages" on slackware64-current. You
see that the python version number no longer needs to be hardcoded.

Use that variable as follows:

python setup.py install \
  --prefix=/usr \
  --install-lib=$PYTHONLIB \
  --root=$PKG

You will not have to add the "if ARCH ... fi" block and the
LIBDIRSUFFIX is not used at all. A single SlackBuild will work on all
Slackware releases.

Cheers, Eric
- --

Eric Hameleers                     >')
Email:  alien at slackbuilds.org      ( \
Jabber: alien at jabber.xs4all.nl      ^^`
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkoe2UsACgkQXlaqr6dcvaD6KgCfcVhUh5MeDRP5js000OpvPzGM
T28AnR5DilhrtY5PJxOMMID+oHGcco9R
=Yz+5
-----END PGP SIGNATURE-----


More information about the SlackBuilds-users mailing list