hdx-python-database 1.3.8__tar.gz → 1.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hdx_python_database-1.4.0/.github/workflows/publish.yaml +34 -0
- hdx_python_database-1.4.0/.github/workflows/run-python-tests.yaml +49 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/.gitignore +4 -1
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/.pre-commit-config.yaml +9 -9
- hdx_python_database-1.4.0/CLAUDE.md +35 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/PKG-INFO +81 -19
- hdx_python_database-1.4.0/README.md +87 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/documentation/index.md +9 -3
- hdx_python_database-1.4.0/pyproject.toml +132 -0
- hdx_python_database-1.4.0/src/hdx/database/_version.py +24 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/src/hdx/database/database.py +28 -20
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/src/hdx/database/dburi.py +13 -13
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/src/hdx/database/no_timezone.py +5 -6
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/src/hdx/database/postgresql.py +11 -5
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/src/hdx/database/views.py +3 -5
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/tests/hdx/database/test_database.py +3 -3
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/tests/hdx/database/test_dburi.py +13 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/tests/hdx/database/test_postgresql.py +12 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/tests/hdx/database/test_reflect.py +2 -1
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/tests/hdx/database/test_ssh.py +9 -0
- hdx_python_database-1.4.0/tests/hdx/database/test_views.py +23 -0
- hdx_python_database-1.4.0/uv.lock +1505 -0
- hdx_python_database-1.3.8/.github/workflows/publish.yaml +0 -37
- hdx_python_database-1.3.8/.github/workflows/run-python-tests.yaml +0 -53
- hdx_python_database-1.3.8/README.md +0 -12
- hdx_python_database-1.3.8/hatch.toml +0 -34
- hdx_python_database-1.3.8/pyproject.toml +0 -53
- hdx_python_database-1.3.8/pytest.ini +0 -4
- hdx_python_database-1.3.8/requirements.txt +0 -143
- hdx_python_database-1.3.8/ruff.toml +0 -15
- hdx_python_database-1.3.8/src/hdx/database/_version.py +0 -34
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/.coveragerc +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/CONTRIBUTING.md +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/LICENSE +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/documentation/.readthedocs.yaml +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/documentation/mkdocs.yaml +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/src/hdx/database/__init__.py +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/src/hdx/database/utils.py +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/src/hdx/database/with_timezone.py +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/tests/fixtures/test.db +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/tests/hdx/database/__init__.py +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/tests/hdx/database/conftest.py +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/tests/hdx/database/dbtestdate.py +0 -0
- {hdx_python_database-1.3.8 → hdx_python_database-1.4.0}/tests/hdx/database/test_drop_recreate.py +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
environment:
|
|
12
|
+
name: pypi
|
|
13
|
+
url: https://pypi.org/p/hdx-python-database
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v6
|
|
21
|
+
|
|
22
|
+
- name: Get history and tags for versioning to work
|
|
23
|
+
run: |
|
|
24
|
+
git fetch --prune --unshallow
|
|
25
|
+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
|
|
26
|
+
|
|
27
|
+
- name: Install uv
|
|
28
|
+
uses: astral-sh/setup-uv@v7
|
|
29
|
+
|
|
30
|
+
- name: Build with uv
|
|
31
|
+
run: uv build
|
|
32
|
+
|
|
33
|
+
- name: Publish distribution 📦 to PyPI
|
|
34
|
+
run: uv publish
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: Run tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
branches-ignore: [gh-pages, "dependabot/**"]
|
|
7
|
+
pull_request:
|
|
8
|
+
branches-ignore: [gh-pages]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
checks: write
|
|
16
|
+
pull-requests: write
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v6
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v7
|
|
23
|
+
with:
|
|
24
|
+
enable-cache: true
|
|
25
|
+
python-version: "3.13"
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: uv sync --frozen
|
|
29
|
+
|
|
30
|
+
- name: Check styling
|
|
31
|
+
run: |
|
|
32
|
+
uv run ruff format --check
|
|
33
|
+
uv run ruff check
|
|
34
|
+
|
|
35
|
+
- name: Test with pytest
|
|
36
|
+
run: uv run pytest
|
|
37
|
+
|
|
38
|
+
- name: Publish Unit Test Results
|
|
39
|
+
uses: EnricoMi/publish-unit-test-result-action@v2
|
|
40
|
+
if: always()
|
|
41
|
+
with:
|
|
42
|
+
files: test-results.xml
|
|
43
|
+
|
|
44
|
+
- name: Publish in Coveralls
|
|
45
|
+
uses: coverallsapp/github-action@v2
|
|
46
|
+
if: always()
|
|
47
|
+
with:
|
|
48
|
+
flag-name: tests
|
|
49
|
+
format: lcov
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
default_language_version:
|
|
2
|
-
|
|
2
|
+
python: python3
|
|
3
|
+
|
|
3
4
|
repos:
|
|
4
5
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
-
rev:
|
|
6
|
+
rev: v6.0.0
|
|
6
7
|
hooks:
|
|
7
8
|
- id: trailing-whitespace
|
|
8
9
|
- id: end-of-file-fixer
|
|
9
10
|
- id: check-ast
|
|
11
|
+
|
|
10
12
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
11
|
-
rev: v0.
|
|
13
|
+
rev: v0.14.13
|
|
12
14
|
hooks:
|
|
13
15
|
# Run the linter.
|
|
14
16
|
- id: ruff-check
|
|
15
17
|
args: [ --fix ]
|
|
16
18
|
# Run the formatter.
|
|
17
19
|
- id: ruff-format
|
|
20
|
+
|
|
18
21
|
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
19
|
-
rev: 0.
|
|
22
|
+
rev: 0.9.25
|
|
20
23
|
hooks:
|
|
21
|
-
#
|
|
22
|
-
- id:
|
|
23
|
-
name: pip-compile requirements.txt
|
|
24
|
-
files: pyproject.toml
|
|
25
|
-
args: [ pyproject.toml, --resolver=backtracking, --all-extras, --upgrade, -q, -o, requirements.txt ]
|
|
24
|
+
# Ensure the lockfile is up-to-date with pyproject.toml
|
|
25
|
+
- id: uv-lock
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# HDX Python Database
|
|
2
|
+
|
|
3
|
+
HDX Python Database Library — provides utilities for connecting to databases (including via SSH tunnel) using SQLAlchemy.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
uv sync
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Running Tests
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
uv run pytest
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Linting
|
|
18
|
+
|
|
19
|
+
```shell
|
|
20
|
+
uv run ruff check
|
|
21
|
+
uv run ruff format --check
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Building
|
|
25
|
+
|
|
26
|
+
```shell
|
|
27
|
+
uv build
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Package Management
|
|
31
|
+
|
|
32
|
+
- Runtime dependencies go in `[project.dependencies]` in `pyproject.toml`
|
|
33
|
+
- Dev/test dependencies go in `[dependency-groups] dev` in `pyproject.toml`
|
|
34
|
+
- Optional runtime extras (`sshtunnel`, `postgresql`) stay in `[project.optional-dependencies]`
|
|
35
|
+
- After changing dependencies, run `uv lock --upgrade` to regenerate `uv.lock`
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: hdx-python-database
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: HDX Python database utilities
|
|
5
5
|
Project-URL: Homepage, https://github.com/OCHA-DAP/hdx-python-database
|
|
6
|
-
Author-email: Michael Rans <rans@
|
|
6
|
+
Author-email: Michael Rans <rans@un.org>
|
|
7
7
|
License: MIT
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
Keywords: HDX,database,postgresql
|
|
@@ -16,29 +16,16 @@ Classifier: Operating System :: Microsoft :: Windows
|
|
|
16
16
|
Classifier: Operating System :: POSIX :: Linux
|
|
17
17
|
Classifier: Operating System :: Unix
|
|
18
18
|
Classifier: Programming Language :: Python
|
|
19
|
-
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
23
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
26
19
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
-
Requires-Python: >=3.
|
|
20
|
+
Requires-Python: >=3.11
|
|
28
21
|
Requires-Dist: sqlalchemy>=2
|
|
29
|
-
Provides-Extra: dev
|
|
30
|
-
Requires-Dist: pre-commit; extra == 'dev'
|
|
31
22
|
Provides-Extra: docs
|
|
32
23
|
Requires-Dist: mkapi; extra == 'docs'
|
|
33
24
|
Provides-Extra: postgresql
|
|
34
25
|
Requires-Dist: psycopg[binary]; extra == 'postgresql'
|
|
35
26
|
Provides-Extra: sshtunnel
|
|
36
|
-
Requires-Dist:
|
|
37
|
-
|
|
38
|
-
Requires-Dist: psycopg[binary]; extra == 'test'
|
|
39
|
-
Requires-Dist: pytest; extra == 'test'
|
|
40
|
-
Requires-Dist: pytest-cov; extra == 'test'
|
|
41
|
-
Requires-Dist: sshtunnel; extra == 'test'
|
|
27
|
+
Requires-Dist: cryptography>=48.0.1; extra == 'sshtunnel'
|
|
28
|
+
Requires-Dist: sshtunnel>=0.5.1; extra == 'sshtunnel'
|
|
42
29
|
Description-Content-Type: text/markdown
|
|
43
30
|
|
|
44
31
|
[](https://github.com/OCHA-DAP/hdx-python-database/actions/workflows/run-python-tests.yaml)
|
|
@@ -53,3 +40,78 @@ For more information, please read the [documentation](https://hdx-python-databas
|
|
|
53
40
|
|
|
54
41
|
This library is part of the [Humanitarian Data Exchange](https://data.humdata.org/) (HDX) project. If you have
|
|
55
42
|
humanitarian related data, please upload your datasets to HDX.
|
|
43
|
+
|
|
44
|
+
# Development
|
|
45
|
+
|
|
46
|
+
## Environment
|
|
47
|
+
|
|
48
|
+
Development is currently done using Python 3.13. The environment can be created with:
|
|
49
|
+
|
|
50
|
+
```shell
|
|
51
|
+
uv sync
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This creates a .venv folder with the versions specified in the project's uv.lock file.
|
|
55
|
+
|
|
56
|
+
### Pre-commit
|
|
57
|
+
|
|
58
|
+
pre-commit will be installed when syncing uv. It is run every time you make a git
|
|
59
|
+
commit if you call it like this:
|
|
60
|
+
|
|
61
|
+
```shell
|
|
62
|
+
pre-commit install
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
With pre-commit, all code is formatted according to
|
|
66
|
+
[ruff](https://docs.astral.sh/ruff/) guidelines.
|
|
67
|
+
|
|
68
|
+
To check if your changes pass pre-commit without committing, run:
|
|
69
|
+
|
|
70
|
+
```shell
|
|
71
|
+
pre-commit run --all-files
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Packages
|
|
75
|
+
|
|
76
|
+
[uv](https://github.com/astral-sh/uv) is used for package management. If
|
|
77
|
+
you've introduced a new package to the source code (i.e. anywhere in `src/`),
|
|
78
|
+
please add it to the `project.dependencies` section of `pyproject.toml` with
|
|
79
|
+
any known version constraints.
|
|
80
|
+
|
|
81
|
+
To add packages required only for testing, add them to the
|
|
82
|
+
`[dependency-groups]`.
|
|
83
|
+
|
|
84
|
+
Any changes to the dependencies will be automatically reflected in
|
|
85
|
+
`uv.lock` with `pre-commit`, but you can re-generate the files without committing by
|
|
86
|
+
executing:
|
|
87
|
+
|
|
88
|
+
```shell
|
|
89
|
+
uv lock --upgrade
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Project
|
|
93
|
+
|
|
94
|
+
[uv](https://github.com/astral-sh/uv) is used for project management. The project can be
|
|
95
|
+
built using:
|
|
96
|
+
|
|
97
|
+
```shell
|
|
98
|
+
uv build
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Linting and syntax checking can be run with:
|
|
102
|
+
|
|
103
|
+
```shell
|
|
104
|
+
uv run ruff check
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
To run the tests and view coverage, execute:
|
|
108
|
+
|
|
109
|
+
```shell
|
|
110
|
+
uv run pytest
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Documentation
|
|
114
|
+
|
|
115
|
+
The documentation, including API documentation, is generated using ReadtheDocs and
|
|
116
|
+
MkDocs with Material. As you change the source code, remember to update the
|
|
117
|
+
documentation at `documentation/index.md`.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
[](https://github.com/OCHA-DAP/hdx-python-database/actions/workflows/run-python-tests.yaml)
|
|
2
|
+
[](https://coveralls.io/github/OCHA-DAP/hdx-python-database?branch=main)
|
|
3
|
+
[](https://github.com/astral-sh/ruff)
|
|
4
|
+
[](https://pypistats.org/packages/hdx-python-database)
|
|
5
|
+
|
|
6
|
+
The HDX Python Database Library provides utilities for connecting to databases in a standard way including
|
|
7
|
+
through an ssh tunnel if needed. It is built on top of SQLAlchemy and simplifies its setup.
|
|
8
|
+
|
|
9
|
+
For more information, please read the [documentation](https://hdx-python-database.readthedocs.io/en/latest/).
|
|
10
|
+
|
|
11
|
+
This library is part of the [Humanitarian Data Exchange](https://data.humdata.org/) (HDX) project. If you have
|
|
12
|
+
humanitarian related data, please upload your datasets to HDX.
|
|
13
|
+
|
|
14
|
+
# Development
|
|
15
|
+
|
|
16
|
+
## Environment
|
|
17
|
+
|
|
18
|
+
Development is currently done using Python 3.13. The environment can be created with:
|
|
19
|
+
|
|
20
|
+
```shell
|
|
21
|
+
uv sync
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This creates a .venv folder with the versions specified in the project's uv.lock file.
|
|
25
|
+
|
|
26
|
+
### Pre-commit
|
|
27
|
+
|
|
28
|
+
pre-commit will be installed when syncing uv. It is run every time you make a git
|
|
29
|
+
commit if you call it like this:
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
pre-commit install
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
With pre-commit, all code is formatted according to
|
|
36
|
+
[ruff](https://docs.astral.sh/ruff/) guidelines.
|
|
37
|
+
|
|
38
|
+
To check if your changes pass pre-commit without committing, run:
|
|
39
|
+
|
|
40
|
+
```shell
|
|
41
|
+
pre-commit run --all-files
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Packages
|
|
45
|
+
|
|
46
|
+
[uv](https://github.com/astral-sh/uv) is used for package management. If
|
|
47
|
+
you've introduced a new package to the source code (i.e. anywhere in `src/`),
|
|
48
|
+
please add it to the `project.dependencies` section of `pyproject.toml` with
|
|
49
|
+
any known version constraints.
|
|
50
|
+
|
|
51
|
+
To add packages required only for testing, add them to the
|
|
52
|
+
`[dependency-groups]`.
|
|
53
|
+
|
|
54
|
+
Any changes to the dependencies will be automatically reflected in
|
|
55
|
+
`uv.lock` with `pre-commit`, but you can re-generate the files without committing by
|
|
56
|
+
executing:
|
|
57
|
+
|
|
58
|
+
```shell
|
|
59
|
+
uv lock --upgrade
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Project
|
|
63
|
+
|
|
64
|
+
[uv](https://github.com/astral-sh/uv) is used for project management. The project can be
|
|
65
|
+
built using:
|
|
66
|
+
|
|
67
|
+
```shell
|
|
68
|
+
uv build
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Linting and syntax checking can be run with:
|
|
72
|
+
|
|
73
|
+
```shell
|
|
74
|
+
uv run ruff check
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
To run the tests and view coverage, execute:
|
|
78
|
+
|
|
79
|
+
```shell
|
|
80
|
+
uv run pytest
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Documentation
|
|
84
|
+
|
|
85
|
+
The documentation, including API documentation, is generated using ReadtheDocs and
|
|
86
|
+
MkDocs with Material. As you change the source code, remember to update the
|
|
87
|
+
documentation at `documentation/index.md`.
|
|
@@ -79,20 +79,26 @@ tunnel (which requires installing `hdx-python-database[sshtunnel]`):
|
|
|
79
79
|
|
|
80
80
|
# Get SQLAlchemy session object given database parameters and
|
|
81
81
|
# if needed SSH parameters. If database is PostgreSQL, will poll
|
|
82
|
-
# till it is up.
|
|
82
|
+
# till it is up (or until pg_timeout seconds if supplied).
|
|
83
83
|
from hdx.database import Database
|
|
84
84
|
with Database(database="db", host="1.2.3.4", username="user",
|
|
85
85
|
password="pass", dialect="dialect", driver="driver",
|
|
86
86
|
|
|
87
87
|
ssh_host="5.6.7.8", ssh_port=2222, ssh_username="sshuser",
|
|
88
|
-
ssh_private_key="path_to_key",
|
|
89
|
-
reflect=True, prepare_fn=prepare_views
|
|
88
|
+
ssh_private_key="path_to_key", ssh_host_key="AAAAC3...",
|
|
89
|
+
db_has_tz=True, reflect=True, prepare_fn=prepare_views,
|
|
90
|
+
pg_timeout=60) as database:
|
|
90
91
|
engine = database.get_engine()
|
|
91
92
|
session = database.get_session()
|
|
92
93
|
reflected_classes = database.get_reflected_classes()
|
|
93
94
|
views = database.get_prepare_results()
|
|
94
95
|
session.query(...)
|
|
95
96
|
|
|
97
|
+
`ssh_host_key` is the SSH server's public host key, used to verify the server's
|
|
98
|
+
identity. Without it, the tunnel is open to man-in-the-middle attacks and a
|
|
99
|
+
warning is logged. It can be obtained with `ssh-keyscan -t ed25519 5.6.7.8`
|
|
100
|
+
(the base64 field of the output).
|
|
101
|
+
|
|
96
102
|
`db_has_tz` which defaults to `False` indicates whether database datetime
|
|
97
103
|
columns have timezones. If `db_has_tz` is `True`, use `Base` from
|
|
98
104
|
`hdx.database.with_timezone`, otherwise use `Base` from
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#########################
|
|
2
|
+
# Project Configuration #
|
|
3
|
+
#########################
|
|
4
|
+
|
|
5
|
+
[build-system]
|
|
6
|
+
requires = ["hatchling", "hatch-vcs"]
|
|
7
|
+
build-backend = "hatchling.build"
|
|
8
|
+
|
|
9
|
+
[project]
|
|
10
|
+
name = "hdx-python-database"
|
|
11
|
+
description = "HDX Python database utilities"
|
|
12
|
+
authors = [{name = "Michael Rans", email = "rans@un.org"}]
|
|
13
|
+
license = {text = "MIT"}
|
|
14
|
+
keywords = ["HDX", "database", "postgresql"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 5 - Production/Stable",
|
|
17
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Intended Audience :: Developers",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Natural Language :: English",
|
|
22
|
+
"Operating System :: POSIX :: Linux",
|
|
23
|
+
"Operating System :: Unix",
|
|
24
|
+
"Operating System :: MacOS",
|
|
25
|
+
"Operating System :: Microsoft :: Windows",
|
|
26
|
+
]
|
|
27
|
+
readme = "README.md"
|
|
28
|
+
dynamic = ["version"]
|
|
29
|
+
requires-python = ">=3.11"
|
|
30
|
+
|
|
31
|
+
dependencies = [
|
|
32
|
+
"sqlalchemy>=2",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.optional-dependencies]
|
|
36
|
+
sshtunnel = ["sshtunnel>=0.5.1", "cryptography>=48.0.1"]
|
|
37
|
+
postgresql = ["psycopg[binary]"]
|
|
38
|
+
docs = ["mkapi"]
|
|
39
|
+
|
|
40
|
+
[dependency-groups]
|
|
41
|
+
dev = [
|
|
42
|
+
"sshtunnel>=0.5.1",
|
|
43
|
+
"psycopg[binary]",
|
|
44
|
+
"pytest",
|
|
45
|
+
"pytest-cov",
|
|
46
|
+
"pre-commit",
|
|
47
|
+
"ruff==0.14.13",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/OCHA-DAP/hdx-python-database"
|
|
52
|
+
|
|
53
|
+
# ----------------------------------------------------------------------------
|
|
54
|
+
# Hatchling (Build & Versioning)
|
|
55
|
+
# ----------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
[tool.hatch.version]
|
|
58
|
+
source = "vcs"
|
|
59
|
+
|
|
60
|
+
[tool.hatch.version.raw-options]
|
|
61
|
+
local_scheme = "no-local-version"
|
|
62
|
+
version_scheme = "python-simplified-semver"
|
|
63
|
+
|
|
64
|
+
[tool.hatch.build.hooks.vcs]
|
|
65
|
+
version-file = "src/hdx/database/_version.py"
|
|
66
|
+
|
|
67
|
+
[tool.hatch.build.targets.wheel]
|
|
68
|
+
packages = ["src/hdx"]
|
|
69
|
+
|
|
70
|
+
[tool.hatch.metadata]
|
|
71
|
+
allow-direct-references = true
|
|
72
|
+
|
|
73
|
+
# ----------------------------------------------------------------------------
|
|
74
|
+
# Ruff (Linting & Formatting)
|
|
75
|
+
# ----------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
[tool.ruff]
|
|
78
|
+
target-version = "py311"
|
|
79
|
+
src = ["src"]
|
|
80
|
+
exclude = ["_version.py"]
|
|
81
|
+
|
|
82
|
+
[tool.ruff.lint]
|
|
83
|
+
# Defaults are E (pycodestyle) and F (pyflakes). We extend them:
|
|
84
|
+
extend-select = [
|
|
85
|
+
"I", # isort
|
|
86
|
+
"UP", # pyupgrade
|
|
87
|
+
]
|
|
88
|
+
ignore = [
|
|
89
|
+
"E501", # Line too long
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
[tool.ruff.lint.isort]
|
|
93
|
+
known-local-folder = ["hdx.database"]
|
|
94
|
+
|
|
95
|
+
# ----------------------------------------------------------------------------
|
|
96
|
+
# Pytest (Testing)
|
|
97
|
+
# ----------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
[tool.pytest.ini_options]
|
|
100
|
+
pythonpath = "src"
|
|
101
|
+
log_cli = true
|
|
102
|
+
addopts = """
|
|
103
|
+
--color=yes
|
|
104
|
+
--rootdir=.
|
|
105
|
+
--junitxml=test-results.xml
|
|
106
|
+
--cov
|
|
107
|
+
--no-cov-on-fail
|
|
108
|
+
--cov-report=lcov
|
|
109
|
+
--cov-report=term-missing
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
# ----------------------------------------------------------------------------
|
|
113
|
+
# Coverage (Reporting)
|
|
114
|
+
# ----------------------------------------------------------------------------
|
|
115
|
+
|
|
116
|
+
[tool.coverage.run]
|
|
117
|
+
source = ["src"]
|
|
118
|
+
omit = ["*/_version.py"]
|
|
119
|
+
|
|
120
|
+
[tool.coverage.report]
|
|
121
|
+
exclude_also = [
|
|
122
|
+
"from ._version",
|
|
123
|
+
"def __repr__",
|
|
124
|
+
"if self.debug:",
|
|
125
|
+
"if settings.DEBUG",
|
|
126
|
+
"raise AssertionError",
|
|
127
|
+
"raise NotImplementedError",
|
|
128
|
+
"if 0:",
|
|
129
|
+
"if __name__ == .__main__.:",
|
|
130
|
+
"if TYPE_CHECKING:",
|
|
131
|
+
"@(abc\\.)?abstractmethod",
|
|
132
|
+
]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '1.4.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (1, 4, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|