From 5309417037b34319796c20ae5ae5c1cfcd178c4c Mon Sep 17 00:00:00 2001 From: Scott Searcy Date: Mon, 10 Jun 2024 14:20:23 -0700 Subject: [PATCH] Remove PostgreSQL support since testing is broken --- .github/workflows/ci.yml | 15 -------- CHANGELOG.rst | 8 +++++ README.md | 1 - docs/config.rst | 4 +-- docs/contributing.rst | 22 +++++------- docs/installation.rst | 5 ++- pdm.lock | 78 +--------------------------------------- pyproject.toml | 2 -- requirements.txt | 1 - tests/conftest.py | 33 ++--------------- 10 files changed, 23 insertions(+), 146 deletions(-) delete mode 100644 README.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ad20699..a56e25c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,19 +43,6 @@ jobs: - "3.10" - "3.11" - services: - postgres: - image: postgres - env: - POSTGRES_PASSWORD: meshmap - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - 5432:5432 - steps: - uses: actions/checkout@v4 - name: Set up PDM @@ -71,8 +58,6 @@ jobs: pdm run pytest --cov=meshinfo env: MESHMAP_COLLECTOR_DATA_DIR: "." - POSTGRES_HOST: localhost - POSTGRES_PASSWORD: meshmap docs: runs-on: ubuntu-latest diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c0df3d5..55d3758 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,14 @@ so breaking changes are possible but will be highlighted here. Fixed Security +0.8.0 - Unreleased +------------------ + +Removed +^^^^^^^ + +* **BREAKING CHANGE:** Removed support for PostgreSQL. + 0.7.0 - 2024-05-20 ------------------ diff --git a/README.md b/README.md deleted file mode 100644 index 13e50ed..0000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# mesh-info diff --git a/docs/config.rst b/docs/config.rst index 59f99b5..6f32bf5 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -20,7 +20,6 @@ Example MESH_INFO_LOG_LEVEL=INFO MESH_INFO_MAP_TILE_URL="https://tiles.stadiamaps.com/tiles/stamen_terrain/{z}/{x}/{y}{r}.png" MESH_INFO_MAP_TILE_ATTRIBUTION='© Stadia Maps © Stamen Design © OpenMapTiles © OpenStreetMap' - MESH_INFO_DB_URL="postgresql+psycopg2://postgres:password@localhost:5432/postgres" Options @@ -47,8 +46,7 @@ MESH_INFO_COLLECTOR_WORKERS Default is 50. MESH_INFO_DB_URL - Override the default SQLite database by pointing to a PostgreSQL server - (or changing the default location). + Change location of the SQLite database. Default is SQLite database ``mesh-info.db`` in the data directory. MESH_INFO_ENVIRONMENT diff --git a/docs/contributing.rst b/docs/contributing.rst index bd4c662..7b2b0e0 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -22,19 +22,16 @@ For starters, you will need: * Python 3.9 or greater, with the "dev" or "devel" libraries * RRDtool libraries (``librrd-dev`` on Debian/Ubuntu or ``rrdtool-devel`` on Fedora). -* PostgreSQL libraries (``libpq-dev`` on Debian/Ubuntu or ``libpq-devel`` on Fedora). -* Fork/clone the Git repository using your preferred tool. +* `PDM `_ to manage the Python environment. +* Fork/clone the Git repository using your preferred tool and ``cd`` to the repository. -Then, setup the Python virtual environment: +Then, setup the Python virtual environment and activate it: .. code-block:: console - $ cd mesh-info - $ python3 -m venv venv - $ . ./venv/bin/activate - (venv) $ pip install -U pip wheel - (venv) $ pip install -r requirements.txt -e .[dev] - (venv) $ make migrate-db + pdm install + make migrate-db + . ./venv/bin/activate Create a ``.env`` file in the ``mesh-info`` folder and add: @@ -58,7 +55,7 @@ Run the development web server via: .. code-block:: console - (venv) $ ./dev-web.sh + ./dev-web.sh Connect to the server at http://localhost:8000. @@ -73,7 +70,7 @@ make pre-commit Runs `pre-commit `_ to check/format files. make lint - Runs `Flake8 `_ to do static linting. + Runs `Ruff `_ to do static linting. make mypy Run `mypy `_ static type checker. @@ -94,9 +91,6 @@ make make-migration make migrate-db Apply `Alembic `_ database migrations. -make requirements - Generate requirements files via `pip-tools `_. - Architecture ------------ diff --git a/docs/installation.rst b/docs/installation.rst index d7ae9f7..c4bcf69 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -1,8 +1,7 @@ Installation ============ -Mesh Info requires Python 3.9+, RRDtool, and PostgreSQL libraries -(although it defaults to using SQLite). +Mesh Info requires Python 3.9+ and RRDtool libraries. The following instructions include installing those dependencies. Installation instructions for Raspberry Pi OS @@ -20,7 +19,7 @@ and create ``/var/lib/mesh-info`` for storing the application data. .. code-block:: console sudo apt update - sudo apt install -y git libpq-dev librrd-dev python3 python3-dev python3-pip python3-venv rrdtool + sudo apt install -y git librrd-dev python3 python3-dev python3-pip python3-venv rrdtool sudo useradd meshinfo sudo mkdir /opt/mesh-info /var/lib/mesh-info sudo chown meshinfo: /opt/mesh-info /var/lib/mesh-info diff --git a/pdm.lock b/pdm.lock index 5c4e831..c305fd0 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "dev", "testing", "docs", "ruff", "mypy"] strategy = ["cross_platform", "inherit_metadata"] lock_version = "4.4.1" -content_hash = "sha256:417eb1dbfdeeaf7eef6cdbc2f92a78b15956cc52c076336ddb9313e177e78156" +content_hash = "sha256:4b8ff74990a172efeddd003535b30d546a7a522a061f25ebfdacbdddeae40de3" [[package]] name = "aiohttp" @@ -764,20 +764,6 @@ files = [ {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, ] -[[package]] -name = "mirakuru" -version = "2.5.2" -requires_python = ">=3.8" -summary = "Process executor (not only) for tests." -groups = ["testing"] -dependencies = [ - "psutil>=4.0.0; sys_platform != \"cygwin\"", -] -files = [ - {file = "mirakuru-2.5.2-py3-none-any.whl", hash = "sha256:90c2d90a8cf14349b2f33e6db30a16acd855499811e0312e56cf80ceacf2d3e5"}, - {file = "mirakuru-2.5.2.tar.gz", hash = "sha256:41ca583d355eb7a6cfdc21c1aea549979d685c27b57239b88725434f115a7132"}, -] - [[package]] name = "multidict" version = "6.0.5" @@ -993,17 +979,6 @@ files = [ {file = "pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1"}, ] -[[package]] -name = "port-for" -version = "0.7.2" -requires_python = ">=3.8" -summary = "Utility that helps with local TCP ports management. It can find an unused TCP localhost port and remember the association." -groups = ["testing"] -files = [ - {file = "port-for-0.7.2.tar.gz", hash = "sha256:074f29335130578aa42fef3726985e57d01c15189e509633a8a1b0b7f9226349"}, - {file = "port_for-0.7.2-py3-none-any.whl", hash = "sha256:16b279ab4f210bad33515c45bd9af0c6e048ab24c3b6bbd9cfc7e451782617df"}, -] - [[package]] name = "pre-commit" version = "3.7.1" @@ -1022,41 +997,6 @@ files = [ {file = "pre_commit-3.7.1.tar.gz", hash = "sha256:8ca3ad567bc78a4972a3f1a477e94a79d4597e8140a6e0b651c5e33899c3654a"}, ] -[[package]] -name = "psutil" -version = "5.9.8" -requires_python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" -summary = "Cross-platform lib for process and system monitoring in Python." -groups = ["testing"] -marker = "sys_platform != \"cygwin\"" -files = [ - {file = "psutil-5.9.8-cp36-abi3-macosx_10_9_x86_64.whl", hash = "sha256:aee678c8720623dc456fa20659af736241f575d79429a0e5e9cf88ae0605cc81"}, - {file = "psutil-5.9.8-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8cb6403ce6d8e047495a701dc7c5bd788add903f8986d523e3e20b98b733e421"}, - {file = "psutil-5.9.8-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d06016f7f8625a1825ba3732081d77c94589dca78b7a3fc072194851e88461a4"}, - {file = "psutil-5.9.8-cp37-abi3-win32.whl", hash = "sha256:bc56c2a1b0d15aa3eaa5a60c9f3f8e3e565303b465dbf57a1b730e7a2b9844e0"}, - {file = "psutil-5.9.8-cp37-abi3-win_amd64.whl", hash = "sha256:8db4c1b57507eef143a15a6884ca10f7c73876cdf5d51e713151c1236a0e68cf"}, - {file = "psutil-5.9.8-cp38-abi3-macosx_11_0_arm64.whl", hash = "sha256:d16bbddf0693323b8c6123dd804100241da461e41d6e332fb0ba6058f630f8c8"}, - {file = "psutil-5.9.8.tar.gz", hash = "sha256:6be126e3225486dff286a8fb9a06246a5253f4c7c53b475ea5f5ac934e64194c"}, -] - -[[package]] -name = "psycopg2" -version = "2.9.9" -requires_python = ">=3.7" -summary = "psycopg2 - Python-PostgreSQL Database Adapter" -groups = ["default"] -files = [ - {file = "psycopg2-2.9.9-cp310-cp310-win32.whl", hash = "sha256:38a8dcc6856f569068b47de286b472b7c473ac7977243593a288ebce0dc89516"}, - {file = "psycopg2-2.9.9-cp310-cp310-win_amd64.whl", hash = "sha256:426f9f29bde126913a20a96ff8ce7d73fd8a216cfb323b1f04da402d452853c3"}, - {file = "psycopg2-2.9.9-cp311-cp311-win32.whl", hash = "sha256:ade01303ccf7ae12c356a5e10911c9e1c51136003a9a1d92f7aa9d010fb98372"}, - {file = "psycopg2-2.9.9-cp311-cp311-win_amd64.whl", hash = "sha256:121081ea2e76729acfb0673ff33755e8703d45e926e416cb59bae3a86c6a4981"}, - {file = "psycopg2-2.9.9-cp312-cp312-win32.whl", hash = "sha256:d735786acc7dd25815e89cc4ad529a43af779db2e25aa7c626de864127e5a024"}, - {file = "psycopg2-2.9.9-cp312-cp312-win_amd64.whl", hash = "sha256:a7653d00b732afb6fc597e29c50ad28087dcb4fbfb28e86092277a559ae4e693"}, - {file = "psycopg2-2.9.9-cp39-cp39-win32.whl", hash = "sha256:c92811b2d4c9b6ea0285942b2e7cac98a59e166d59c588fe5cfe1eda58e72d59"}, - {file = "psycopg2-2.9.9-cp39-cp39-win_amd64.whl", hash = "sha256:de80739447af31525feddeb8effd640782cf5998e1a4e9192ebdf829717e3913"}, - {file = "psycopg2-2.9.9.tar.gz", hash = "sha256:d1454bde93fb1e224166811694d600e746430c006fbb031ea06ecc2ea41bf156"}, -] - [[package]] name = "pygments" version = "2.18.0" @@ -1244,22 +1184,6 @@ files = [ {file = "pytest_mock-3.14.0-py3-none-any.whl", hash = "sha256:0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f"}, ] -[[package]] -name = "pytest-postgresql" -version = "3.1.3" -requires_python = ">=3.7" -summary = "Postgresql fixtures and fixture factories for Pytest." -groups = ["testing"] -dependencies = [ - "mirakuru>=2.3.0", - "port-for", - "pytest>=6.2.0", -] -files = [ - {file = "pytest-postgresql-3.1.3.tar.gz", hash = "sha256:05b87a192741511f5171e0300689a531a2a48b4483c69ae2b5f565d3e429b1d5"}, - {file = "pytest_postgresql-3.1.3-py3-none-any.whl", hash = "sha256:3649bcac5a0cd0d2cc1470a1087739990d402e2e910d53265ac486321a833898"}, -] - [[package]] name = "python-dateutil" version = "2.9.0.post0" diff --git a/pyproject.toml b/pyproject.toml index baedaca..1f39fed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ dependencies = [ "gunicorn ~= 22.0", "pendulum ~= 2.1", "platformdirs ~= 2.0", - "psycopg2 ~= 2.9", "pyramid ~= 2.0", "pyramid-jinja2 ~= 2.10", "pyramid-retry ~= 2.1", @@ -75,7 +74,6 @@ testing = [ "pytest-asyncio>=0.23.7", "pytest-cov>=5.0.0", "pytest-mock>=3.14.0", - "pytest-postgresql < 4.0", "pytest>=8.2.1", ] dev = [ diff --git a/requirements.txt b/requirements.txt index a43e5d9..90c3637 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,7 +24,6 @@ pendulum==2.1.2 plaster==1.1.2 plaster-pastedeploy==1.0.1 platformdirs==2.6.2 -psycopg2==2.9.9 pygments==2.18.0 pyramid==2.0.2 pyramid-jinja2==2.10.1 diff --git a/tests/conftest.py b/tests/conftest.py index 1bdbe85..d1d9568 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,24 +8,12 @@ import webtest from pyramid.scripting import prepare from pyramid.testing import DummyRequest, testConfig -from pytest_postgresql import factories from sqlalchemy import create_engine from meshinfo import models from meshinfo.config import AppConfig, configure from meshinfo.models.meta import Base -if os.environ.get("CI"): - postgresql_ci = factories.postgresql_noproc( - # needs to match service in .gitlab-ci.yml - host=os.environ.get("POSTGRES_HOST", "postgres"), - user=os.environ.get("POSTGRES_USER", "postgres"), - password=os.environ.get("POSTGRES_PASSWORD", ""), - dbname=os.environ.get("POSTGRES_DB", "postgres"), - ) -else: - postgresql_local = factories.postgresql("postgresql_proc") - @pytest.fixture(scope="module") def data_folder() -> Path: @@ -41,25 +29,10 @@ def app_config(): return AppConfig.from_environ(env) -@pytest.fixture(params=("sqlite", "postgres")) +@pytest.fixture def dbengine(request, tmp_path): - if request.param == "sqlite": - sqlite_file = tmp_path / "testing.sqlite" - db_url = f"sqlite:///{sqlite_file!s}" - elif request.param == "postgres": - if os.environ.get("CI"): - dbinfo = request.getfixturevalue("postgresql_ci") - else: - postgresql = request.getfixturevalue("postgresql_local") - dbinfo = postgresql.info - user = dbinfo.user - password = dbinfo.password - host = dbinfo.host - port = dbinfo.port - dbname = dbinfo.dbname - db_url = f"postgresql+psycopg2://{user}:{password}@{host}:{port}/{dbname}" - else: - raise ValueError(f"Unknown param: {request.param!r}") + sqlite_file = tmp_path / "testing.sqlite" + db_url = f"sqlite:///{sqlite_file!s}" alembic_cfg = alembic.config.Config("alembic.ini") engine = create_engine(db_url)