Skip to content
Merged
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
7 changes: 3 additions & 4 deletions .github/workflows/python-code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry poetry-plugin-export
poetry config virtualenvs.create false
poetry install --no-root --with dev
make dev-dependencies
- name: Check code style with black
run: |
make format
6 changes: 3 additions & 3 deletions .github/workflows/python-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry tox poetry-plugin-export
make poetry-export
make dev-dependencies
- name: Lint with ruff
run: make lint
7 changes: 3 additions & 4 deletions .github/workflows/python-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry poetry-plugin-export
poetry config virtualenvs.create false
poetry install --no-root --with dev
make dev-dependencies
- name: Test & publish code coverage
uses: paambaati/[email protected]
env:
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.version }}"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry poetry-plugin-export
poetry config virtualenvs.create false
poetry install --no-root --with dev
make dev-dependencies
- name: Test with pytest
id: citest
run: |
Expand Down Expand Up @@ -68,7 +67,7 @@ jobs:
--body "$BODY")
if [[ $PINNED == true ]]; then
gh issue pin "$new_issue_url"
fi
fi
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/python-typing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry tox poetry-plugin-export
make poetry-export
make dev-dependencies
- name: Check typing
run: make typing
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ jobs:
with:
python-version: "3.13"

- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry poetry-dynamic-versioning poetry-plugin-export
make dev-dependencies

- name: Build package
run: |
poetry build
uv build

- name: Archive the dist folder
uses: actions/upload-artifact@v4
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/reusable-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ jobs:
with:
python-version: "3.13"

- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry config virtualenvs.create false
poetry install --no-root --with dev
make dev-dependencies

- name: Configure Git user
run: |
Expand All @@ -62,12 +61,12 @@ jobs:

- name: Build and deploy static pages
run: |
mike deploy ${{ inputs.site-version }} ${{ inputs.version-alias }} --update-aliases --push --branch ${{ inputs.branch }}
uv run mike deploy ${{ inputs.site-version }} ${{ inputs.version-alias }} --update-aliases --push --branch ${{ inputs.branch }}

- name: Set default site version
if: ${{ inputs.set-default }}
run: |
mike set-default ${{ inputs.site-version }} --push --branch ${{ inputs.branch }}
uv run mike set-default ${{ inputs.site-version }} --push --branch ${{ inputs.branch }}

# `mike` is specifically built to be used together with GitHub pages.
# To upload the website to another service (i.e. AWS S3) uncomment
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,5 @@ dmypy.json

# Cython debug symbols
cython_debug/
poetry.lock
uv.lock
version.py
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ Please note that this project is released with a Contributor Code of Conduct. By

## Submitting a pull request

Before running any commands, [install `uv`](https://docs.astral.sh/uv/getting-started/installation/):

0. Fork and clone the repository
0. Install poetry: `pip install -g poetry`
0. Configure and install the dependencies: `make dev-dependencies`
0. Make sure the tests pass on your machine: `make check`
0. Create a new branch: `git checkout -b my-branch-name`
Expand Down
44 changes: 18 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,49 +1,41 @@
.PHONY: dev-dependencies update-dependencies test docs fix check typing lint format ci-test ci-coverage poetry-export
.PHONY: dev-dependencies update-dependencies test docs fix check typing lint format ci-test ci-coverage

#########################
###### dev commands #####
#########################
dev-dependencies:
poetry install --with dev --no-root

update-dependencies:
poetry update --with dev
uv lock --upgrade
uv sync --all-groups --frozen

test:
poetry run pytest -n auto --cov
uv run pytest -n auto --cov

docs:
poetry run mkdocs serve
uv run mkdocs serve

fix:
poetry run ruff check . --fix
poetry run ruff format .

check: poetry-export
tox

typing: poetry-export
tox -e typing
uv run ruff format .
uv run ruff check . --fix
uv run ruff format .

lint: poetry-export
tox -e lint
check:
uv run tox

format: poetry-export
tox -e format
typing:
uv run tox -e typing

lint:
uv run tox -e lint

#########################
#### Helper commands ####
#########################
poetry-export:
poetry export -f requirements.txt --output /tmp/requirements.txt --with dev
format:
uv run tox -e format


#########################
###### CI commands ######
#########################
ci-test:
poetry run pytest
uv run pytest

ci-coverage:
poetry run pytest --cov --cov-report lcov
uv run pytest --cov --cov-report lcov
98 changes: 57 additions & 41 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
[tool.poetry]
[project]
name = "sqlalchemy-bind-manager"
version = "0.0.0"
dynamic = ["version"]
description = "A manager to easily handle multiple SQLAlchemy configurations"
license = "MIT"
authors = ["Federico Busetti <[email protected]>"]
repository = "https://github.com/febus982/sqlalchemy-bind-manager"
homepage = "https://febus982.github.io/sqlalchemy-bind-manager"
authors = [{ name = "Federico Busetti", email = "[email protected]" }]
requires-python = ">=3.9,<3.14"
readme = "README.md"
packages = [{include = "sqlalchemy_bind_manager"}]
keywords = ["sqlalchemy", "config", "manager"]
license = "MIT"
keywords = [
"sqlalchemy",
"config",
"manager",
]
classifiers = [
"Development Status :: 4 - Beta",
"Framework :: AsyncIO",
Expand All @@ -28,52 +30,63 @@ classifiers = [
"Topic :: Database",
"Topic :: Database :: Front-Ends",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed"
"Typing :: Typed",
]
dependencies = [
"pydantic>=2.1.1,<3",
"SQLAlchemy[asyncio, mypy]~=2.0.0",
]

[project.urls]
Homepage = "https://febus982.github.io/sqlalchemy-bind-manager"
Repository = "https://github.com/febus982/sqlalchemy-bind-manager"

[dependency-groups]
dev = [
"aiosqlite>=0.18.0",
"coverage>=6.5.0",
"mike>=2.0.0",
"mkdocs>=1.4.3",
"mkdocstrings[python]>=0.24.0",
"mkdocs-awesome-pages-plugin>=2.9.2,<3",
"mkdocs-gen-files>=0.5.0",
"mkdocs-material>=9.1.16",
"mypy>=0.990",
"poetry-plugin-export",
"pymdown-extensions>=10.0.1",
"pytest>=8.0.0,<9",
"pytest-asyncio>=0.20.3",
"pytest-cov>=4.0.0",
"pytest-factoryboy>=2.5.0",
"pytest-xdist>=3.0.2",
"ruff>=0.0.263",
"tox>=4.14.1,<5",
"tox-uv>=1.26.0",
"uv-dynamic-versioning>=0.8.2",
]

[tool.poetry-dynamic-versioning]
enable = true

[build-system]
requires = ["poetry-core", "poetry-dynamic-versioning"]
build-backend = "poetry_dynamic_versioning.backend"
requires = ["hatchling", "uv-dynamic-versioning"]
build-backend = "hatchling.build"

[tool.poetry.dependencies]
python = ">=3.9,<3.14"
pydantic = "^2.1.1"
SQLAlchemy = { version = "~2.0.0", extras = ["asyncio", "mypy"] }
[tool.hatch.build.targets.sdist]
include = ["sqlalchemy_bind_manager"]

[tool.poetry.group.dev]
optional = true
[tool.hatch.build.targets.wheel]
include = ["sqlalchemy_bind_manager"]

[tool.poetry.group.dev.dependencies]
aiosqlite = ">=0.18.0"
coverage = ">=6.5.0"
mike = ">=2.0.0"
mkdocs = ">=1.4.3"
mkdocstrings = { version = ">=0.24.0", extras = ["python"] }
mkdocs-awesome-pages-plugin = "^2.9.2"
mkdocs-gen-files = ">=0.5.0"
mkdocs-material = ">=9.1.16"
mypy = ">=0.990"
poetry-plugin-export = "*"
pymdown-extensions = ">=10.0.1"
pytest = "^8.0.0"
pytest-asyncio = ">=0.20.3"
pytest-cov = ">=4.0.0"
pytest-factoryboy = ">=2.5.0"
pytest-xdist = ">=3.0.2"
ruff = ">=0.0.263"
tox = "^4.14.1"
[tool.hatch.version]
source = "uv-dynamic-versioning"

[tool.hatch.build.hooks.version]
path = "sqlalchemy_bind_manager/version.py"

############################
### Tools configuration ###
############################
[tool.coverage.run]
branch = true
source = ["sqlalchemy_bind_manager"]
# It's not necessary to setup concurrency here
# because pytest-cov takes care of that

[tool.coverage.report]
fail_under = 100
Expand All @@ -82,6 +95,9 @@ exclude_also = [
"pass",
"\\.\\.\\.",
]
omit = [
"sqlalchemy_bind_manager/version.py",
]

[tool.mypy]
files = "sqlalchemy_bind_manager"
Expand Down
4 changes: 3 additions & 1 deletion scripts/docs-version.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

VERSION=$(poetry version -s)
# uv doesn't yet support reading dynamic version: https://github.com/astral-sh/uv/issues/14137
#VERSION=$(uv version --short)
VERSION=$(uv run scripts/version_from_git.py)
SEMVER=( ${VERSION//./ } )
echo "${SEMVER[0]}.${SEMVER[1]}"
23 changes: 23 additions & 0 deletions scripts/version_from_git.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (c) 2025 Federico Busetti <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
from dunamai import Version

version = Version.from_git().serialize()
print(version)
Loading