Suppose I have a package that calls an executable file somewhere in the code (for example, a third-party c / java program). Suppose further that the application is small / trivial enough to bundle with a bundle. For example, one executable file ( cfoo ).
I could go ahead and put the files in the following structure:
. |-- foo | |-- __init__.py | |-- __init__.pyc | |-- core.py | |-- corebin | | `-- cfoo | `-- foomain.py `-- setup.py
And prepare setup.py as follows:
from setuptools import setup setup( name='foo', version='1.0', packages=['foo'], scripts=['foo/foomain.py'], package_data={'foo': ['corebin/*']}, zip_safe=False )
This will allow me to install the package correctly. Later in batch code I could do this:
from subprocess import call import pkg_resources as res def main(): fn = res.resource_filename('foo', 'corebin/cfoo') print "Resource located at:", fn call([fn])
Unfortunately, the executable will be installed without the flag set. Even if the source file was installed. Adding a chmod call at the end of the setup.py script is not so simple, as you first need to figure out the correct installation path. I tried with resource_filename , but returned a local file (as in the "preinstall").
How to solve this problem? Also subject to virtualenv ...
source share