Skip to content

Commit

Permalink
feat!: use setuptools-scm, capture version at package root
Browse files Browse the repository at this point in the history
* use setuptools-scm for versioning instead of explicit declaration in version.py
* provide version in package root instead of version module
  • Loading branch information
korikuzma committed Jul 12, 2024
1 parent 7e804ea commit 659bde5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
3 changes: 1 addition & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@
# -- get version -------------------------------------------------------------
from gene import __version__ # noqa: E402

version = __version__
release = version
version = release = __version__


# -- linkcode ----------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ gene_norm_dump = "gene.cli:dump_database"
gene_norm_check_db = "gene.cli:check_db"

[build-system]
requires = ["setuptools>=61.0"]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[tool.setuptools.dynamic]
version = {attr = "gene.version.__version__"}
[tool.setuptools_scm]

[tool.setuptools.packages.find]
where = ["src"]
Expand Down
11 changes: 9 additions & 2 deletions src/gene/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
"""The VICC library for normalizing genes."""

from importlib.metadata import PackageNotFoundError, version
from os import environ
from pathlib import Path

from .version import __version__

APP_ROOT = Path(__file__).resolve().parent

SEQREPO_ROOT_DIR = Path(
environ.get("SEQREPO_ROOT_DIR", "/usr/local/share/seqrepo/latest")
)


try:
__version__ = version("gene-normalizer")
except PackageNotFoundError:
__version__ = "unknown"
finally:
del version, PackageNotFoundError


class DownloadException(Exception): # noqa: N818
"""Exception for failures relating to source file downloads."""

Expand Down
3 changes: 1 addition & 2 deletions src/gene/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ga4gh.core import domain_models, entity_models, ga4gh_identify
from ga4gh.vrs import models

from gene import ITEM_TYPES, NAMESPACE_LOOKUP, PREFIX_LOOKUP
from gene import ITEM_TYPES, NAMESPACE_LOOKUP, PREFIX_LOOKUP, __version__
from gene.database import AbstractDatabase, DatabaseReadException
from gene.schemas import (
BaseGene,
Expand All @@ -29,7 +29,6 @@
SourcePriority,
UnmergedNormalizationService,
)
from gene.version import __version__

_logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/gene/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
constr,
)

from gene.version import __version__
from gene import __version__

CURIE = constr(pattern=r"^\w[^:]*:.+$")

Expand Down
3 changes: 0 additions & 3 deletions src/gene/version.py

This file was deleted.

0 comments on commit 659bde5

Please sign in to comment.