From 72bb43312dd6b78b32dfdc8dac2b063b9fc15093 Mon Sep 17 00:00:00 2001 From: Ryan Medick Date: Sat, 24 Feb 2024 10:00:14 -0800 Subject: [PATCH] use setuptools-scm for package version --- .gitignore | 9 +++++++++ oresat_configs/constants.py | 12 +++++++++++- pyproject.toml | 10 +++++----- requirements.txt | 1 + 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 169ad13..5292567 100644 --- a/.gitignore +++ b/.gitignore @@ -176,3 +176,12 @@ OD.* # Beacon def formats *xtce.xml + +# MacOS +.DS_Store + +# Vim +*.swp + +# setuptools-scm +*/_version.py diff --git a/oresat_configs/constants.py b/oresat_configs/constants.py index 51619ab..742a194 100644 --- a/oresat_configs/constants.py +++ b/oresat_configs/constants.py @@ -6,7 +6,17 @@ from enum import IntEnum -__version__ = "0.3.1" +__all__ = [ + "__version__", + "OreSatId", + "ORESAT_NICE_NAMES", + "NodeId", +] + +try: + from ._version import version as __version__ # type: ignore +except ImportError: + __version__ = "0.0.0" # package is not installed class OreSatId(IntEnum): diff --git a/pyproject.toml b/pyproject.toml index 6c7f728..e07e913 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools"] +requires = ["setuptools", "setuptools_scm"] build-backend = "setuptools.build_meta" [project] @@ -33,15 +33,15 @@ oresat-print-od = "oresat_configs.scripts.print_od:print_od" oresat-sdo-transfer = "oresat_configs.scripts.sdo_transfer:sdo_transfer" oresat-gen-xtce = "oresat_configs.scripts.gen_xtce:gen_xtce" -[tool.setuptools.dynamic] -version = {attr = "oresat_configs.constants.__version__"} - [tool.setuptools.packages.find] -exclude = ["docs*", "tests*"] +exclude = ["docs*", "tests*"] [tool.setuptools.package-data] "*" = ["*.yaml", "*.csv"] +[tool.setuptools_scm] +write_to = "oresat_configs/_version.py" + [tool.black] line_length = 100 diff --git a/requirements.txt b/requirements.txt index 2ea82f7..0c40e2d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,6 +8,7 @@ pylama[all] pylama[toml] pyyaml setuptools +setuptools-scm sphinx sphinx-rtd-theme wheel