From 7ea3a6f682810b14b06ff0deae746676dcab3025 Mon Sep 17 00:00:00 2001 From: Daniel Nilsson Date: Mon, 25 Nov 2024 08:34:36 +0100 Subject: [PATCH 1/3] bump to 0.9.3 and use importlib version --- CHANGELOG.md | 3 ++- pyproject.toml | 2 +- stranger/__version__.py | 2 +- stranger/cli.py | 9 +-------- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e81ee65..2a13aca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [unreleased] +## [0.9.3] ### Fixed - Switch build system to uv-hatchling +- Version from importlib metadata ## [0.9.2] ### Fixed diff --git a/pyproject.toml b/pyproject.toml index b2b523a..4517eb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "stranger" -version = "0.9.2" +version = "0.9.3" description = "Annotate VCF files with STR variants with pathogenicity implications" authors = [{name="Daniel Nilsson", email="daniel.nilsson@ki.se"}, {name="Mans Magnuson", email="mans.magnusson@scilifelab.se"}] license = {text = "MIT License"} diff --git a/stranger/__version__.py b/stranger/__version__.py index a2fecb4..c598173 100644 --- a/stranger/__version__.py +++ b/stranger/__version__.py @@ -1 +1 @@ -__version__ = "0.9.2" +__version__ = "0.9.3" diff --git a/stranger/cli.py b/stranger/cli.py index 71e0569..42313ae 100644 --- a/stranger/cli.py +++ b/stranger/cli.py @@ -23,13 +23,6 @@ LOG_LEVELS = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] -def print_version(ctx, param, value): - if not value or ctx.resilient_parsing: - return - click.echo(__version__) - ctx.exit() - - @click.command() @click.argument("vcf") @click.option( @@ -45,7 +38,6 @@ def print_version(ctx, param, value): ) @click.option("-i", "--family_id", default="1") @click.option("-t", "--trgt", is_flag=True, help="File was produced with TRGT") -@click.option("--version", is_flag=True, callback=print_version, expose_value=False, is_eager=True) @click.option( "--loglevel", default="INFO", @@ -53,6 +45,7 @@ def print_version(ctx, param, value): help="Set the level of log output.", show_default=True, ) +@click.version_option(__version__) @click.pass_context def cli(context, vcf, family_id, repeats_file, loglevel, trgt): """Annotate str variants with str status""" From 6e3cc1b01b2bab8f6a3cc93abadc73d64dd57353 Mon Sep 17 00:00:00 2001 From: Daniel Nilsson Date: Mon, 25 Nov 2024 08:48:51 +0100 Subject: [PATCH 2/3] more bump to 0.9.3 and version from toml --- pyproject.toml | 1 - stranger/__version__.py | 1 - stranger/cli.py | 10 +++++++--- uv.lock | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 stranger/__version__.py diff --git a/pyproject.toml b/pyproject.toml index 4517eb6..3cffebf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,6 @@ Repository = "https://github.com/Clinical-Genomics/stranger" Changelog = "https://github.com/Clinical-Genomics/stranger/blob/main/CHANGELOG.md" "Bug Tracker" = "https://github.com/Clinical-Genomics/stranger/issues" - [project.scripts] stranger = "stranger.cli:cli" diff --git a/stranger/__version__.py b/stranger/__version__.py deleted file mode 100644 index c598173..0000000 --- a/stranger/__version__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "0.9.3" diff --git a/stranger/cli.py b/stranger/cli.py index 42313ae..71bea52 100644 --- a/stranger/cli.py +++ b/stranger/cli.py @@ -1,11 +1,15 @@ import gzip import logging from codecs import getreader, open +try: + from importlib.metadata import version +except ImportError: + # Try backported to piPY<37 `importlib_resources`. + from importlib_resources import version import click import coloredlogs -from stranger.__version__ import __version__ from stranger.constants import ANNOTATE_REPEAT_KEYS, ANNOTATE_REPEAT_KEYS_TRGT from stranger.resources import repeats_json_path from stranger.utils import ( @@ -45,12 +49,12 @@ help="Set the level of log output.", show_default=True, ) -@click.version_option(__version__) +@click.version_option(version('stranger')) @click.pass_context def cli(context, vcf, family_id, repeats_file, loglevel, trgt): """Annotate str variants with str status""" coloredlogs.install(level=loglevel) - LOG.info("Running stranger version %s", __version__) + LOG.info("Running stranger version %s", version('stranger')) repeat_information = None repeats_file_type = "tsv" diff --git a/uv.lock b/uv.lock index 1ebd419..626f372 100644 --- a/uv.lock +++ b/uv.lock @@ -394,7 +394,7 @@ wheels = [ [[package]] name = "stranger" -version = "0.9.2" +version = "0.9.3" source = { editable = "." } dependencies = [ { name = "click" }, From b86fb375bd2d7816f1a5287079fd2100344ce647 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Mon, 25 Nov 2024 07:49:16 +0000 Subject: [PATCH 3/3] Fix code style issues with Black --- stranger/cli.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stranger/cli.py b/stranger/cli.py index 71bea52..c19a850 100644 --- a/stranger/cli.py +++ b/stranger/cli.py @@ -1,6 +1,7 @@ import gzip import logging from codecs import getreader, open + try: from importlib.metadata import version except ImportError: @@ -49,12 +50,12 @@ help="Set the level of log output.", show_default=True, ) -@click.version_option(version('stranger')) +@click.version_option(version("stranger")) @click.pass_context def cli(context, vcf, family_id, repeats_file, loglevel, trgt): """Annotate str variants with str status""" coloredlogs.install(level=loglevel) - LOG.info("Running stranger version %s", version('stranger')) + LOG.info("Running stranger version %s", version("stranger")) repeat_information = None repeats_file_type = "tsv"