Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintenance work #5

Merged
merged 5 commits into from
Dec 29, 2023
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
58 changes: 35 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build

on:
workflow_dispatch:
release:
types: [published]
push:
Expand All @@ -16,11 +17,11 @@ env:

jobs:
build:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v1
Expand Down Expand Up @@ -59,39 +60,50 @@ jobs:
bash <(curl -s https://codecov.io/bash)

- name: Install distribution dependencies
run: pip install --upgrade twine setuptools wheel
if: matrix.python-version == 3.8 || matrix.python-version == 3.9
run: pip install build
if: matrix.python-version == 3.12

- name: Create distribution package
run: python setup.py sdist bdist_wheel
if: matrix.python-version == 3.8 || matrix.python-version == 3.9
run: python -m build
if: matrix.python-version == 3.12

- name: Upload distribution package
uses: actions/upload-artifact@master
uses: actions/upload-artifact@v4
with:
name: dist-package-${{ matrix.python-version }}
name: dist
path: dist
if: matrix.python-version == 3.8 || matrix.python-version == 3.9
if: matrix.python-version == 3.12

publish:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release'
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
steps:
- name: Download a distribution artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: dist-package-3.9
name: dist
path: dist
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master

- name: Use Python 3.12
uses: actions/setup-python@v1
with:
skip_existing: true
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
python-version: '3.12'

- name: Install dependencies
run: |
pip install twine

- name: Publish distribution 📦 to Test PyPI
run: |
twine upload -r testpypi dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.test_pypi_password }}

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
run: |
twine upload -r pypi dist/*
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.pypi_password }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ dmypy.json
# Pyre type checker
.pyre/
/tests/example.db

example.db
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.3] - 2023-12-29 :christmas_tree:
- Upgrades the library to use `pyproject.toml`.
- Updates the GitHub Workflow.
- Updates the LICENSE contact.

## [0.0.2] - 2021-11-28 :sheep:
- Unpins the `SQLAlchemy` version from requirements

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

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

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ simplifies the use of SQLAlchemy in the web framework.
pip install blacksheep-sqlalchemy
```

**Important:** this library only supports `rodi` dependency injection
container. However, the implementation can be used for reference to configure
other DI containers to work with SQLAlchemy.

## How to use

```python
Expand Down Expand Up @@ -64,7 +68,7 @@ For example, using SQLite:
* requires driver: `pip install aiosqlite`
* connection string: `sqlite+aiosqlite:///example.db`

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

Expand Down
4 changes: 4 additions & 0 deletions blacksheepsqlalchemy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional

from blacksheep.server import Application
from rodi import Container
from sqlalchemy.ext.asyncio import (
AsyncConnection,
AsyncEngine,
Expand Down Expand Up @@ -31,6 +32,9 @@ def connection_factory() -> AsyncConnection:
def session_factory() -> AsyncSession:
return AsyncSession(engine, expire_on_commit=False)

assert isinstance(
app.services, Container
), "blacksheep-sqlalchemy only supports rodi for dependency injection"
app.services.add_instance(engine)
app.services.add_alias(db_engine_alias, AsyncEngine)

Expand Down
69 changes: 35 additions & 34 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
aiosqlite==0.17.0
alembic==1.8.1
attrs==22.1.0
black==22.10.0
blacksheep==1.2.8
certifi==2022.9.24
click==8.1.3
coverage==6.5.0
aiosqlite==0.19.0
alembic==1.13.1
attrs==23.1.0
black==23.12.1
blacksheep==2.0.3
certifi==2023.11.17
charset-normalizer==3.1.0
click==8.1.7
coverage==7.4.0
essentials==1.1.5
essentials-openapi==0.1.6
exceptiongroup==1.0.4
flake8==6.0.0
greenlet==2.0.1
guardpost==0.0.9
essentials-openapi==1.0.9
exceptiongroup==1.2.0
flake8==6.1.0
greenlet==3.0.3
guardpost==1.0.2
h11==0.14.0
httptools==0.5.0
iniconfig==1.1.1
isort==5.10.1
httptools==0.6.1
iniconfig==2.0.0
isort==5.13.2
itsdangerous==2.1.2
Jinja2==3.1.2
Mako==1.2.4
MarkupSafe==2.1.1
Mako==1.3.0
MarkupSafe==2.1.3
mccabe==0.7.0
mypy-extensions==0.4.3
packaging==21.3
pathspec==0.10.2
platformdirs==2.5.4
pluggy==1.0.0
pycodestyle==2.10.0
pyflakes==3.0.1
pyparsing==3.0.9
pytest==7.2.0
pytest-asyncio==0.20.2
pytest-cov==4.0.0
mypy-extensions==1.0.0
packaging==23.2
pathspec==0.12.1
platformdirs==4.1.0
pluggy==1.3.0
pycodestyle==2.11.1
pyflakes==3.1.0
pyparsing==3.1.1
pytest==7.4.3
pytest-asyncio==0.23.2
pytest-cov==4.1.0
python-dateutil==2.8.2
PyYAML==5.4.1
rodi==1.1.3
PyYAML==6.0.1
rodi==2.0.6
six==1.16.0
SQLAlchemy==1.4.44
SQLAlchemy==2.0.24
tomli==2.0.1
typing_extensions==4.4.0
uvicorn==0.20.0
typing_extensions==4.9.0
uvicorn==0.25.0
41 changes: 41 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "blacksheep-sqlalchemy"
version = "0.0.3"
authors = [{ name = "Roberto Prevato", email = "roberto.prevato@gmail.com" }]
description = "Extension for BlackSheep to use SQLAlchemy."
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent",
]
keywords = ["blacksheep", "sqlalchemy", "orm", "database"]

dependencies = ["blacksheep", "SQLAlchemy"]

[tool.hatch.build.targets.wheel]
packages = ["blacksheepsqlalchemy"]

[tool.hatch.build.targets.sdist]
exclude = ["tests"]

[tool.hatch.build]
only-packages = true

[project.urls]
"Homepage" = "https://github.com/Neoteroi/BlackSheep-SQLAlchemy"
"Bug Tracker" = "https://github.com/Neoteroi/BlackSheep-SQLAlchemy/issues"

[tool.pytest.ini_options]
asyncio_mode = "auto"
34 changes: 0 additions & 34 deletions setup.py

This file was deleted.

Loading