From 17560207c636676484aa0ca62a8038f28cb2c9d6 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Thu, 26 Dec 2019 19:30:54 -0600 Subject: [PATCH] use dynamic version in ``gino.__version__`` --- README.rst | 4 ++-- poetry.lock | 8 ++++---- pyproject.toml | 1 + src/gino/__init__.py | 14 +++++++++++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/README.rst b/README.rst index 56c85cec..4be90d79 100644 --- a/README.rst +++ b/README.rst @@ -8,7 +8,7 @@ GINO .. image:: https://img.shields.io/github/workflow/status/python-gino/gino/test?label=test&logo=github :alt: GitHub Workflow Status - :target: https://github.com/python-gino/gino/actions?query=workflow%3Apytest + :target: https://github.com/python-gino/gino/actions?query=workflow%3Atest .. image:: https://img.shields.io/codacy/coverage/b6a59cdf5ca64eab9104928d4f9bbb97?logo=codacy :alt: Codacy coverage @@ -28,7 +28,7 @@ GINO GINO - GINO Is Not ORM - is a lightweight asynchronous ORM built on top of -SQLAlchemy_ core for Python asyncio_. Now (early 2018) GINO supports only one +SQLAlchemy_ core for Python asyncio_. Now (early 2020) GINO supports only one dialect asyncpg_. * Free software: BSD license diff --git a/poetry.lock b/poetry.lock index 89729ffe..dadd3195 100644 --- a/poetry.lock +++ b/poetry.lock @@ -189,7 +189,7 @@ python-versions = "*" version = "0.11" [[package]] -category = "dev" +category = "main" description = "Read metadata from Python packages" marker = "python_version < \"3.8\"" name = "importlib-metadata" @@ -239,7 +239,7 @@ python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*" version = "1.1.1" [[package]] -category = "dev" +category = "main" description = "More routines for operating on iterables, beyond itertools" name = "more-itertools" optional = false @@ -738,7 +738,7 @@ python-versions = "*" version = "0.1.7" [[package]] -category = "dev" +category = "main" description = "Backport of pathlib-compatible object wrapper for zip files" marker = "python_version < \"3.8\"" name = "zipp" @@ -754,7 +754,7 @@ docs = ["sphinx", "jaraco.packaging (>=3.2)", "rst.linker (>=1.9)"] testing = ["pathlib2", "contextlib2", "unittest2"] [metadata] -content-hash = "e5786e21a014696bfc7500f95ec5e79446608e2e366ab8ca6bc8544bac9388f7" +content-hash = "736363c58669039eb63f8bfadebfe24590c1058cfa336562a92354f0d9d6f263" python-versions = "^3.5" [metadata.files] diff --git a/pyproject.toml b/pyproject.toml index de7ed6c0..5db0503c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ python = "^3.5" asyncpg = ">=0.18,<1.0" SQLAlchemy = "^1.2" contextvars = { version = "^2.4", python = "<3.7" } +importlib_metadata = { version = "^1.3.0", python = "<3.8" } [tool.poetry.dev-dependencies] psycopg2-binary = "^2.8.4" diff --git a/src/gino/__init__.py b/src/gino/__init__.py index cf8461fa..bc085fe0 100644 --- a/src/gino/__init__.py +++ b/src/gino/__init__.py @@ -11,4 +11,16 @@ def create_engine(*args, **kwargs): return create_engine(*args, **kwargs) -__version__ = "1.0.0-alpha" +def get_version(): + try: + from importlib.metadata import version + except ImportError: + from importlib_metadata import version + return version("gino") + + +# noinspection PyBroadException +try: + __version__ = get_version() +except Exception: + pass