Skip to content

Commit 3bcf5f7

Browse files
committed
fix: make python-magic import graceful on Windows (avoids segfault when libmagic missing)
- Wrap import magic in try/except so the module can be imported on Windows without libmagic installed. - Guard _identify MIME-type lookup — returns None (falling back to extension matching) when magic is unavailable. - CI: skip --extras dbc and pre-commit on Windows. - CI: per-OS timeout (30 m Windows, 15 m Linux). - CI: guard Pages deployment steps behind refs/heads/main to avoid failure on PRs from forks. - Coverage: omit pysus/management/client.py and pysus/tui/*.
1 parent 99c8e34 commit 3bcf5f7

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

pysus/api/extensions.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
from typing import ClassVar
1515

1616
import chardet
17-
import magic
17+
18+
try:
19+
import magic
20+
except (ImportError, OSError):
21+
magic = None # type: ignore[assignment]
22+
1823
import pandas as pd
1924
import pyarrow as pa
2025
import pyarrow.parquet as pq
@@ -832,6 +837,8 @@ class ExtensionFactory:
832837
@classmethod
833838
async def _identify(cls, path: Path) -> type[BaseLocalFile] | None:
834839
"""Identify the file class by its MIME type."""
840+
if magic is None:
841+
return None
835842
try:
836843
mime = await to_thread.run_sync(
837844
magic.from_file,

0 commit comments

Comments
 (0)