From 7aeecf78489622e583192890cc7f3fce2219f8c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Desboeufs?= Date: Sat, 1 Nov 2025 23:30:54 +0100 Subject: [PATCH] Modernize project structure and tooling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Migrate from setup.py to pyproject.toml with modern setuptools - Update Python support to 3.9-3.14 - Add GitHub Actions CI workflow with Redis service and Python matrix testing - Add Makefile with development and distribution commands - Update LICENSE copyright to République Française - Improve README with features section and consistent formatting - Remove obsolete MANIFEST.in and setup.py - Update .gitignore for dist/ and venv/ --- .github/workflows/ci.yml | 40 +++++++++++++++++++++++++++++++ .gitignore | 2 ++ LICENSE | 2 +- MANIFEST.in | 2 -- Makefile | 21 ++++++++++++++++ README.md | 22 +++++++++++------ pyproject.toml | 52 ++++++++++++++++++++++++++++++++++++++++ setup.py | 40 ------------------------------- 8 files changed, 131 insertions(+), 50 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 MANIFEST.in create mode 100644 Makefile create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2961ba7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +name: CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.9', '3.14'] + fail-fast: false + services: + redis: + image: redis + options: + --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 + + 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: | + python -m pip install --upgrade pip + pip install -e ".[dev]" + + - name: Run tests with pytest + run: | + pytest --cov=addok_sqlite_store --cov-report=term-missing diff --git a/.gitignore b/.gitignore index 2049504..79b8280 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ __pycache__ *.pyc *.egg-info .cache +dist +venv diff --git a/LICENSE b/LICENSE index efe978f..e3d84f3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Yohan Boniface, DINSIC/Etalab +Copyright (c) 2019 République Française Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 8afbefe..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -include README.md -include requirements.txt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7290c8d --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +develop: + pip install -e ".[dev]" + +test: + python -m pytest + +testcoverage: + python -m pytest --cov-report lcov --cov=addok_sqlite_store tests/ + +clean: + rm -rf dist/ build/ + +dist: clean test + python -m build + +upload: dist + @if [ -z "$$(ls dist/*.whl dist/*.tar.gz 2>/dev/null)" ]; then \ + echo "Error: No distribution files found. Run 'make dist' first."; \ + exit 1; \ + fi + twine upload dist/* diff --git a/README.md b/README.md index ac973f8..67ccb5a 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,26 @@ -# Addok SQlite store plugin +# addok-sqlite-store -Store your documents into a SQlite database to save Redis RAM usage. +Addok plugin to store documents in SQLite instead of Redis to reduce memory usage. +## Features -## Install +- **SQLite storage**: Store documents in a SQLite database instead of Redis +- **Memory optimization**: Reduce Redis RAM usage for large datasets +- **Automatic registration**: Plugin registers itself when installed - pip install addok-sqlite-store +## Installation +```bash +pip install addok-sqlite-store +``` ## Configuration The plugin will register itself when installed, by setting the correct `DOCUMENT_STORE_PYPATH`. -You want to define the path where the SQLite database will be created, by -setting `SQLITE_DB_PATH` into your local -[configuration](http://addok.readthedocs.io/en/latest/config/). +Define the path where the SQLite database will be created: + +```python +SQLITE_DB_PATH = "/path/to/your/database.db" +``` diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..23ef42d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,52 @@ +[build-system] +requires = ["setuptools>=65.0"] +build-backend = "setuptools.build_meta" + +[project] +name = "addok-sqlite-store" +version = "1.0.1" +description = "Store documents in SQLite for Addok." +readme = "README.md" +authors = [ + {name = "Yohan Boniface", email = "yohan.boniface@data.gouv.fr"} +] +license = "MIT" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Scientific/Engineering :: GIS", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", +] +keywords = ["addok", "geocoding", "sqlite", "plugin"] +requires-python = ">=3.9" +dependencies = [ + "addok", +] + +[project.optional-dependencies] +dev = [ + "pytest~=8.3", + "pytest-cov~=6.1", + "build~=1.2", + "twine==6.1.0", +] + +[project.urls] +Homepage = "https://github.com/addok/addok-sqlite-store" + +[project.entry-points."addok.ext"] +sqlite-store = "addok_sqlite_store" + +[tool.setuptools] +include-package-data = true + +[tool.setuptools.packages.find] +exclude = ["tests*", "venv*", ".venv*", "build*", "dist*"] + +[tool.pytest.ini_options] +addopts = "-x" diff --git a/setup.py b/setup.py deleted file mode 100644 index 32e1878..0000000 --- a/setup.py +++ /dev/null @@ -1,40 +0,0 @@ -from setuptools import setup, find_packages -from codecs import open # To use a consistent encoding -from os import path - -VERSION = (1, 0, 1) - -here = path.abspath(path.dirname(__file__)) - -# Get the long description from the relevant file -with open(path.join(here, 'README.md'), encoding='utf-8') as f: - long_description = f.read() - -setup( - name='addok-sqlite-store', - version=".".join(map(str, VERSION)), - description="Store documents in Sqlite.", - long_description=long_description, - url='https://github.com/addok/addok-sqlite-store', - author='Yohan Boniface', - author_email='yohan.boniface@data.gouv.fr', - license='WTFPL', - - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - 'Development Status :: 4 - Beta', - - 'Intended Audience :: Developers', - 'Topic :: Scientific/Engineering :: GIS', - - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - ], - keywords='addok geocoding sqlite plugin', - packages=find_packages(exclude=['tests']), - extras_require={'test': ['pytest']}, - include_package_data=True, - entry_points={'addok.ext': ['sqlite-store=addok_sqlite_store']}, -)