diff --git a/CHANGELOG.rst b/CHANGELOG.rst index eb67c932..136392db 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,6 +9,10 @@ Changelog version 1.10.0-dev ------------------ ++ Speed up ``import isal`` by about 0.1 ms in programs that have not imported + ``__future__`` yet. The version module that is generated when isal is built + no longer imports ``__future__``. Building isal now requires setuptools-scm + 9.2 or later. + Fix ``igzip_threaded`` files that stopped working when the thread that opened them ended, for example a ``ThreadPoolExecutor`` thread after ``shutdown()``. Reads returned truncated data without an error, and writes diff --git a/pyproject.toml b/pyproject.toml index d1bbfb46..8cb0e2c2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=77", "setuptools-scm>=8"] +requires = ["setuptools>=77", "setuptools-scm>=9.2"] build-backend = "setuptools.build_meta" [project] @@ -36,6 +36,34 @@ urls.documentation = "https://python-isal.readthedocs.io" [tool.setuptools_scm] version_file = "src/isal/_version.py" +# The default template of setuptools-scm 10 without its +# "from __future__ import annotations", which slows down "import isal". +# scm_version.short_node needs setuptools-scm 9.2 or later. +version_file_template = ''' +# file generated by setuptools-scm +# don't change, don't track in version control + +__all__ = [ + "__version__", + "__version_tuple__", + "version", + "version_tuple", + "__commit_id__", + "commit_id", +] + +version: str +__version__: str +__version_tuple__: tuple[int | str, ...] +version_tuple: tuple[int | str, ...] +commit_id: str | None +__commit_id__: str | None + +__version__ = version = {version!r} +__version_tuple__ = version_tuple = {version_tuple!r} + +__commit_id__ = commit_id = {scm_version.short_node!r} +''' [tool.setuptools.packages.find] where = ["src"] diff --git a/src/isal/_version.pyi b/src/isal/_version.pyi index e59e7032..31f7d606 100644 --- a/src/isal/_version.pyi +++ b/src/isal/_version.pyi @@ -5,4 +5,9 @@ # This file is part of python-isal which is distributed under the # PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2. +version: str __version__: str +__version_tuple__: tuple[int | str, ...] +version_tuple: tuple[int | str, ...] +commit_id: str | None +__commit_id__: str | None diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 00000000..a3af6383 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,8 @@ +"""Check the version module that setuptools-scm writes.""" +from importlib import metadata + +import isal + + +def test_version_matches_package_metadata(): + assert isal.__version__ == metadata.version("isal")