-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embed resource files in final package at a given location #2267
Comments
Hello @theunkn0wn1, maybe there is a use case for your feature request. But the one you are showing isn't. The correct way to get access to the metadata of a package during runtime is to use importlib.metadata (or importlib_metadata for python <3.8)
So could you imagine other use cases? fin swimmer |
@finswimmer @stephsamson Is there no current way to include resource files that are not in a package? I'd like to include a changelog.md so it can be summarized when the package runs. This is a more obscure use case, but I also have a self-hosting code that needs to store its own config setup, including its own pyproject.toml. |
What about including a JAR file? |
What about including a schema.json to be used by jsonschema? Sure, as a work-around, I can embed the schema into a string... But what if I want to include image resources in my package? etc.. |
Resource files (in short: file that is not a Python file) that you wish to install and access at run time have to be part of an importable package. They can then be accessed with |
Just to be explicit about this. When I changed my access to a file from using |
I think this thread sums up the full situation about including and/or excluding things of the sdist and/or wheel: #3380 |
I would love this feature. I have a package with a C extension where I would like to the copy the folder of header files inside the wheel and sdist during build time. Currently I have no way of doing this. I don't want to keep the header files in the python package folder since they don't belong there. |
Funnily enough that was my initial inpetus to request this feature: compiled modules. I have two projects which have generated files, which I do not wish to place in-line with the non-generated sources as they don't belong there. |
Closing this as a duplicate of #4583 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
From @theunkn0wn1
The feature I would like to see out of this is to be able to embed resource files into the wheel (and subsequently the installed package) at an arbitrary location.
For instance, in my project i would like to embed the
pyproject.toml
into the installed sources so the library may access this resource at runtime. I wish to do this to access the version string contained in thepyproject.toml
.Presently, even if the
tool.poetry.include
directive is used the file does not end up in the installation directory and is consequently not usable to the installed application.My application has the structure
What I would like to do is copy, at build time,
/pyproject.toml
to/src/pyproject.toml
so it may be included in the wheel and usable a resource viaimportlib.resources
.The text was updated successfully, but these errors were encountered: