Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python's setup.py: how to install different files for different platforms

I'm writing a cross-platform package which need to include different binary file for different platforms (e.g. Linux/MAC OS/Windows and even 32bit/64bit Windows)

I need my package's setup.py to install different binary data files based on the platform. The problem is that I need the data files for all platforms to be included in the package where they may have the same name but different content.

Can someone suggest how to do it using distutils / setuptools setup.py?

like image 973
Uri Cohen Avatar asked Nov 05 '22 13:11

Uri Cohen


1 Answers

It's not too hard, at least in simple cases: you can for instance see how the setup.py of the uncertainties Python package does it (it selects an install directory based on the version of Python, but you would simply check sys.platform and friends, in your case).

The key lines are

if sys.version_info >= (2, 5):
    package_dir = 'uncertainties-py25'
else:
    package_dir = 'uncertainties-py23'

and

distutils.core.setup(
    …
    # Where to find the source code:
    package_dir={'uncertainties': package_dir},
    …
)
like image 188
Eric O Lebigot Avatar answered Nov 15 '22 07:11

Eric O Lebigot