Locales not imported with PyInstaller
- Dominant language
- Python
- Stars
- 226
- Forks
- 38
- PR merge metrics
- No merged PRs in 30d
Description
Example:
```python
import time
import timeago
timestamp = time.time() - 30
print(timeago.format(timestamp))
```
PyInstaller command:
```sh
$ pyinstaller -F -c --noupx -i NONE main.py
```
Output:
```
Traceback (most recent call last):
File "timeago\locales\__init__.py", line 25, in timeago_template
ModuleNotFoundError: No module named 'timeago.locales.en'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 7, in
print(timeago.format(timestamp))
File "timeago\__init__.py", line 80, in format
File "timeago\locales\__init__.py", line 29, in timeago_template
[28604] Failed to execute script 'main' due to unhandled exception!
```
Python 3.10.1
PyInstaller 4.8
timeago 1.0.15
The [PyInstaller documentation](https://pyinstaller.readthedocs.io/en/stable/hooks.html#providing-pyinstaller-hooks-with-your-package) provides examples of how to add hooks for hidden imports. There is also an [example package repo](https://github.com/pyinstaller/hooksample).
A temporary workaround is to add each locale module manually using `--hidden-import 'timeago.locales.'`
I haven't worked with PyInstaller hooks, but it looks easy to implement. I can try to make a PR if needed when I look at it further.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.