indygreg/PyOxidizer

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.

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...

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.

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.