indygreg / PyOxidizer

A modern Python application packaging and distribution tool
Mozilla Public License 2.0
5.36k stars 232 forks source link

Accessing __file__ from certifi and pytz #91

Open crabhi opened 5 years ago

crabhi commented 5 years ago

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:

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.

indygreg commented 5 years ago

Issues with __file__ are issues with the 3rd party Python package. See #69 for more details.

We already have an issue on file for certifi (#73). I also believe there's another issue floating around for problems with pytz...

crabhi commented 5 years ago

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:

  1. Create a PyOxidizer project with pyoxidizer init test
  2. Add a pip-install-simple rule to pyoxidizer.toml with the certifi package.
  3. Build the project.
  4. In the repl, try to access cacert.pem from certifi with any of pkgutil, pkg_resources or importlib.resources. It doesn't work. If I install certifi into an empty Python virtualenv without PyOxidizer, all of the methods give me the data.
crabhi commented 5 years ago

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.

jeamland commented 4 years ago

https://github.com/certifi/python-certifi/pull/116