I have a python module with a setup like this:
from distutils.core import setup
setup = (
...
package_data={'mypackage': ['my/file.data']})
in a package laid out like this:
mypackage/
setup.py
mypackage/
__init__.py
my/
file.data
and __init__.py looks something like this:
import pkgutil
DATA = pkgutil.get_data(__name__, 'my/file.data')
Pretty simple. All I want is to get some data into my python plugin. However, when I install it with
sudo python setup.py install
and try to run it, I get
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/mypackage/my/file.data'
It's been installed with incorrect permissions.
How do I distribute data and config files in python such that they can be read at runtime?
I’m afraid you can’t do that out of the box: if I recall correctly file permissions are just copied as is. You’d need to write a custom build command to change the file rights in the build directory before they are copied by the install command.
The simplest solution would be to have the desired rights in your repository or source tree.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With