ahupp / python-magic

A python wrapper for libmagic
Other
2.6k stars 280 forks source link

Version 0.4.23 breaks libmagic detection on Alpine 3 #247

Closed Routhinator closed 3 years ago

Routhinator commented 3 years ago

Hi,

As of the new version 0.4.23 that dropped today, a regression has been introduced, breaking libmagic detection on Alpine 3:

  File "/usr/local/lib/python3.8/site-packages/magic/loader.py", line 44, in load_lib
    raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation

Rolling back to 0.4.22 fixes.

anushbmx commented 3 years ago

Yes same issue in alpine, reverting back to 0.4.22.

marko-tuononen commented 3 years ago

Also suffering this, reverting back to 0.4.22

ahupp commented 3 years ago

I reverted that specific case because the Alpine 3 docker test was passing. Can someone give me details about how to reproduce this?

shubb30 commented 3 years ago

Can be replicated using Docker

$ docker run -it python:3.8-alpine3.12 sh
# apk add --no-cache py3-magic
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/3) Installing python3 (3.8.10-r0)
(2/3) Installing libmagic (5.38-r0)
(3/3) Installing py3-magic (0.4.18-r0)
Executing busybox-1.31.1-r20.trigger
OK: 62 MiB in 38 packages

# pip3 install python-magic==0.4.23
Collecting python-magic==0.4.23
  Downloading python_magic-0.4.23-py2.py3-none-any.whl (12 kB)
Installing collected packages: python-magic
Successfully installed python-magic-0.4.23
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv

# python
Python 3.8.10 (default, May  4 2021, 19:15:20)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/magic/__init__.py", line 208, in <module>
    libmagic = loader.load_lib()
  File "/usr/local/lib/python3.8/site-packages/magic/loader.py", line 44, in load_lib
    raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation
>>>

# pip3 install python-magic==0.4.22
Collecting python-magic==0.4.22
  Downloading python_magic-0.4.22-py2.py3-none-any.whl (12 kB)
Installing collected packages: python-magic
  Attempting uninstall: python-magic
    Found existing installation: python-magic 0.4.23
    Uninstalling python-magic-0.4.23:
      Successfully uninstalled python-magic-0.4.23
Successfully installed python-magic-0.4.22
WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv

# python
Python 3.8.10 (default, May  4 2021, 19:15:20)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import magic
>>>
ahupp commented 3 years ago

The docker test uses the alpine:3 image. Not sure why that's behaving differently from the python:3.8-alpine3.12 image here. Either way, fixed in 0.4.24 and now the test uses python:3.8-alpine3.12

ahupp commented 3 years ago

4ed6b038ba8acd59ed58c888fbd18355b8955eba