diff --git a/.gitignore b/.gitignore index 3b286b137d..8a1ae8023b 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,7 @@ __pycache__ /dist /*.egg-info *.py[c,o] +/.eggs # JavaScript /Gruntfile.js diff --git a/Makefile b/Makefile index 3755c20aa8..8fbf817545 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ NPM_BIN ?= npm CHROMIUM_BIN=/tmp/chrome-linux/chrome GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) MANAGEMENT_COMMAND ?= awx-manage -VERSION := $(shell cat VERSION) +VERSION := $(shell $(PYTHON) setup.py --version) # NOTE: This defaults the container image version to the branch that's active COMPOSE_TAG ?= $(GIT_BRANCH) diff --git a/VERSION b/VERSION deleted file mode 100644 index 05c8bd681d..0000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -19.4.0 diff --git a/awxkit/VERSION b/awxkit/VERSION deleted file mode 100644 index 05c8bd681d..0000000000 --- a/awxkit/VERSION +++ /dev/null @@ -1 +0,0 @@ -19.4.0 diff --git a/awxkit/setup.py b/awxkit/setup.py index 657fce0a84..c185e519d1 100644 --- a/awxkit/setup.py +++ b/awxkit/setup.py @@ -4,11 +4,34 @@ import shutil from setuptools import setup, find_packages, Command -def get_version(): +def use_scm_version(): + return False if version_file() else True + + +def get_version_from_file(): + if vf := version_file(): + with open(vf, 'r') as file: + return file.read().strip() + + +def version_file(): current_dir = os.path.dirname(os.path.abspath(__file__)) version_file = os.path.join(current_dir, 'VERSION') - with open(version_file, 'r') as file: - return file.read().strip() + + if os.path.exists(version_file): + return version_file + + +def setup_requires(): + if version_file(): + return [] + else: + return ['setuptools_scm'] + + +extra_setup_args = {} +if not version_file(): + extra_setup_args.update(dict(use_scm_version=dict(root="..", relative_to=__file__), setup_requires=setup_requires())) class CleanCommand(Command): @@ -53,7 +76,7 @@ class CleanCommand(Command): setup( name='awxkit', - version=get_version(), + version=get_version_from_file(), description='The official command line interface for Ansible AWX', author='Red Hat, Inc.', author_email='info@ansible.com', @@ -84,4 +107,5 @@ setup( 'Topic :: System :: Systems Administration', ], entry_points={'console_scripts': ['akit=awxkit.scripts.basic_session:load_interactive', 'awx=awxkit.cli:run']}, + **extra_setup_args, ) diff --git a/setup.py b/setup.py index 7ca1d590a1..62ea103e33 100755 --- a/setup.py +++ b/setup.py @@ -18,12 +18,34 @@ sharedir = "/usr/share/awx" docdir = "/usr/share/doc/awx" -def get_version(): +def use_scm_version(): + return False if version_file() else True + + +def get_version_from_file(): + if vf := version_file(): + with open(vf, 'r') as file: + return file.read().strip() + + +def version_file(): current_dir = os.path.dirname(os.path.abspath(__file__)) version_file = os.path.join(current_dir, 'VERSION') - with open(version_file, 'r') as file: - return file.read().strip() + if os.path.exists(version_file): + return version_file + + +def setup_requires(): + if version_file(): + return [] + else: + return ['setuptools_scm'] + + +extra_setup_args = {} +if not version_file(): + extra_setup_args.update(dict(use_scm_version=use_scm_version(), setup_requires=setup_requires())) if os.path.exists("/etc/debian_version"): sysinit = "/etc/init.d" @@ -93,7 +115,7 @@ class egg_info_dev(_egg_info): setup( name=os.getenv('NAME', 'awx'), - version=get_version(), + version=get_version_from_file(), author='Ansible, Inc.', author_email='info@ansible.com', description='awx: API, UI and Task Engine for Ansible', @@ -104,7 +126,6 @@ setup( packages=['awx'], include_package_data=True, zip_safe=False, - setup_requires=[], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', @@ -165,4 +186,5 @@ setup( }, }, cmdclass={'egg_info_dev': egg_info_dev}, + **extra_setup_args, )