From 81e52e04be88eaa0416322c758d96a998413b373 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Thu, 30 Apr 2020 10:16:07 +0100 Subject: [PATCH] add uharfbuzz.__version__ --- .gitignore | 3 +++ setup.py | 2 +- src/uharfbuzz/__init__.py | 5 +++++ tests/test_uharfbuzz.py | 6 ++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 31a4557..bda6de5 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ htmlcov/ # Cython src/uharfbuzz/*.c src/uharfbuzz/*.html + +# autogenerated version file +src/uharfbuzz/_version.py diff --git a/setup.py b/setup.py index 0c916c8..1ed70d8 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ setup_params = dict( name="uharfbuzz", - use_scm_version=True, + use_scm_version={"write_to": "src/uharfbuzz/_version.py"}, description="Streamlined Cython bindings for the harfbuzz shaping engine", long_description=long_description, long_description_content_type='text/markdown', diff --git a/src/uharfbuzz/__init__.py b/src/uharfbuzz/__init__.py index 1b7cc4a..32b583a 100644 --- a/src/uharfbuzz/__init__.py +++ b/src/uharfbuzz/__init__.py @@ -1 +1,6 @@ +try: + from ._version import version as __version__ +except ImportError: + __version__ = "0.0.0+unknown" + from ._harfbuzz import * diff --git a/tests/test_uharfbuzz.py b/tests/test_uharfbuzz.py index 41ab03b..1577592 100644 --- a/tests/test_uharfbuzz.py +++ b/tests/test_uharfbuzz.py @@ -303,3 +303,9 @@ def test_ot_layout_script_get_language_tags(self, blankfont): def test_harfbuzz_version(): v = hb.version_string() assert isinstance(v, str) + + +def test_uharfbuzz_version(): + v = hb.__version__ + assert isinstance(v, str) + assert "unknown" not in v