From b755e4d72a85e379d43e060d5a0a0530b5a5c114 Mon Sep 17 00:00:00 2001 From: Andrew Lapp Date: Tue, 8 Oct 2024 21:16:13 -0400 Subject: [PATCH] Retrieve the version number at runtime --- pyproject.toml | 1 + python/outlines_core/__init__.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index f257735f..6efc781a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,6 +113,7 @@ ignore_missing_imports = true [tool.coverage.run] omit = [ "python/outlines_core/_version.py", + "python/outlines_core/__init__.py", "tests/*", ] branch = true diff --git a/python/outlines_core/__init__.py b/python/outlines_core/__init__.py index ed2d5a9c..03df0bb7 100644 --- a/python/outlines_core/__init__.py +++ b/python/outlines_core/__init__.py @@ -1,4 +1,12 @@ """Outlines is a Generative Model Programming Framework.""" +from importlib.metadata import PackageNotFoundError, version + import outlines_core.models +try: + __version__ = version("outlines_core") +except PackageNotFoundError: + pass + + __all__ = ["models"]