Skip to content

Commit

Permalink
Make pylibmagic import optional
Browse files Browse the repository at this point in the history
I was trying to use the galaxy-data container for data source tools,
but it fails with:
```
Traceback (most recent call last):
  File "/Users/mvandenb/src/galaxy/test/functional/tools/data_source.py", line 13, in <module>
    from galaxy.datatypes import sniff
  File "/usr/local/lib/python3.12/site-packages/galaxy/datatypes/sniff.py", line 40, in <module>
    import pylibmagic  # noqa: F401  # isort:skip
    ^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pylibmagic'
```
pylibmagic is just shipping the magic library and adds it to path,
but that's not needed for the data-data container which can use magic
just fine.
  • Loading branch information
mvdbeek committed Sep 14, 2024
1 parent 4a5b3dd commit b6d0d51
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/galaxy/datatypes/sniff.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
)
from galaxy.util.path import StrPath

import pylibmagic # noqa: F401 # isort:skip
try:
import pylibmagic # noqa: F401 # isort:skip
except ImportError:
# Not available in conda, but docker image contains libmagic
pass
import magic # isort:skip


Expand Down

0 comments on commit b6d0d51

Please sign in to comment.