[issue45427] importlib.readers.MultiplexedPath

David Rajaratnam report at bugs.python.org
Mon Oct 18 01:03:38 EDT 2021


David Rajaratnam <daver at gemarex.com.au> added the comment:

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

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45427>
_______________________________________


More information about the Python-bugs-list mailing list