GitHub
11/14/2024, 10:59 PMPath(__file__) with importlib_resources to support Meltano zipapp
Issue created by WillDaSilva
https://docs.python.org/3/library/importlib.resources.html
This module leverages Python’s import system to provide access to resources within packages. If you can import a package, you can access resources within that package. Resources can be opened or read, in either binary or text mode.
Resources are roughly akin to files inside directories, though it’s important to keep in mind that this is just a metaphor. Resources and packages do not have to exist as physical files and directories on the file system: for example, a package and its resources can be imported from a zip file using zipimport.Currently Meltano makes use of
pathlib.Path(__file__) in 3 locations under src/meltano. These paths are incorrect when Meltano is running as a zipapp. To access the contents the paths would normally refer to in all cases, importlib.resources must be used. To support older versions of Python, the official backport importlib_resources should be used instead: https://github.com/python/importlib_resources
This backport is already a dependency of Meltano, so all that remains is to make us of it.
CC @aaronsteers because of your interest in zipapps. From what I've heard this is a moderately widespread issue with them, but at least we can do our part to make sure Meltano runs properly as one.
meltano/meltanoGitHub
11/14/2024, 10:59 PMPath(__file__) with importlib_resources to support Meltano zipapp
Issue closed as completed by edgarrmondragon
meltano/meltano