Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build!: use setuptools-scm to declare version #428

Merged
merged 5 commits into from
Jul 15, 2024
Merged
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
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,14 @@ therapy_norm_update = "therapy.cli:update_normalizer_db"
therapy_norm_check_db = "therapy.cli:check_db"

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

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

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools_scm]

[tool.setuptools.package-data]
"therapy.etl" = ["*.csv"]

Expand Down
11 changes: 9 additions & 2 deletions src/therapy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
"""The VICC library for normalizing therapies."""

import re
from importlib.metadata import PackageNotFoundError, version
from pathlib import Path

from .version import __version__ # noqa: F401

APP_ROOT: Path = Path(__file__).resolve().parents[0]


try:
__version__ = version("thera-py")
except PackageNotFoundError:
__version__ = "unknown"
finally:
del version, PackageNotFoundError


from therapy.schemas import ( # noqa: E402
NamespacePrefix,
RefType,
Expand Down
2 changes: 1 addition & 1 deletion src/therapy/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ga4gh.core import domain_models
from pydantic import BaseModel, ConfigDict, StrictBool, constr

from therapy.version import __version__
from therapy import __version__

# Working structure for object in preparation for upload to DB
RecordParams = dict[str, list | set | str | dict[str, Any]]
Expand Down
3 changes: 0 additions & 3 deletions src/therapy/version.py

This file was deleted.

4 changes: 2 additions & 2 deletions tests/unit/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,14 +756,14 @@ def test_service_meta(search_handler, normalize_handler):
response = search_handler.search(query)
service_meta = response.service_meta_
assert service_meta.name == "thera-py"
assert service_meta.version >= "0.2.13"
assert service_meta.version != "unknown"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I should have done this for disease or gene? I forget which one made this check

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh I don't really think it matters but at some point we can just run this one around everywhere

assert isinstance(service_meta.response_datetime, datetime)
assert service_meta.url == "https://github.com/cancervariants/therapy-normalization"

response = normalize_handler.normalize(query)
service_meta = response.service_meta_
assert service_meta.name == "thera-py"
assert service_meta.version >= "0.2.13"
assert service_meta.version != "unknown"
assert isinstance(service_meta.response_datetime, datetime)
assert service_meta.url == "https://github.com/cancervariants/therapy-normalization"

Expand Down