Skip to content
Prev Previous commit
Next Next commit
Use a more elaborate init file instead of suppressing warnings.
  • Loading branch information
arokem committed Feb 4, 2026
commit 6a2782918afb00a9e708cbbc5be613d4a3975a1b
5 changes: 0 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@
autoapi_dirs = ['../../trx']
autoapi_ignore = ['*test*', '*version*']

# Added to suppress warnings from autoapi about import of _version
# within __init__.py:
suppress_warnings = ['autoapi.python_import_resolution']


# Sphinx gallery configuration
sphinx_gallery_conf = {
'examples_dirs': '../../examples',
Expand Down
13 changes: 12 additions & 1 deletion trx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
"""TRX file format for brain tractography data."""

from ._version import __version__ # noqa: F401
try:
from .version import __version__ # noqa: F401
except ImportError:
try:
from importlib.metadata import PackageNotFoundError, version
except ImportError: # pragma: no cover
__version__ = "0+unknown"
else:
try:
__version__ = version("trx-python")
except PackageNotFoundError:
__version__ = "0+unknown"