Skip to content

Commit

Permalink
Added --version flag and _version file writing, closes #67 (#69)
Browse files Browse the repository at this point in the history
* Fixed version number, resolving #67

* Added a dastardly end quote

* Allowed alchemist to be run without a command

* Fixed cli version option

* Linting fix

* Fixed ImportError when alchemist is not installed

Co-authored-by: Matthew Alger <[email protected]>
  • Loading branch information
MatthewJA and Matthew Alger authored Feb 15, 2021
1 parent 22ae98c commit 1ad0d2f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ venv.bak/
.vscode/
datacube-index/
output

# Let setuptools_scm manage the _version.py file
datacube_alchemist/_version.py
9 changes: 3 additions & 6 deletions datacube_alchemist/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
from pkg_resources import get_distribution, DistributionNotFound

try:
__version__ = get_distribution(__name__).version
except DistributionNotFound:
# package is not installed
__version__ = "package-not-installed"
from ._version import version as __version__
except ImportError:
__version__ = "Unknown/Not Installed"
9 changes: 7 additions & 2 deletions datacube_alchemist/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from datacube.ui import click as ui

from datacube_alchemist._utils import _configure_logger
from datacube_alchemist import __version__
import structlog

from odc.aws.queue import get_queue
Expand Down Expand Up @@ -66,11 +67,15 @@ def cli_with_envvar_handling():
cli(auto_envvar_prefix="ALCHEMIST")


@click.group(context_settings=dict(max_content_width=120))
def cli():
@click.group(context_settings=dict(max_content_width=120), invoke_without_command=True)
@click.option("--version", is_flag=True, default=False)
def cli(version):
"""
Transform Datasets from the Open Data Cube into a new type of Dataset
"""
if version:
click.echo(__version__)

# Set up opinionated logging
_configure_logger()

Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]

[tool.setuptools_scm]
write_to = "datacube_alchemist/_version.py"

0 comments on commit 1ad0d2f

Please sign in to comment.