pendulum icon indicating copy to clipboard operation
pendulum copied to clipboard

pendulum does not seem to be compatible with zipapp

Open sbstp opened this issue 4 years ago • 3 comments

The new zipapp module permits one to create a bundled python program inside of a zip file. I went ahead and made such a program but I have an issue when I try to execute it, it seems like pendulum is not able to locate the locale files.

    import pendulum
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "dist/bobctl.pyz/pendulum/__init__.py", line 9, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "dist/bobctl.pyz/pendulum/datetime.py", line 11, in <module>
    def _cmp(x, y):
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "dist/bobctl.pyz/pendulum/date.py", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
  File "dist/bobctl.pyz/pendulum/helpers.py", line 43, in <module>
  File "dist/bobctl.pyz/pendulum/formatting/difference_formatter.py", line 12, in __init__
  File "dist/bobctl.pyz/pendulum/locales/locale.py", line 38, in load
    
ValueError: Locale [en] does not exist.

sbstp avatar Dec 23 '19 23:12 sbstp

Where u ever able to fix that?

OmarSultan85 avatar Aug 26 '21 23:08 OmarSultan85

It's been a really long time. I think I ended up using pyinstaller.

sbstp avatar Aug 26 '21 23:08 sbstp

I don't think it is possible to package pendulum into a zipapp because pendulum includes C extensions. As per "Caveats" (https://docs.python.org/3.9/library/zipapp.html#caveats), packages with C extensions cannot be used in zipapp.

Dmitrii-I avatar Nov 10 '21 23:11 Dmitrii-I

You could build a pure-python version from source if you really need to. I don't think we will be providing non-C wheels. I consider this issue resolved.

Secrus avatar Aug 07 '22 14:08 Secrus

You could build a pure-python version from source if you really need to. I don't think we will be providing non-C wheels. I consider this issue resolved.

Actually simply building from source is not enough since an extension is still created and zipapp does not work with extensions. So this won't work: pip install --no-binary :all: pendulum

What may work is installing pendulum without extensions: PENDULUM_EXTENSIONS=0 pip install --no-binary :all: pendulum.

Dmitrii-I avatar Aug 08 '22 12:08 Dmitrii-I

You could build a pure-python version from source if you really need to. I don't think we will be providing non-C wheels. I consider this issue resolved.

Actually simply building from source is not enough since an extension is still created and zipapp does not work with extensions. So this won't work: pip install --no-binary :all: pendulum

What may work is installing pendulum without extensions: PENDULUM_EXTENSIONS=0 pip install --no-binary :all: pendulum.

That is exactly what I meant by building pure-python version from source

Secrus avatar Aug 08 '22 12:08 Secrus