File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed
Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 1+ # Production Dockerfile for LangExtract with libmagic support
2+ FROM python:3.10-slim
3+
4+ # Install system dependencies including libmagic
5+ RUN apt-get update && apt-get install -y --no-install-recommends \
6+ libmagic1 \
7+ && rm -rf /var/lib/apt/lists/*
8+
9+ # Set working directory
10+ WORKDIR /app
11+
12+ # Install LangExtract from PyPI
13+ RUN pip install --no-cache-dir langextract
14+
15+ # Set default command
16+ CMD ["python" ]
Original file line number Diff line number Diff line change @@ -181,6 +181,12 @@ pip install -e ".[dev]"
181181pip install -e " .[test]"
182182```
183183
184+ ### Docker
185+
186+ ``` bash
187+ docker build -t langextract .
188+ docker run --rm -e LANGEXTRACT_API_KEY=" your-api-key" langextract python your_script.py
189+ ```
184190
185191## API Key Setup for Cloud Models
186192
@@ -297,6 +303,12 @@ Or reproduce the full CI matrix locally with tox:
297303tox # runs pylint + pytest on Python 3.10 and 3.11
298304```
299305
306+ ## Troubleshooting
307+
308+ ** libmagic error** : If you see "failed to find libmagic", install with ` pip install langextract[full] ` or install system dependencies:
309+ - Ubuntu/Debian: ` sudo apt-get install libmagic1 `
310+ - macOS: ` brew install libmagic `
311+
300312## Disclaimer
301313
302314This is not an officially supported Google product. If you use
Original file line number Diff line number Diff line change 1616
1717from __future__ import annotations
1818
19+ # Ensure libmagic is available before langfun imports python-magic.
20+ # pylibmagic provides pre-built binaries that python-magic needs.
21+ try :
22+ import pylibmagic # noqa: F401 (side-effect import)
23+ except ImportError :
24+ pass
25+
1926from collections .abc import Iterable , Sequence
2027import os
2128from typing import Any , Type , TypeVar , cast
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ build-backend = "setuptools.build_meta"
1818
1919[project ]
2020name = " langextract"
21- version = " 1.0.0 "
21+ version = " 1.0.1 "
2222description = " LangExtract: A library for extracting structured data from language models"
2323readme = " README.md"
2424requires-python = " >=3.10"
@@ -41,6 +41,7 @@ dependencies = [
4141 " pydantic>=1.8.0" ,
4242 " python-dotenv>=0.19.0" ,
4343 " python-magic>=0.4.27" ,
44+ " pylibmagic>=0.5.0" ,
4445 " requests>=2.25.0" ,
4546 " tqdm>=4.64.0" ,
4647 " typing-extensions>=4.0.0"
@@ -64,6 +65,10 @@ test = [
6465 " pytest>=7.4.0" ,
6566 " tomli>=2.0.0"
6667]
68+ full = [
69+ " python-magic>=0.4.27" ,
70+ " pylibmagic>=0.5.0" ,
71+ ]
6772
6873[tool .setuptools ]
6974packages = [" langextract" ]
You can’t perform that action at this time.
0 commit comments