selectolax icon indicating copy to clipboard operation
selectolax copied to clipboard

Add pyinstaller hooks?

Open baseplate-admin opened this issue 1 year ago • 3 comments

Hi, it seems that selectolax doesn't work with pyinstaller due to it's Cython codes.

Projects that use hybrid ( python + other language ) approach has to include hooks to allow the projects to be built properly.

For example

If i somehow add selectolax into hidden_import, i get this error

PyInstaller\hooks\rthooks\pyi_rth_pkgres.py:36: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
Traceback (most recent call last):
  File "cli.py", line 2, in <module>
  File "builder\staff.py", line 2, in <module>
  File "selectolax\__init__.py", line 10, in <module>
ImportError: cannot import name 'modest' from partially initialized module 'selectolax' (most likely due to a circular import) (C:\Users\baseplate-admin\AppData\Local\Temp\_MEI235082\selectolax\__init__.pyc)
[30172] Failed to execute script 'cli' due to unhandled exception!

On inspection of the build dir, it seems that pyc files are not build included image

baseplate-admin avatar Aug 01 '24 16:08 baseplate-admin

Good idea. Are you familiar with hooks?

rushter avatar Aug 02 '24 09:08 rushter

Good idea. Are you familiar with hooks?

Unfortunately i am not very familiar with hooks.

But the maintainer of pyinstaller replied in this discussion on how this can be added.

https://github.com/orgs/pyinstaller/discussions/8703#discussioncomment-10220874

baseplate-admin avatar Aug 02 '24 13:08 baseplate-admin

from PyInstaller.utils.hooks import collect_data_files

datas = collect_data_files("selectolax")

Adding this file to selectolax/_pyinstaller/hook-selectolax.py did the trick

baseplate-admin avatar Aug 02 '24 13:08 baseplate-admin

Added it

rushter avatar Aug 28 '24 17:08 rushter