Skip to content

Commit 1697e15

Browse files
Use setuptools-scm for versioning (#748)
Use setuptools-scm for versioning - generate aiomysql/_scm_version.py at build time, fallback to `unknown` if it doesn't exist - include setuptools-scm-git-archive to support versioning in archives from git tags - install aiomysql package in readthedocs and access generated version to embed in docs - fetch git context in workflow to ensure we have all information for setuptools-scm to work - fetch git context in `make doc` Split from #734, including suggestions from @webknjaz Co-authored-by: Sviatoslav Sydorenko <[email protected]>
1 parent 42532c8 commit 1697e15

File tree

13 files changed

+43
-29
lines changed

13 files changed

+43
-29
lines changed

.git_archival.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ref-names: $Format:%D$

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Force LF line endings for text files
2+
* text=auto eol=lf
3+
4+
# Needed for setuptools-scm-git-archive
5+
.git_archival.txt export-subst

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ jobs:
5858
steps:
5959
- name: Checkout
6060
uses: actions/checkout@v3
61+
with:
62+
fetch-depth: 0
6163

6264
- name: Setup Python ${{ matrix.py }}
6365
uses: actions/setup-python@v3

.readthedocs.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,7 @@ formats:
1919
- epub
2020

2121
python:
22-
install:
23-
- requirements: requirements-dev.txt
22+
install:
23+
- requirements: requirements-dev.txt
24+
- method: pip
25+
path: .

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ To be included in 1.0.0 (unreleased)
2424
* Required python version is now properly documented in python_requires instead of failing on setup.py execution #731
2525
* Add rsa extras_require depending on PyMySQL[rsa] #557
2626
* Migrate to PEP 517 build system #746
27+
* Self-reported `__version__` now returns version generated by `setuptools-scm` during build, otherwise `'unknown'` #748
2728

2829

2930
0.0.22 (2021-11-14)

MANIFEST.in

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

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,16 @@ start_mysql:
4444
stop_mysql:
4545
docker-compose -f docker-compose.yml stop mysql
4646

47+
# TODO: this depends on aiomysql being installed, e.g. in a venv.
48+
# TODO: maybe this can be solved better.
4749
doc:
50+
@echo "----------------------------------------------------------------"
51+
@echo "Doc builds require installing the aiomysql package in the"
52+
@echo "environment. Make sure you've installed your current dev version"
53+
@echo "into your environment, e.g. using venv, then run this command in"
54+
@echo "the virtual environment."
55+
@echo "----------------------------------------------------------------"
56+
git fetch --tags --all
4857
make -C docs html
4958
@echo "open file://`pwd`/docs/_build/html/index.html"
5059

aiomysql/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/_scm_version.py

aiomysql/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
from .connection import Connection, connect
3333
from .cursors import Cursor, SSCursor, DictCursor, SSDictCursor
3434
from .pool import create_pool, Pool
35+
from ._version import version
3536

36-
__version__ = '0.0.22'
37+
__version__ = version
3738

3839
__all__ = [
3940

aiomysql/_scm_version.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This stub file is necessary because `_scm_version.py`
2+
# autogenerated on build and absent on mypy checks time
3+
version: str

0 commit comments

Comments
 (0)