This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author daveraja
Recipients FFY00, daveraja, eric.smith, jaraco
Date 2021-10-18.05:03:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634533418.94.0.615488401338.issue45427@roundup.psfhosted.org>
In-reply-to
Content
Hi Filipe,

Thanks very much for the pointers and for the clarifications. I'll look at using importlib.resources.as_file(). I think this is the API that I stupidly seemed to have missed!

However, it is also very possible that I am misunderstanding the correct usage of the importlib.resource library, so here is a summary of my use-case:

I am working with a specialised language interpreter that can be embedded in python. The interpreter API requires a file system path to load files and the language itself has its own "include" statements for loading files. So in my case it has to be a file system path and not some other resource (eg. zip file or database).

However, I have struggled to understand what is the correct way to treat these files when installed as part of a python package. It seems to me that python's setuptools is too limited to cover the range of options that I would want. AFAIK setuptools allows only two options for installing non-python files; "data_files" and "package_data". "data_files" doesn't seem to be the right place because I couldn't find a full-proof way to programmatically find out where these files are installed. So it seems to be focused more on supplementary data (high-level docs, examples, etc) rather than data files that are necessary for the operations of the application.

On the other hand "package_data" forces these non-python files to be embedded within the python package structure. This is a bit ugly since its not really a natural fit; for example the language has its own command-line tools that I use during development.

So what I've tried to do is that for development I separate the python code from my other interpreter's code, but then for installation have setup.py map the specialised language files into the python package structure. I'm not overly happy with how I've done it (although it does seem to work),so I would be very happy if someone can point to a better way.

Dave
History
Date User Action Args
2021-10-18 05:03:38daverajasetrecipients: + daveraja, jaraco, eric.smith, FFY00
2021-10-18 05:03:38daverajasetmessageid: <1634533418.94.0.615488401338.issue45427@roundup.psfhosted.org>
2021-10-18 05:03:38daverajalinkissue45427 messages
2021-10-18 05:03:38daverajacreate