Accessing __file__ from certifi and pytz
crabhi opened this issue · 4 comments
Hi, this tool looks very good. I'm trying to package my first app. Unfortunately, it depends on certifi
and pytz
.
I can't find a way to access the files bundled with the modules.
I've tried:
pkgutil.get_data('certifi', 'cacert.pem')
->None
importlib.resources.read_binary('certifi', c 'cacert.pem')
->FileNotFoundError: Package has no location <module 'certifi' (<PyOxidizerFinder object at 0x7fd94a6bb558>)>
import pkg_resources
->ModuleNotFoundError: No module named 'pkg_resources'
I haven't tried the __loader__
method yet because it means I have to fork the dependencies. At least with certifi
, I thought I could monkey-patch it.
I donl't like much the app-relative:lib
install location because that complicates the distribution and updates of the app.
Thanks for your response. I've missed the issue #69. I'm not sure if this particular problem falls under that umbrella, though.
I tried to patch certifi
and pytz
locally. I was using pkgutil
but I didn't get any data.
I've tried it also with a clean build:
- Create a PyOxidizer project with
pyoxidizer init test
- Add a
pip-install-simple
rule topyoxidizer.toml
with thecertifi
package. - Build the project.
- In the repl, try to access
cacert.pem
fromcertifi
with any ofpkgutil
,pkg_resources
orimportlib.resources
. It doesn't work. If I installcertifi
into an empty Python virtualenv without PyOxidizer, all of the methods give me the data.
If you feel #69 is more appropriate for this discussion, I'll move it there. If you have any pointers to how to load such bundled file, it would be much appreciated.