masaccio / numbers-parser

Python module for parsing Apple Numbers .numbers files
MIT License
208 stars 15 forks source link

3.9.1 dependency issues #46

Closed SheetJSDev closed 1 year ago

SheetJSDev commented 2 years ago

When trying to install globally (sudo -H python3 -m pip install numbers_parser) there were a few missing deps:

1) the package depends on poetry. Installation error:

...
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'poetry'

Looking at the current tarball (https://files.pythonhosted.org/packages/8e/d4/d32d8935fc3a3fbe777e988925e3bf3b60e0daa45f7b9d8a7fe689f4fb84/numbers_parser-3.9.1.tar.gz) the setup.py does not reference poetry dependency:

2) the package depends on libmagic. Runtime error:

  File "/usr/local/lib/python3.10/site-packages/numbers_parser/model.py", line 23, in <module>
    from numbers_parser.cell import (
  File "/usr/local/lib/python3.10/site-packages/numbers_parser/cell.py", line 1, in <module>
    import magic
  File "/usr/local/lib/python3.10/site-packages/magic/__init__.py", line 209, in <module>
    libmagic = loader.load_lib()
  File "/usr/local/lib/python3.10/site-packages/magic/loader.py", line 49, in load_lib
    raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation

This was resolved with brew install libmagic.

masaccio commented 2 years ago

I'm unsurprised by the dependency on libmagic (I'll add it to the readme as a binary dependency) but poetry failing is a surprise. Seems like poetry has created an installer that relies upon poetry being installed.

So pip install poetry is the obvious fix but really should not be required.

masaccio commented 2 years ago

It's all clean in a virtual environment and sanitised PATH

% python3 -m venv venv-numbers-parser
% export PATH=/usr/bin:/bin
% source venv-numbers-parser/bin/activate
(venv-numbers-parser) % pip install numbers-parser
Collecting numbers-parser
  Using cached numbers_parser-3.9.3-py3-none-any.whl (278 kB)
Collecting compact-json<2.0.0,>=1.1.3
  Using cached compact_json-1.1.3-py3-none-any.whl
Collecting pendulum<3.0.0,>=2.1.2
  Using cached pendulum-2.1.2-cp311-cp311-macosx_13_0_arm64.whl
Collecting protobuf<5.0.0,>=4.21.1
  Using cached protobuf-4.21.9-cp37-abi3-macosx_10_9_universal2.whl (483 kB)
Collecting python-magic<0.5.0,>=0.4.27
  Using cached python_magic-0.4.27-py2.py3-none-any.whl (13 kB)
Collecting python-snappy<0.7.0,>=0.6.1
  Using cached python_snappy-0.6.1-cp311-cp311-macosx_13_0_arm64.whl
Collecting regex<2023.0.0,>=2022.9.13
  Using cached regex-2022.10.31-cp311-cp311-macosx_11_0_arm64.whl (287 kB)
Collecting roman<4.0,>=3.3
  Using cached roman-3.3-py2.py3-none-any.whl (3.9 kB)
Collecting python-dateutil<3.0,>=2.6
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting pytzdata>=2020.1
  Using cached pytzdata-2020.1-py2.py3-none-any.whl (489 kB)
Collecting six>=1.5
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: python-snappy, six, roman, regex, pytzdata, python-magic, protobuf, compact-json, python-dateutil, pendulum, numbers-parser
Successfully installed compact-json-1.1.3 numbers-parser-3.9.3 pendulum-2.1.2 protobuf-4.21.9 python-dateutil-2.8.2 python-magic-0.4.27 python-snappy-0.6.1 pytzdata-2020.1 regex-2022.10.31 roman-3.3 six-1.16.0

[notice] A new release of pip available: 22.3 -> 22.3.1
[notice] To update, run: pip install --upgrade pip

I also sudo'd to a new shell and cleaned PATH to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin and could pip install without an error. Poetry is only installed in my home directory so I don't understand where your error comes from.

On libmagic, I've decided to remove the image_type property since it's trivial for a caller to test this given the image data.

Woolwit commented 1 year ago

Sorry, I'm not a sophisticated coder. I'm in a venv. Python 3.9.12 Just FYI...

ImportError: failed to find libmagic.  Check your installation
(landers) user@Users-Mac afterDan % pip install libmagic      
Requirement already satisfied: libmagic in ./landers/lib/python3.9/site-packages (1.0)
masaccio commented 1 year ago

Sorry, I'm not a sophisticated coder. I'm in a venv. Python 3.9.12 Just FYI...

ImportError: failed to find libmagic.  Check your installation
(landers) user@Users-Mac afterDan % pip install libmagic      
Requirement already satisfied: libmagic in ./landers/lib/python3.9/site-packages (1.0)

You don’t need libmagic unless you are running tests in a dev environment. It’s most easily installed using Homebrew on a Mac and is installed by default on Linux.

Also when you say you’re using venv, the dev environment uses Poetry to manage environments.

What were you looking to do?

Woolwit commented 1 year ago

Thanks, I'm experimenting with reading Mac .numbers files using pandas. That's where I got the error (in a virtual environment and using VS Code). I've since exported the .numbers file in an excel format and am not having issues.

masaccio commented 1 year ago

Odd as I only use python-magic in tests. But if you do need it, you will need the binary library it depends upon which is where Homebrew is needed.