Skip to content

Commit fd619d6

Browse files
Maintenance work
1 parent ce54994 commit fd619d6

13 files changed

Lines changed: 160 additions & 123 deletions

File tree

.github/workflows/build.yml

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Build
22

33
on:
4+
workflow_dispatch:
45
release:
56
types: [published]
67
push:
@@ -16,11 +17,11 @@ env:
1617

1718
jobs:
1819
build:
19-
runs-on: ubuntu-18.04
20+
runs-on: ubuntu-latest
2021
strategy:
2122
fail-fast: false
2223
matrix:
23-
python-version: [3.8, 3.9, "3.10", "3.11"]
24+
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
2425

2526
steps:
2627
- uses: actions/checkout@v1
@@ -59,39 +60,50 @@ jobs:
5960
bash <(curl -s https://codecov.io/bash)
6061
6162
- name: Install distribution dependencies
62-
run: pip install --upgrade twine setuptools wheel
63-
if: matrix.python-version == 3.8 || matrix.python-version == 3.9
63+
run: pip install build
64+
if: matrix.python-version == 3.12
6465

6566
- name: Create distribution package
66-
run: python setup.py sdist bdist_wheel
67-
if: matrix.python-version == 3.8 || matrix.python-version == 3.9
67+
run: python -m build
68+
if: matrix.python-version == 3.12
6869

6970
- name: Upload distribution package
70-
uses: actions/upload-artifact@master
71+
uses: actions/upload-artifact@v4
7172
with:
72-
name: dist-package-${{ matrix.python-version }}
73+
name: dist
7374
path: dist
74-
if: matrix.python-version == 3.8 || matrix.python-version == 3.9
75+
if: matrix.python-version == 3.12
7576

7677
publish:
77-
runs-on: ubuntu-18.04
78+
runs-on: ubuntu-latest
7879
needs: build
79-
if: github.event_name == 'release'
80+
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
8081
steps:
8182
- name: Download a distribution artifact
82-
uses: actions/download-artifact@v2
83+
uses: actions/download-artifact@v4
8384
with:
84-
name: dist-package-3.9
85+
name: dist
8586
path: dist
86-
- name: Publish distribution 📦 to Test PyPI
87-
uses: pypa/gh-action-pypi-publish@master
87+
88+
- name: Use Python 3.12
89+
uses: actions/setup-python@v1
8890
with:
89-
skip_existing: true
90-
user: __token__
91-
password: ${{ secrets.test_pypi_password }}
92-
repository_url: https://test.pypi.org/legacy/
91+
python-version: '3.12'
92+
93+
- name: Install dependencies
94+
run: |
95+
pip install twine
96+
97+
- name: Publish distribution 📦 to Test PyPI
98+
run: |
99+
twine upload -r testpypi dist/*
100+
env:
101+
TWINE_USERNAME: __token__
102+
TWINE_PASSWORD: ${{ secrets.test_pypi_password }}
103+
93104
- name: Publish distribution 📦 to PyPI
94-
uses: pypa/gh-action-pypi-publish@master
95-
with:
96-
user: __token__
97-
password: ${{ secrets.pypi_password }}
105+
run: |
106+
twine upload -r pypi dist/*
107+
env:
108+
TWINE_USERNAME: __token__
109+
TWINE_PASSWORD: ${{ secrets.pypi_password }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,5 @@ dmypy.json
128128
# Pyre type checker
129129
.pyre/
130130
/tests/example.db
131+
132+
example.db

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.3] - 2023-12-29 :christmas_tree:
9+
- Upgrades the library to use `pyproject.toml`.
10+
- Updates the GitHub Workflow.
11+
- Updates the LICENSE contact.
12+
813
## [0.0.2] - 2021-11-28 :sheep:
914
- Unpins the `SQLAlchemy` version from requirements
1015

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Neoteroi
3+
Copyright (c) 2021, current Roberto Prevato <roberto.prevato@gmail.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ simplifies the use of SQLAlchemy in the web framework.
1111
pip install blacksheep-sqlalchemy
1212
```
1313

14+
**Important:** this library only supports `rodi` dependency injection
15+
container. However, the implementation can be used for reference to configure
16+
other DI containers to work with SQLAlchemy.
17+
1418
## How to use
1519

1620
```python
@@ -64,7 +68,7 @@ For example, using SQLite:
6468
* requires driver: `pip install aiosqlite`
6569
* connection string: `sqlite+aiosqlite:///example.db`
6670

67-
See the `tests` folder for a [working example](https://github.com/Neoteroi/BlackSheep-SQLAlchemy/blob/main/tests/app.py)
71+
See the `tests` folder for a [working example](https://github.com/Neoteroi/BlackSheep-SQLAlchemy/blob/main/tests/app.py)
6872
using database migrations applied with `Alembic`, and a documented API that offers methods to fetch, create,
6973
delete countries objects.
7074

blacksheepsqlalchemy/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Optional
22

33
from blacksheep.server import Application
4+
from rodi import Container
45
from sqlalchemy.ext.asyncio import (
56
AsyncConnection,
67
AsyncEngine,
@@ -31,6 +32,9 @@ def connection_factory() -> AsyncConnection:
3132
def session_factory() -> AsyncSession:
3233
return AsyncSession(engine, expire_on_commit=False)
3334

35+
assert isinstance(
36+
app.services, Container
37+
), "blacksheep-sqlalchemy only supports rodi for dependency injection"
3438
app.services.add_instance(engine)
3539
app.services.add_alias(db_engine_alias, AsyncEngine)
3640

dev-requirements.txt

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
1-
aiosqlite==0.17.0
2-
alembic==1.8.1
3-
attrs==22.1.0
4-
black==22.10.0
5-
blacksheep==1.2.8
6-
certifi==2022.9.24
7-
click==8.1.3
8-
coverage==6.5.0
1+
aiosqlite==0.19.0
2+
alembic==1.13.1
3+
attrs==23.1.0
4+
black==23.12.1
5+
blacksheep==2.0.3
6+
certifi==2023.11.17
7+
charset-normalizer==3.1.0
8+
click==8.1.7
9+
coverage==7.4.0
910
essentials==1.1.5
10-
essentials-openapi==0.1.6
11-
exceptiongroup==1.0.4
12-
flake8==6.0.0
13-
greenlet==2.0.1
14-
guardpost==0.0.9
11+
essentials-openapi==1.0.9
12+
exceptiongroup==1.2.0
13+
flake8==6.1.0
14+
greenlet==3.0.3
15+
guardpost==1.0.2
1516
h11==0.14.0
16-
httptools==0.5.0
17-
iniconfig==1.1.1
18-
isort==5.10.1
17+
httptools==0.6.1
18+
iniconfig==2.0.0
19+
isort==5.13.2
1920
itsdangerous==2.1.2
2021
Jinja2==3.1.2
21-
Mako==1.2.4
22-
MarkupSafe==2.1.1
22+
Mako==1.3.0
23+
MarkupSafe==2.1.3
2324
mccabe==0.7.0
24-
mypy-extensions==0.4.3
25-
packaging==21.3
26-
pathspec==0.10.2
27-
platformdirs==2.5.4
28-
pluggy==1.0.0
29-
pycodestyle==2.10.0
30-
pyflakes==3.0.1
31-
pyparsing==3.0.9
32-
pytest==7.2.0
33-
pytest-asyncio==0.20.2
34-
pytest-cov==4.0.0
25+
mypy-extensions==1.0.0
26+
packaging==23.2
27+
pathspec==0.12.1
28+
platformdirs==4.1.0
29+
pluggy==1.3.0
30+
pycodestyle==2.11.1
31+
pyflakes==3.1.0
32+
pyparsing==3.1.1
33+
pytest==7.4.3
34+
pytest-asyncio==0.23.2
35+
pytest-cov==4.1.0
3536
python-dateutil==2.8.2
36-
PyYAML==5.4.1
37-
rodi==1.1.3
37+
PyYAML==6.0.1
38+
rodi==2.0.6
3839
six==1.16.0
39-
SQLAlchemy==1.4.44
40+
SQLAlchemy==2.0.24
4041
tomli==2.0.1
41-
typing_extensions==4.4.0
42-
uvicorn==0.20.0
42+
typing_extensions==4.9.0
43+
uvicorn==0.25.0

pyproject.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "blacksheep-sqlalchemy"
7+
version = "0.0.3"
8+
authors = [{ name = "Roberto Prevato", email = "roberto.prevato@gmail.com" }]
9+
description = "Extension for BlackSheep to use SQLAlchemy."
10+
readme = "README.md"
11+
requires-python = ">=3.7"
12+
classifiers = [
13+
"Development Status :: 5 - Production/Stable",
14+
"License :: OSI Approved :: MIT License",
15+
"Programming Language :: Python :: 3",
16+
"Programming Language :: Python :: 3.8",
17+
"Programming Language :: Python :: 3.9",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
"Operating System :: OS Independent",
22+
]
23+
keywords = ["blacksheep", "sqlalchemy", "orm", "database"]
24+
25+
dependencies = ["blacksheep", "SQLAlchemy"]
26+
27+
[tool.hatch.build.targets.wheel]
28+
packages = ["blacksheepsqlalchemy"]
29+
30+
[tool.hatch.build.targets.sdist]
31+
exclude = ["tests"]
32+
33+
[tool.hatch.build]
34+
only-packages = true
35+
36+
[project.urls]
37+
"Homepage" = "https://github.com/Neoteroi/BlackSheep-SQLAlchemy"
38+
"Bug Tracker" = "https://github.com/Neoteroi/BlackSheep-SQLAlchemy/issues"
39+
40+
[tool.pytest.ini_options]
41+
asyncio_mode = "auto"

setup.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)