pyinstaller / pyinstaller-hooks-contrib

Community maintained hooks for PyInstaller.
Other
96 stars 126 forks source link

Hook for tzwhere (fork) #771

Closed davetapley closed 3 months ago

davetapley commented 4 months ago

Which library is the hook for?

tzwhere ...

... but I'm using this fork for currently unmerged

Have you gotten the library to work with pyinstaller?

No, I'm getting:

FileNotFoundError: [Errno 2] No such file or directory: '/workspaces/ng/dist/ng/_internal/tzwhere/tz_world.json.gz'

I tried:

binaries=[('/usr/local/python/3.12.2/lib/python3.12/site-packages/tzwhere/tz_world.json.gz', '_internal/tzwhere/')],

But same error.

Help / advice welcome!

bwoodsend commented 4 months ago

What about:

binaries=[('/usr/local/python/3.12.2/lib/python3.12/site-packages/tzwhere/tz_world.json.gz', 'tzwhere')],
davetapley commented 3 months ago

@bwoodsend yes! Thanks, needed one more and then it worked:

        ('/usr/local/python/3.12.2/lib/python3.12/site-packages/tzwhere/tz_world.json.gz', 'tzwhere'),
        ('/usr/local/python/3.12.2/lib/python3.12/site-packages/tzwhere/tz_world_shortcuts.json', 'tzwhere')

Happy to make a PR but skimming the docs I don't see:

  1. How to add reference to a binary (presumably in a site-packages location agnostic way), and:
  2. Guidance for requirements-test-libraries.txt when the package is broken upstream pending merging a fork https://github.com/pegler/pytzwhere/pull/62

Thanks again 🙏🏻

rokm commented 3 months ago
# hook-tzwhere.py
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('tzwhere')

You are not collecting binaries, but data files (not that the distinction matters that much with contemporary PyInstaller versions).

bwoodsend commented 3 months ago

Guidance for requirements-test-libraries.txt when the package is broken upstream pending merging a fork https://github.com/pegler/pytzwhere/pull/62

It doesn't really matter since the project seems too abandoned to ever release again. The tests only run when the version in the requirements-test-libraries.txt changes so if you put the latest version in now, CI will run on your pull request and fail although we can work around that by doing a one-shot run (see the collapsed section under CI/CD) where you give the https://github.com/domas-v/pytzwhere/archive/refs/heads/fix/numpy_version_compatibility.zip as the package name. After that though, unless pytzwhere comes back from the dead, the test will never run again.

To that end, I won't object if you skip the test+CI stuff.

rokm commented 3 months ago

To that end, I won't object if you skip the test+CI stuff.

Yeah, I agree. Maybe add an import test (or whatever is required to show that data files need to be collected), but do not add tzwhere to requirements file.