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

Use setuptools-scm for versioning #748

Merged
merged 4 commits into from
Apr 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .git_archival.txt
@@ -0,0 +1 @@
ref-names: $Format:%D$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Nothing4You FYI the recent versions of setuptools-scm need a more complete template — the current one has 4 lines, not just one.

5 changes: 5 additions & 0 deletions .gitattributes
@@ -0,0 +1,5 @@
# Force LF line endings for text files
* text=auto eol=lf

# Needed for setuptools-scm-git-archive
.git_archival.txt export-subst
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -58,6 +58,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python ${{ matrix.py }}
uses: actions/setup-python@v3
Expand Down
6 changes: 4 additions & 2 deletions .readthedocs.yaml
Expand Up @@ -19,5 +19,7 @@ formats:
- epub

python:
install:
- requirements: requirements-dev.txt
install:
- requirements: requirements-dev.txt
- method: pip
path: .
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -24,6 +24,7 @@ To be included in 1.0.0 (unreleased)
* Required python version is now properly documented in python_requires instead of failing on setup.py execution #731
* Add rsa extras_require depending on PyMySQL[rsa] #557
* Migrate to PEP 517 build system #746
* Self-reported `__version__` now returns version generated by `setuptools-scm` during build, otherwise `'unknown'` #748


0.0.22 (2021-11-14)
Expand Down
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

9 changes: 9 additions & 0 deletions Makefile
Expand Up @@ -44,7 +44,16 @@ start_mysql:
stop_mysql:
docker-compose -f docker-compose.yml stop mysql

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

Expand Down
1 change: 1 addition & 0 deletions aiomysql/.gitignore
@@ -0,0 +1 @@
/_scm_version.py
3 changes: 2 additions & 1 deletion aiomysql/__init__.py
Expand Up @@ -32,8 +32,9 @@
from .connection import Connection, connect
from .cursors import Cursor, SSCursor, DictCursor, SSDictCursor
from .pool import create_pool, Pool
from ._version import version

__version__ = '0.0.22'
__version__ = version

__all__ = [

Expand Down
3 changes: 3 additions & 0 deletions aiomysql/_scm_version.pyi
@@ -0,0 +1,3 @@
# This stub file is necessary because `_scm_version.py`
# autogenerated on build and absent on mypy checks time
version: str
4 changes: 4 additions & 0 deletions aiomysql/_version.py
@@ -0,0 +1,4 @@
try:
from ._scm_version import version
except ImportError:
version = "unknown"
25 changes: 4 additions & 21 deletions docs/conf.py
Expand Up @@ -30,25 +30,8 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.

import re, os.path

def get_release():
regexp = re.compile(r"^__version__\W*=\W*'([\d.abrc]+)'")
here = os.path.dirname(__file__)
root = os.path.dirname(here)
init_py = os.path.join(root, 'aiomysql', '__init__.py')
with open(init_py) as f:
for line in f:
match = regexp.match(line)
if match is not None:
return match.group(1)
else:
raise RuntimeError('Cannot find version in aiomysql/__init__.py')


def get_version(release):
parts = release.split('.')
return '.'.join(parts[:2])
from aiomysql import __version__


extensions = [
'sphinx.ext.autodoc',
Expand Down Expand Up @@ -82,8 +65,8 @@ def get_version(release):
# |version| and |release|, also used in various other places throughout the
# built documents.
#
release = get_release()
version = get_version(release)
release = __version__
version = '.'.join(__version__.split('.')[:2])

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Expand Up @@ -2,5 +2,12 @@
requires = [
# Essentials
"setuptools >= 42",

# Plugins
"setuptools_scm[toml] >= 6.4",
"setuptools_scm_git_archive >= 1.1",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "aiomysql/_scm_version.py"