From 705a2fe71cd0899580ae6da52a30ccf4c09e141b Mon Sep 17 00:00:00 2001 From: mloubout Date: Thu, 22 May 2025 08:36:55 -0500 Subject: [PATCH] install: switch to dynamic version to avoid _version file issue --- devito/__init__.py | 7 ++++++- pyproject.toml | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/devito/__init__.py b/devito/__init__.py index 8ce009ca0f..8aad2acb28 100644 --- a/devito/__init__.py +++ b/devito/__init__.py @@ -47,7 +47,12 @@ from devito.mpatches import * # noqa -from ._version import version as __version__ # noqa +from importlib.metadata import version, PackageNotFoundError +try: + __version__ = version("devito") +except PackageNotFoundError: + # devito is not installed + __version__ = '0+untagged' def reinit_compiler(val): diff --git a/pyproject.toml b/pyproject.toml index 5cad88f017..c997f02644 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -68,7 +68,6 @@ exclude = ["docs", "tests", "examples"] [tool.setuptools_scm] -write_to = 'devito/_version.py' fallback_version = "0+untagged" [tool.flake8]