Skip to content

Commit f41359b

Browse files
committed
feat(package): remove the need of the libffi-dev requirement on pyreaddbc
1 parent 5cb4058 commit f41359b

7 files changed

Lines changed: 2677 additions & 2285 deletions

File tree

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
pip install poetry poetry-plugin-export
3535
poetry config virtualenvs.create false
3636
if [ "${{ runner.os }}" = "Linux" ]; then
37-
poetry install --without dev --extras dbc
37+
poetry install --without dev
3838
pip install pre-commit
3939
else
4040
poetry install --without dev

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ PySUS is a Python package for accessing and analyzing Brazil's public health dat
2020
pip install pysus
2121
```
2222

23-
For DBC file support (requires libffi):
24-
```bash
25-
# Ubuntu/Debian
26-
sudo apt install libffi-dev
27-
pip install pysus[dbc]
28-
```
29-
3023
For the terminal user interface (TUI):
3124
```bash
3225
pip install pysus[tui]

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ COPY docker/scripts/entrypoint.sh /entrypoint.sh
2929
COPY docker/notebooks/ /home/pysus/Notebooks/
3030

3131
RUN pip install poetry \
32-
&& cd /usr/src && poetry config virtualenvs.create false && poetry install --with docs --extras dbc \
32+
&& cd /usr/src && poetry config virtualenvs.create false && poetry install --with docs \
3333
&& pip install 'httpx<0.28' \
3434
&& chown -R pysus:pysus /home/pysus
3535

docs/source/installation.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@ The simplest way to install PySUS is via pip:
1414
Extras
1515
^^^^^^
1616

17-
For DBC file support (requires ``libffi``):
18-
19-
.. code-block:: bash
20-
21-
# Ubuntu/Debian
22-
sudo apt install libffi-dev
23-
pip install pysus[dbc]
24-
2517
For the terminal user interface (TUI):
2618

2719
.. code-block:: bash

poetry.lock

Lines changed: 2666 additions & 2246 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,15 @@ httpx = ">=0.28.0"
3838
aioftp = "^0.21.4"
3939
dbfread = "2.0.7"
4040
bigtree = "^0.12.2"
41-
42-
pyreaddbc = { version = ">=1.1.0", optional = true }
43-
pycparser = { version = "2.21", optional = true }
44-
textual = { extras = ["syntax"], version = "^8.2.1", optional = true }
45-
humanize = { version = "^4.8.0", optional = true }
41+
pyreaddbc = ">=2.0.4"
4642
dotenv = "^0.9.9"
4743
boto3 = "^1.42.89"
4844
typer = "^0.24.1"
4945

46+
humanize = { version = "^4.8.0", optional = true }
47+
textual = { extras = ["syntax"], version = "^8.2.1", optional = true }
48+
5049
[tool.poetry.extras]
51-
dbc = ["pyreaddbc", "pycparser"]
5250
tui = ["textual", "humanize"]
5351

5452
[tool.poetry.group.dev.dependencies]

pysus/api/extensions.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
import asyncio
44
import csv
5-
import ctypes.util
65
import gzip
76
import shutil
8-
import sys
97
import tarfile
108
import zipfile
119
from collections.abc import AsyncGenerator, Callable
@@ -26,16 +24,9 @@
2624
from .types import FileType
2725

2826
try:
29-
LIBFFI = True
30-
if sys.platform.startswith("linux"):
31-
LIBFFI = ctypes.util.find_library("ffi") is not None
27+
from pyreaddbc import dbc2dbf
3228

33-
if LIBFFI:
34-
from pyreaddbc import dbc2dbf
35-
36-
DBC_IMPORT = True
37-
else:
38-
DBC_IMPORT = False
29+
DBC_IMPORT = True
3930
except ImportError:
4031
DBC_IMPORT = False
4132

@@ -781,14 +772,12 @@ def _extract():
781772
return list(await asyncio.gather(*tasks))
782773

783774

784-
class FTPNotImported(BaseTabularFile):
775+
class DBCNotImported(BaseTabularFile):
785776
"""Placeholder for DBC files when optional dependency is not installed."""
786777

787778
path: Path = Field(default_factory=lambda: Path("..."))
788779
type: str | FileType = Field(default="remote")
789-
import_err: ClassVar[
790-
str
791-
] = """
780+
import_err: ClassVar[str] = """
792781
run "pip install pysus[dbc]" to handle DBC files.
793782
Make sure you also have libffi installed on the system. It may not work
794783
on Windows
@@ -872,7 +861,7 @@ class ExtensionFactory:
872861
".csv": CSV,
873862
".parquet": Parquet,
874863
".dbf": DBF,
875-
".dbc": DBC if DBC_IMPORT else FTPNotImported, # type: ignore
864+
".dbc": DBC if DBC_IMPORT else DBCNotImported, # type: ignore
876865
".pdf": PDF,
877866
".json": JSON,
878867
}

0 commit comments

Comments
 (0)