hustcc / timeago

:hourglass: Simple library used to format datetime with `*** time ago` statement. eg: "3 hours ago".
http://timeago.org
MIT License
224 stars 37 forks source link

Pyinstaller hook #41

Open alexitx opened 2 years ago

alexitx commented 2 years ago

Added a hook for PyInstaller to package the dynamically imported locales (#40)

laurentmmeyer commented 2 years ago

Thank you very much for the PR. We reviewed it (@gr0uch0dev and I) and we have few questions:

alexitx commented 2 years ago

Is there a way we can have your the pyinstaller locales list in one place instead of updating the README and the pyinstaller for every release? Like one single truth?

There can be a globally defined constant containing all available locales which can even be used by the import mechanism in timeago.locales.timeago_template but the README still has to be updated manually. For example:

locale = 'en'
if locale in LOCALES:
    # Import the locale module and use it
else:
    # Fall back to default locale or raise exception

But after taking another look at the timeago.locales package, there is a lot that can be improved outside of this PR.

This would be a major overhaul of the whole timeago library to make it easier to maintain. Not sure if everyone would agree with such changes.

Can you provide the command to run the pyinstaller? We found pyinstaller -F -c --noupx -i None but we're not sure how it is supposed to play.

I gave some sample code and the PyInstaller command in #40 which demonstrates the issue. With this PR it should print the properly formatted string because all the locales are known to PyInstaller, otherwise they can't be imported because they aren't bundled with the produced executable.

lolobosse commented 2 years ago

Hi @alexitx,

Thanks a lot for the exhaustive feedback, you're right, we would need a rewrite and a simplification.

I'll get on it as soon as I get time, I might write some specs at some point in some issues.

About PyInstaller, I think that I need to run it on a Windows machine as everything is working on my Mac