Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Repository = "https://github.com/PolusAI/bfio"


[tool.setuptools.dynamic]
version = {attr = "bfio.__version__"}
version = {file = ["src/bfio/VERSION"]}


[tool.setuptools]
Expand Down
25 changes: 20 additions & 5 deletions src/bfio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import logging
import pathlib
from typing import Any

JAR_VERSION = None

Expand All @@ -16,15 +17,29 @@

try:
with open(pathlib.Path(__file__).parent.joinpath("VERSION"), "r") as fh:
__version__ = fh.read()
__version__ = fh.read().strip()
except FileNotFoundError:
logger.info(
"Could not find VERSION. "
+ "This is likely due to using a local/cloned version of bfio."
"This is likely due to using a local/cloned version of bfio."
)
__version__ = "0.0.0"
logger.info("VERSION = {}".format(__version__))

logger.info("VERSION = %s", __version__)

from .bfio import BioReader, BioWriter # NOQA: F401, E402
from .utils import start # NOQA: F401, E402
# same public API but with lazy imports
__all__ = ["BioReader", "BioWriter", "start", "__version__", "JAR_VERSION", "log_level"]


def __getattr__(name: str) -> Any:
if name in ("BioReader", "BioWriter"):
from .bfio import BioReader, BioWriter # local import (lazy)

return BioReader if name == "BioReader" else BioWriter

if name == "start":
from .utils import start # local import (lazy)

return start

raise AttributeError(f"module {__name__!r} has no attribute {name!r}")