Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
branches: ["master", "main"]
pull_request:

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
pip install --upgrade pip
pip install numpy scipy lz4 pytest
pip install -e .

- name: Run tests
run: pytest
18 changes: 5 additions & 13 deletions INSTALL.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
Installation
------------
This is a standard Python Distutil distribution. To install simply run:
dbdreader is a pure-Python package. Install with pip::

for python2.7
pip install dbdreader

python setup.py install
or, to install from source::

pip install .

for python3.3+

python3 setup.py install

This installs dbdreader system-wide. You need root privileges to do this. If
you don't have root privileges, or you don't wish to install dbdreader system-wide
you can install into a custum directory by adding the option "--prefix=...".

For the extension module to compile you will also need to have gcc and python(3)
development headers installed.
Dependencies (numpy, scipy, lz4) are installed automatically.

4 changes: 0 additions & 4 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
include README.rst COPYING COPYRIGHT MANIFEST.in INSTALL.rst LICENSE
include requirements.txt
include extension/*.c
include extension/include/*.h
include lz4/*.c
include lz4/include/*.h
include tests/*.py
include dbdreader/data/*.[stdem][bcl][dg]
include dbdreader/data/cac/*.c[ac]c
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
391 changes: 391 additions & 0 deletions dbdreader/_dbdreader.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbdreader/dbdreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import datetime
from calendar import timegm
from collections import defaultdict, namedtuple
import _dbdreader
from . import _dbdreader
import dbdreader.decompress
import logging

Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ classifiers = [
"Programming Language :: Python :: 3",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: POSIX",
"Operating System :: OS Independent",
]
dependencies = [
"lz4>=4.4.5",
Expand Down Expand Up @@ -40,9 +40,6 @@ requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
ext-modules = [
{name = "_dbdreader", sources = ["extension/py_dbdreader.c", "extension/dbdreader.c", "extension/decompress.c"], include-dirs = ["extension/include"]}
]
packages = ["dbdreader"]
include-package-data = false

Expand Down
99 changes: 1 addition & 98 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import sys
import os
import re

import glob

import setuptools

with open("dbdreader/__init__.py", "r") as fh:
Expand All @@ -25,92 +21,6 @@
with open('requirements.txt') as fh:
install_requires = [line.strip() for line in fh]

# Now determine what we need to build ourselves.
sources = ["extension/py_dbdreader.c",
"extension/dbdreader.c",
"extension/decompress.c"]
include_dirs = ['extension/include']
library_dirs = []


def check_header_file_version(p):
version = dict(MAJOR=0, MINOR=0, RELEASE=0)
counter = 0
with open(p) as fp:
for line in fp:
if line.startswith("#define LZ4_VERSION"):
fields = line.strip().split()
for k in version.keys():
if k in fields[1]:
version[k] = fields[2]
counter += 1
if counter == 3:
break
if counter == 3:
v = ".".join((version["MAJOR"],
version["MINOR"],
version["RELEASE"]))
else:
v = ""
return v


def version_as_int(s):
major, minor, release = map(int, s.split('.'))
return release + minor*1000 + major*1000000


def has_header_file(header_file='lz4.h', required_version=None):
include_dirs = ['/usr/include',
'/usr/local/include']
found = False
for d in include_dirs:
p = os.path.join(d, header_file)
if os.path.exists(p):
found = True
break
if found:
version = check_header_file_version(p)
if version and required_version is None:
return True
else:
V = version_as_int(version)
Vreq = version_as_int(required_version)
return V >= Vreq
else:
return False


if sys.platform.startswith('linux'):
# we're on linux, so check for a system-wide installed library of
# lz4 and use that if available.
import ctypes
try:
# Try to load the lz4 library
ctypes.CDLL("liblz4.so.1")
except OSError:
liblz4_found = False
else:
# Library found, what about the include file?
if has_header_file('lz4.h', required_version='1.7.5'):
liblz4_found = True
else:
liblz4_found = False
elif sys.platform.startswith("win"):
liblz4_found = False
else:
liblz4_found = False

if liblz4_found:
# We are on a linux platform, and have access to system-wide
# installed library of lz4.
libraries = ['lz4']
else:
# we need to integrate the lz4 code in our build.
sources += ["lz4/lz4.c"]
libraries = []
include_dirs += ['lz4/include']

setuptools.setup(
name="dbdreader",
version=VERSION,
Expand All @@ -130,17 +40,10 @@ def has_header_file(header_file='lz4.h', required_version=None):
},
scripts=[],
install_requires=install_requires,
ext_modules=[
setuptools.Extension("_dbdreader",
sources=sources,
libraries=libraries,
include_dirs=include_dirs,
library_dirs=library_dirs)
],
classifiers=[
"Programming Language :: Python :: 3",
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
"Operating System :: POSIX",
"Operating System :: OS Independent",
],
)