From a3cf252958d6f6603b371475eaa1ecf666b037ba Mon Sep 17 00:00:00 2001 From: Lena Garber <114949949+lgarber-akamai@users.noreply.github.com> Date: Wed, 3 Apr 2024 16:25:34 -0400 Subject: [PATCH] ref: Drop `version` script; consolidate version logic in setup.py (#594) --- setup.py | 15 ++++----------- version | 21 --------------------- 2 files changed, 4 insertions(+), 32 deletions(-) delete mode 100755 version diff --git a/setup.py b/setup.py index 522cb5f78..ddcf08cd7 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ #!/usr/bin/env python3 +import os import pathlib import subprocess import sys @@ -10,6 +11,8 @@ here = pathlib.Path().absolute() +ENV_LINODE_CLI_VERSION = "LINODE_CLI_VERSION" + # get the long description from the README.md with open(here / "README.md", encoding="utf-8") as f: long_description = f.read() @@ -31,16 +34,6 @@ def get_baked_files(): return data_files -def get_version(): - """ - Uses the version file to calculate this package's version - """ - return ( - subprocess.check_output([sys.executable, "./version"]) - .decode("utf-8") - .rstrip() - ) - def get_baked_version(): """ @@ -71,7 +64,7 @@ def bake_version(v): version = get_baked_version() else: # Otherwise, retrieve and bake the version as normal - version = get_version() + version = os.getenv(ENV_LINODE_CLI_VERSION) or "0.0.0" bake_version(version) with open("requirements.txt") as f: diff --git a/version b/version deleted file mode 100755 index 5aa51e513..000000000 --- a/version +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -# Usage: -# ./bin/version -# Prints the current version - -import os - -from packaging.version import parse - -ENV_LINODE_CLI_VERSION = "LINODE_CLI_VERSION" - - -def get_version(): - # We want to override the version if an environment variable is specified. - # This is useful for certain release and testing pipelines. - version_str = os.getenv(ENV_LINODE_CLI_VERSION) or "0.0.0" - - return parse(version_str).release - - -print("{}.{}.{}".format(*get_version()))