Skip to content

Commit 18b922a

Browse files
committed
Use importlib.metadata instead of reading pyproject.toml at runtime
1 parent cc62cf0 commit 18b922a

2 files changed

Lines changed: 4 additions & 10 deletions

File tree

ontograph/config/settings.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
from importlib.metadata import version
12
from pathlib import Path
23

3-
import toml
44
from appdirs import user_cache_dir
55

66
__all__ = [
@@ -13,14 +13,9 @@
1313
'DEFAULT_FORMAT_ONTOLOGY',
1414
]
1515

16-
# Read package information from pyproject.toml
17-
_PYPROJECT_PATH = Path(__file__).parents[2] / 'pyproject.toml'
18-
with open(_PYPROJECT_PATH) as f:
19-
_PYPROJECT = toml.load(f)
20-
21-
# Extract package metadata
22-
PACKAGE_NAME = _PYPROJECT['project']['name']
23-
PACKAGE_VERSION = _PYPROJECT['project']['version']
16+
# Package metadata from installed package
17+
PACKAGE_NAME = 'ontograph'
18+
PACKAGE_VERSION = version(PACKAGE_NAME)
2419

2520
# Use package name (ontograph) from `pyproject.toml`` for cache directory
2621
DEFAULT_CACHE_DIR = Path(

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ classifiers = [
2828
"Topic :: Scientific/Engineering :: Bio-Informatics"
2929
]
3030
dependencies = [
31-
"toml",
3231
"pronto",
3332
"pooch[progress]",
3433
"pyyaml",

0 commit comments

Comments
 (0)