Let's assume I have a package which calls an executable file somewhere in the code (for example a third-party c/java-program). Let's further assume, the application is small/trivial enough to bundle with the package. For example a single executable file (cfoo).
I could go ahead, and put the files into the following structure:
.
|-- foo
| |-- __init__.py
| |-- __init__.pyc
| |-- core.py
| |-- corebin
| | `-- cfoo
| `-- foomain.py
`-- setup.py
And prepare a 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 properly install the package. Later, in the package-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 file will be installed without executable flag set. Even if the original file had it set. Adding a chmod call at the end of the setup.py script is not as easy, as one would need to figure out the proper installation path first. I tried with resource_filename but that returned the local file (as in "pre-installation").
How can this problem be solved? Also with virtualenv in mind...
.tar.gzdistribution, or one of those old deprecated.eggdistributions? Because this might at some point involve the question of which archive formats preserve which file attributes on while operating systems. :)scriptskeyword, it will get the correct mode (and get installed in an appropriatebin/directory).