Getting distutils to install prebuilt compiled libraries?
Asked Answered
D

2

9

I manage an open source project (Remix, the source is available there) written in python. We ask users to run python setup.py install to install the software. Recently we added a compiled C++ package (a port of SoundTouch -- go to trunk/externals in the source to see it.) We'd like the setup.py file that installs the base Remix libraries to also install the pysoundtouch14 library.

However, we don't want users to have to have a gcc or msvc toolchain on their system. We've precompiled binaries for common platforms (linux-i386, windows, mac 10.5 and 10.6), go to trunk/externals/pysoundtouch14/build to see them. I was hoping that a user who does not have gcc or msvc installed could just run pysoundtouch14's setup.py and it would detect the presence of our prebuilt binaries and just copy them to the right place (/Library/Python/2.5/site-packages, for example.) But that doesn't happen. On a new 10.5 system, for example, setup.py complains about no gcc being installed even though the .so it needs to install is already built in the build/ folder.

So I have two direct questions:

  • How can I get setup.py to just "install" prebuilt .so and .pyd files in the right place automatically depending on the platform without requiring a build system?
  • How can one setup.py (our main setup.py file) also run the setup.py of another included package (pysoundtouch14's setup.py?)
Destiny answered 16/6, 2009 at 16:27 Comment(0)
A
1

Your first question is a tough one given the multiplatform requirement. If it was just windows, you could use the post-installation script option to run a script to handle the libraries or just use a non-python tool such as NSIS. I'm not sure what else can be done other than Almad's suggestion.

For your second question, you might want to look into Paver.

Arhat answered 17/6, 2009 at 16:24 Comment(2)
Thanks DoxaLogos. It may be the case that we have to just move to platform specific installers (NSIS, Packages on the mac, dkpg/apt for debian, etc.) It probably is not a horrible idea. But i was hoping for a pure python solution... may not be possible.Destiny
Well, even if you use multiple package tools, I think you can automate their package creation with the likes of Paver. So, once you get everything set up intially, you can just run build script with Paver.Arhat
T
1

Unfortunately, I'd say that overriding install command is the way to go.

This can be done easily, using custom distribution command. For example, see [1] http://svn.zope.org/Zope/branches/2.9/setup.py?rev=69978&view=auto

Teakettle answered 16/6, 2009 at 21:55 Comment(2)
This link is broken, can you share the code snippet?Rugen
Memory a bit rusty after 13 years, but I believe I was referring to this zope setup command.Teakettle
A
1

Your first question is a tough one given the multiplatform requirement. If it was just windows, you could use the post-installation script option to run a script to handle the libraries or just use a non-python tool such as NSIS. I'm not sure what else can be done other than Almad's suggestion.

For your second question, you might want to look into Paver.

Arhat answered 17/6, 2009 at 16:24 Comment(2)
Thanks DoxaLogos. It may be the case that we have to just move to platform specific installers (NSIS, Packages on the mac, dkpg/apt for debian, etc.) It probably is not a horrible idea. But i was hoping for a pure python solution... may not be possible.Destiny
Well, even if you use multiple package tools, I think you can automate their package creation with the likes of Paver. So, once you get everything set up intially, you can just run build script with Paver.Arhat

© 2022 - 2024 — McMap. All rights reserved.