Skip to content

Commit 4e26b67

Browse files
authored
Migrate to hatch (#40)
* Migrate to hatch * Disable pip cache * Use hatch to publish package * Disable pip cache
1 parent 48f45fb commit 4e26b67

File tree

8 files changed

+109
-94
lines changed

8 files changed

+109
-94
lines changed

.github/workflows/build-docs.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,11 @@ jobs:
66
deploy:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: "actions/checkout@v3"
10-
- uses: "actions/setup-python@v4"
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-python@v4
1111
with:
1212
python-version: 3.8
13-
- name: Install poetry
14-
run: |
15-
python -m pip install --upgrade pip
16-
curl -sSL https://install.python-poetry.org | python3 -
17-
- name: Configure poetry
18-
run: poetry config virtualenvs.create false
19-
- name: Install dependencies
20-
run: poetry install
21-
- run: mkdocs gh-deploy --force
13+
cache: "pip"
14+
- name: Install Dependencies
15+
run: pip install hatch
16+
- run: hatch run docs:deploy

.github/workflows/publish.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,12 @@ jobs:
1717
- uses: "actions/setup-python@v4"
1818
with:
1919
python-version: 3.9
20-
- name: Install poetry
21-
run: |
22-
python -m pip install --upgrade pip
23-
curl -sSL https://install.python-poetry.org | python3 -
24-
- name: Configure poetry
25-
run: poetry config virtualenvs.create false
26-
- name: Install dependencies
27-
run: poetry install
20+
- name: Install Dependencies
21+
run: pip install hatch
22+
- name: Build
23+
run: hatch build
2824
- name: Publish
2925
env:
30-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
31-
run: |
32-
poetry config pypi-token.pypi $PYPI_TOKEN
33-
poetry publish --build
26+
HATCH_INDEX_USER: __token__
27+
HATCH_INDEX_AUTH: ${{ secrets.PYPI_TOKEN }}
28+
run: hatch publish

.github/workflows/test.yml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,28 @@ jobs:
5252
uses: actions/setup-python@v4
5353
with:
5454
python-version: ${{ matrix.python-version }}
55-
- name: Install poetry
56-
run: |
57-
python -m pip install --upgrade pip
58-
curl -sSL https://install.python-poetry.org | python3 -
59-
- name: Configure poetry
60-
run: poetry config virtualenvs.create false
61-
- name: Install dependencies
62-
run: poetry install
55+
- name: Install Dependencies
56+
run: pip install hatch
6357
- name: Lint
64-
run: poetry run bash scripts/lint.sh
58+
run: hatch run test:lint
6559
- name: Test Local Storage provider & sqlite
6660
env:
6761
ENGINE: 'sqlite:///test.db?check_same_thread=False'
6862
STORAGE_PROVIDER: 'LOCAL'
6963
LOCAL_PATH: '/tmp/storage'
70-
run: poetry run coverage run -m pytest tests
64+
run: hatch run test:all
7165
- name: Test Local Storage provider & postgresql
7266
env:
7367
ENGINE: 'postgresql+psycopg2://username:password@localhost:5432/test_db'
7468
STORAGE_PROVIDER: 'LOCAL'
7569
LOCAL_PATH: '/tmp/storage'
76-
run: poetry run coverage run -m pytest tests
70+
run: hatch run test:all
7771
- name: Test Local Storage provider & mysql
7872
env:
7973
ENGINE: 'mysql+pymysql://username:password@localhost:3306/test_db'
8074
STORAGE_PROVIDER: 'LOCAL'
8175
LOCAL_PATH: '/tmp/storage'
82-
run: poetry run coverage run -m pytest tests
76+
run: hatch run test:all
8377
- name: Test Minio Storage provider & sqlite memory
8478
env:
8579
ENGINE: 'sqlite:///:memory:?check_same_thread=False'
@@ -89,8 +83,8 @@ jobs:
8983
MINIO_HOST: 'localhost'
9084
MINIO_PORT: 9000
9185
MINIO_SECURE: false
92-
run: poetry run coverage run -m pytest tests
86+
run: hatch run test:all
9387
- name: Coverage Report
94-
run: poetry run bash scripts/coverage.sh
88+
run: hatch run test:cov
9589
- name: Upload coverage
9690
uses: codecov/codecov-action@v3

pyproject.toml

Lines changed: 87 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
[tool.poetry]
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
26
name = "sqlalchemy-file"
3-
version = "0.3.0"
47
description = "SQLAlchemy-file is a SQLAlchemy extension for attaching files to SQLAlchemy model and uploading them to various storage."
5-
authors = ["Jocelin Hounon <hounonj@gmail.com>"]
6-
license = "MIT"
78
readme = "README.md"
8-
homepage = "https://jowilf.github.io/sqlalchemy-file"
9-
repository = "https://github.com/jowilf/sqlalchemy-file"
10-
documentation = "https://jowilf.github.io/sqlalchemy-file"
9+
license = "MIT"
10+
requires-python = ">=3.7"
1111
keywords = ["sqlalchemy", "sqlmodel", "file-upload", "apache-libcloud"]
12+
authors = [
13+
{ name = "Jocelin Hounon", email = "hounonj@gmail.com" },
14+
]
1215
classifiers = [
1316
'Development Status :: 4 - Beta',
1417
"Framework :: AsyncIO",
@@ -26,32 +29,83 @@ classifiers = [
2629
"Topic :: Database",
2730
"Topic :: Database :: Database Engines/Servers",
2831
]
32+
dependencies = [
33+
"SQLAlchemy >=1.4, <1.5",
34+
"apache-libcloud >=3.6, <3.8",
35+
]
36+
dynamic = ["version"]
37+
38+
[project.urls]
39+
Homepage = "https://jowilf.github.io/sqlalchemy-file"
40+
Documentation = "https://jowilf.github.io/sqlalchemy-file"
41+
Repository = "https://github.com/jowilf/sqlalchemy-file"
42+
Changelog = "https://jowilf.github.io/sqlalchemy-file/changelog/"
43+
44+
[project.optional-dependencies]
45+
test = [
46+
"pytest >=7.2.0, <7.3.0",
47+
"mypy ==0.991",
48+
"ruff ==0.0.215",
49+
"black ==22.12.0",
50+
"coverage >=7.0.0, <7.1.0",
51+
"fasteners ==0.18",
52+
"PyMySQL[rsa] >=1.0.2, <1.1.0",
53+
"psycopg2-binary >=2.9.5, <3.0.0",
54+
"Pillow >=9.4.0, <9.5.0",
55+
"sqlmodel ==0.0.8",
56+
"python-multipart ==0.0.5",
57+
"fastapi >=0.92, <0.93",
58+
"Flask >=2.2, <2.3",
59+
"Flask-SQLAlchemy >=3.0,<3.1"
60+
]
61+
doc = [
62+
"mkdocs-material >=9.0.0, <10.0.0",
63+
"mkdocstrings[python] >=0.19.0, <0.21.0"
64+
]
65+
dev = [
66+
"pre-commit >=2.20.0, <3.0.0",
67+
"uvicorn >=0.20.0, <0.21.0",
68+
]
2969

30-
[tool.poetry.dependencies]
31-
python = "^3.7"
32-
SQLAlchemy = ">=1.4,<1.5"
33-
apache-libcloud = ">=3.6.0,<3.8"
70+
[tool.hatch.envs.default]
71+
features = [
72+
"test",
73+
"dev"
74+
]
75+
[tool.hatch.envs.default.scripts]
76+
format = [
77+
"ruff sqlalchemy_file tests docs_src --fix",
78+
"black ."
79+
]
80+
81+
[tool.hatch.envs.test]
82+
features = [
83+
"test",
84+
]
85+
[tool.hatch.envs.test.scripts]
86+
lint = [
87+
"mypy sqlalchemy_file",
88+
"ruff sqlalchemy_file tests",
89+
"black . --check"
90+
]
91+
all = "coverage run -m pytest tests"
92+
cov = [
93+
"coverage combine",
94+
"coverage report --show-missing",
95+
"coverage xml"
96+
]
3497

35-
[tool.poetry.group.dev.dependencies]
36-
pytest = "^7.2.0"
37-
mypy = "0.991"
38-
black = "22.12.0"
39-
ruff = "0.0.215"
40-
sqlmodel = "^0.0.8"
41-
Pillow = "^9.3.0"
42-
fasteners = "^0.18"
43-
coverage = { extras = ["toml"], version = "^7.0.4" }
44-
mkdocs-material = "^9.0.3"
45-
PyMySQL = { extras = ["rsa"], version = "^1.0.2" }
46-
psycopg2-binary = "^2.9.5"
47-
mkdocstrings = { extras = ["python"], version = "^0.19.0" }
48-
fastapi = "^0.89.0"
49-
uvicorn = "^0.20.0"
50-
python-multipart = "^0.0.5"
51-
Flask = "^2.2.2"
52-
Flask-SQLAlchemy = "^3.0.2"
53-
pre-commit = "^2.20.0"
98+
[tool.hatch.envs.docs]
99+
features = [
100+
"doc",
101+
]
102+
[tool.hatch.envs.docs.scripts]
103+
serve = "mkdocs serve -a localhost:8080"
104+
build = "mkdocs build"
105+
deploy = "mkdocs gh-deploy --force"
54106

107+
[tool.hatch.version]
108+
path = "sqlalchemy_file/__init__.py"
55109

56110
[tool.coverage.report]
57111
fail_under = 99
@@ -83,7 +137,6 @@ known-third-party = ["sqlalchemy_file"]
83137
[tool.mypy]
84138
strict = true
85139

86-
87-
[build-system]
88-
requires = ["poetry-core>=1.0.0"]
89-
build-backend = "poetry.core.masonry.api"
140+
[tool.hatch.build.targets.wheel]
141+
[tool.hatch.build.targets.sdist]
142+
include = ["sqlalchemy_file"]

scripts/coverage.sh

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

scripts/format.sh

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

scripts/lint.sh

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

sqlalchemy_file/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.3.0"
1+
__version__ = "0.4.0.dev0"
22

33
from .file import File as File
44
from .types import FileField as FileField

0 commit comments

Comments
 (0)