diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 00000000..95cb3eea --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1 @@ +ref-names: $Format:%D$ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..ec8c3333 --- /dev/null +++ b/.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 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 9ac30d0d..5fba73ba 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -19,5 +19,7 @@ formats: - epub python: - install: - - requirements: requirements-dev.txt + install: + - requirements: requirements-dev.txt + - method: pip + path: . diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 95727af4..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -include LICENSE -include CHANGES.txt -include README.rst -graft aiomysql -global-exclude *.pyc *.swp diff --git a/aiomysql/.gitignore b/aiomysql/.gitignore new file mode 100644 index 00000000..91cb299f --- /dev/null +++ b/aiomysql/.gitignore @@ -0,0 +1 @@ +/_scm_version.py diff --git a/aiomysql/__init__.py b/aiomysql/__init__.py index 1b08ab56..a367fcd2 100644 --- a/aiomysql/__init__.py +++ b/aiomysql/__init__.py @@ -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__ = [ diff --git a/aiomysql/_scm_version.pyi b/aiomysql/_scm_version.pyi new file mode 100644 index 00000000..deb2e36a --- /dev/null +++ b/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 diff --git a/aiomysql/_version.py b/aiomysql/_version.py new file mode 100644 index 00000000..80af3cd2 --- /dev/null +++ b/aiomysql/_version.py @@ -0,0 +1,4 @@ +try: + from ._scm_version import version +except ImportError: + version = "unknown" diff --git a/docs/conf.py b/docs/conf.py index 4a4019e1..027c81c5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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', @@ -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. diff --git a/pyproject.toml b/pyproject.toml index 05e4daa9..4e903b7d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"