From d8b65e5eee22ca7c21e406b34badaa3d5feb0d86 Mon Sep 17 00:00:00 2001 From: Gregor Sturm Date: Mon, 9 Feb 2026 09:19:36 +0100 Subject: [PATCH 1/3] Simplify vcs version handling One downside of the VCS-based versioning is that when the project is installed in editable mode, the version encoded in the package metadata will remain the one from installation time and get stale. There was some additional code in MuData that attempted to address this, but I believe it does more harm than good: * while it would have updated __version__ (which is a convention, but not a standard), the standard way to retrieve the version via importlib.metadata would still have returned the version number * It goes hunting for the version number at import time and things can go wrong while doing so. In fact, building the conda recipe for scirpy fails on CI exactly because some dependency for getting the version at runtime is missing (https://github.com/scverse/scirpy/actions/runs/21799752388/job/62893203310?pr=672) or it might fail because one has a shallow clone without git history etc. With this PR, I propose to get rid of all the additional version handling and be more aligned with the cookiecutter template. Risking stale metadata in editable mode is a trade-off that we conciously took in the template, because the consequences are low-impact and only affect developers. --- src/mudata/__init__.py | 6 +++--- src/mudata/version.py | 37 ------------------------------------- 2 files changed, 3 insertions(+), 40 deletions(-) delete mode 100644 src/mudata/version.py diff --git a/src/mudata/__init__.py b/src/mudata/__init__.py index 4377213..26eef3e 100644 --- a/src/mudata/__init__.py +++ b/src/mudata/__init__.py @@ -1,5 +1,7 @@ """Multimodal datasets""" +from importlib.metadata import version + from anndata import AnnData from ._core import utils @@ -19,10 +21,8 @@ from ._core.merge import concat from ._core.mudata import MuData from ._core.to_ import to_anndata, to_mudata -from .version import __version__, __version_tuple__ -__anndataversion__ = "0.1.0" -__mudataversion__ = "0.1.0" +__version__ = version("mudata") __all__ = [ "__version__", diff --git a/src/mudata/version.py b/src/mudata/version.py deleted file mode 100644 index b0c7fcd..0000000 --- a/src/mudata/version.py +++ /dev/null @@ -1,37 +0,0 @@ -"""Compute the version number and store it in the `__version__` variable. - -Based on . -""" - - -def _get_hatch_version(): - """Compute the most up-to-date version number in a development environment. - - Returns `None` if Hatchling is not installed, e.g. in a production environment. - - For more details, see . - """ - import os - - try: - from hatchling.metadata.core import ProjectMetadata - from hatchling.plugin.manager import PluginManager - from hatchling.utils.fs import locate_file - except ImportError: - # Hatchling is not installed, so probably we are not in - # a development environment. - return None - - pyproject_toml = locate_file(__file__, "pyproject.toml") - if pyproject_toml is None: - return None - root = os.path.dirname(pyproject_toml) - metadata = ProjectMetadata(root=root, plugin_manager=PluginManager()) - # Version can be either statically set in pyproject.toml or computed dynamically: - return metadata.core.version or metadata.hatch.version.cached - - -__version__ = _get_hatch_version() -__version_tuple__ = None -if not __version__: # not in development mode - from ._version import __version__ From 129aa29a7cf506fd3707c6b43edec21376b01be3 Mon Sep 17 00:00:00 2001 From: Gregor Sturm Date: Mon, 9 Feb 2026 09:30:08 +0100 Subject: [PATCH 2/3] Re-add file-format versions --- src/mudata/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mudata/__init__.py b/src/mudata/__init__.py index 26eef3e..2a45078 100644 --- a/src/mudata/__init__.py +++ b/src/mudata/__init__.py @@ -24,6 +24,10 @@ __version__ = version("mudata") +# file format versions +__anndataversion__ = "0.1.0" +__mudataversion__ = "0.1.0" + __all__ = [ "__version__", "MuData", From 6b6b416bf99979ab725220bc880a660189dda9e2 Mon Sep 17 00:00:00 2001 From: Ilia Kats Date: Fri, 13 Feb 2026 10:23:21 +0100 Subject: [PATCH 3/3] use hatch-generated version file instead of importlib.metadata --- src/mudata/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/mudata/__init__.py b/src/mudata/__init__.py index 2a45078..fa9ca20 100644 --- a/src/mudata/__init__.py +++ b/src/mudata/__init__.py @@ -1,7 +1,5 @@ """Multimodal datasets""" -from importlib.metadata import version - from anndata import AnnData from ._core import utils @@ -21,8 +19,7 @@ from ._core.merge import concat from ._core.mudata import MuData from ._core.to_ import to_anndata, to_mudata - -__version__ = version("mudata") +from ._version import __version__, __version_tuple__ # file format versions __anndataversion__ = "0.1.0"