mirror of
https://github.com/ansible/awx.git
synced 2026-01-09 23:12:08 -03:30
Merge pull request #12428 from djyasin/updating_setuppy
Updated setup.py --version to python3 -m setuptools_scm.
This commit is contained in:
commit
a0d5f1fb03
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -113,7 +113,7 @@ jobs:
|
||||
|
||||
- name: Install playbook dependencies
|
||||
run: |
|
||||
python3 -m pip install docker
|
||||
python3 -m pip install docker setuptools_scm
|
||||
|
||||
- name: Build AWX image
|
||||
working-directory: awx
|
||||
|
||||
2
.github/workflows/stage.yml
vendored
2
.github/workflows/stage.yml
vendored
@ -65,7 +65,7 @@ jobs:
|
||||
|
||||
- name: Install playbook dependencies
|
||||
run: |
|
||||
python3 -m pip install docker
|
||||
python3 -m pip install docker setuptools_scm
|
||||
|
||||
- name: Build and stage AWX
|
||||
working-directory: awx
|
||||
|
||||
18
Makefile
18
Makefile
@ -5,8 +5,8 @@ NPM_BIN ?= npm
|
||||
CHROMIUM_BIN=/tmp/chrome-linux/chrome
|
||||
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
|
||||
MANAGEMENT_COMMAND ?= awx-manage
|
||||
VERSION := $(shell $(PYTHON) setup.py --version)
|
||||
COLLECTION_VERSION := $(shell $(PYTHON) setup.py --version | cut -d . -f 1-3)
|
||||
VERSION := $(shell $(PYTHON) tools/scripts/scm_version.py)
|
||||
COLLECTION_VERSION := $(shell $(PYTHON) tools/scripts/scm_version.py | cut -d . -f 1-3)
|
||||
|
||||
# NOTE: This defaults the container image version to the branch that's active
|
||||
COMPOSE_TAG ?= $(GIT_BRANCH)
|
||||
@ -49,7 +49,7 @@ I18N_FLAG_FILE = .i18n_built
|
||||
.PHONY: awx-link clean clean-tmp clean-venv requirements requirements_dev \
|
||||
develop refresh adduser migrate dbchange \
|
||||
receiver test test_unit test_coverage coverage_html \
|
||||
dev_build release_build sdist \
|
||||
sdist \
|
||||
ui-release ui-devel \
|
||||
VERSION PYTHON_VERSION docker-compose-sources \
|
||||
.git/hooks/pre-commit
|
||||
@ -273,7 +273,7 @@ api-lint:
|
||||
yamllint -s .
|
||||
|
||||
awx-link:
|
||||
[ -d "/awx_devel/awx.egg-info" ] || $(PYTHON) /awx_devel/setup.py egg_info_dev
|
||||
[ -d "/awx_devel/awx.egg-info" ] || $(PYTHON) /awx_devel/tools/scripts/egg_info_dev
|
||||
cp -f /tmp/awx.egg-link /var/lib/awx/venv/awx/lib/$(PYTHON)/site-packages/awx.egg-link
|
||||
|
||||
TEST_DIRS ?= awx/main/tests/unit awx/main/tests/functional awx/conf/tests awx/sso/tests
|
||||
@ -424,21 +424,13 @@ ui-test-general:
|
||||
$(NPM_BIN) run --prefix awx/ui pretest
|
||||
$(NPM_BIN) run --prefix awx/ui/ test-general --runInBand
|
||||
|
||||
# Build a pip-installable package into dist/ with a timestamped version number.
|
||||
dev_build:
|
||||
$(PYTHON) setup.py dev_build
|
||||
|
||||
# Build a pip-installable package into dist/ with the release version number.
|
||||
release_build:
|
||||
$(PYTHON) setup.py release_build
|
||||
|
||||
HEADLESS ?= no
|
||||
ifeq ($(HEADLESS), yes)
|
||||
dist/$(SDIST_TAR_FILE):
|
||||
else
|
||||
dist/$(SDIST_TAR_FILE): $(UI_BUILD_FLAG_FILE)
|
||||
endif
|
||||
$(PYTHON) setup.py $(SDIST_COMMAND)
|
||||
$(PYTHON) -m build -s
|
||||
ln -sf $(SDIST_TAR_FILE) dist/awx.tar.gz
|
||||
|
||||
sdist: dist/$(SDIST_TAR_FILE)
|
||||
|
||||
@ -6,9 +6,40 @@ import os
|
||||
import sys
|
||||
import warnings
|
||||
|
||||
from pkg_resources import get_distribution
|
||||
|
||||
__version__ = get_distribution('awx').version
|
||||
def get_version():
|
||||
version_from_file = get_version_from_file()
|
||||
if version_from_file:
|
||||
return version_from_file
|
||||
else:
|
||||
from setuptools_scm import get_version
|
||||
|
||||
version = get_version(root='..', relative_to=__file__)
|
||||
return version
|
||||
|
||||
|
||||
def get_version_from_file():
|
||||
vf = version_file()
|
||||
if vf:
|
||||
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')
|
||||
|
||||
if os.path.exists(version_file):
|
||||
return version_file
|
||||
|
||||
|
||||
try:
|
||||
import pkg_resources
|
||||
|
||||
__version__ = pkg_resources.get_distribution('awx').version
|
||||
except pkg_resources.DistributionNotFound:
|
||||
__version__ = get_version()
|
||||
|
||||
__all__ = ['__version__']
|
||||
|
||||
|
||||
@ -21,7 +52,6 @@ try:
|
||||
except ImportError: # pragma: no cover
|
||||
MODE = 'production'
|
||||
|
||||
|
||||
import hashlib
|
||||
|
||||
try:
|
||||
|
||||
@ -1,3 +1,11 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
# Do not uncomment the line below. We need to be able to override the version via a file, and this
|
||||
# causes the "version" key in setup.cfg to be ignored.
|
||||
# [tool.setuptools_scm]
|
||||
|
||||
[tool.black]
|
||||
line-length = 160
|
||||
fast = true
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
build
|
||||
django-debug-toolbar==3.2.4
|
||||
django-rest-swagger
|
||||
# pprofile - re-add once https://github.com/vpelletier/pprofile/issues/41 is addressed
|
||||
|
||||
24
setup.cfg
Normal file
24
setup.cfg
Normal file
@ -0,0 +1,24 @@
|
||||
[metadata]
|
||||
name = awx
|
||||
author = Red Hat
|
||||
author_email = info@ansible.com
|
||||
version = attr: awx.get_version
|
||||
|
||||
[options]
|
||||
packages =
|
||||
awx
|
||||
zip_safe = False
|
||||
include_package_data = True
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
awx-manage = awx:manage
|
||||
awx.credential_plugins =
|
||||
conjur = awx.main.credential_plugins.conjur:conjur_plugin
|
||||
hashivault_kv = awx.main.credential_plugins.hashivault:hashivault_kv_plugin
|
||||
hashivault_ssh = awx.main.credential_plugins.hashivault:hashivault_ssh_plugin
|
||||
azure_kv = awx.main.credential_plugins.azure_kv:azure_keyvault_plugin
|
||||
aim = awx.main.credential_plugins.aim:aim_plugin
|
||||
centrify_vault_kv = awx.main.credential_plugins.centrify_vault:centrify_plugin
|
||||
thycotic_dsv = awx.main.credential_plugins.dsv:dsv_plugin
|
||||
thycotic_tss = awx.main.credential_plugins.tss:tss_plugin
|
||||
190
setup.py
190
setup.py
@ -1,190 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (c) 2015 Ansible, Inc.
|
||||
# All Rights Reserved.
|
||||
|
||||
import os
|
||||
import glob
|
||||
import sys
|
||||
from setuptools import setup
|
||||
from setuptools.command.egg_info import egg_info as _egg_info
|
||||
|
||||
|
||||
# Paths we'll use later
|
||||
etcpath = "/etc/tower"
|
||||
homedir = "/var/lib/awx"
|
||||
bindir = "/usr/bin"
|
||||
sharedir = "/usr/share/awx"
|
||||
docdir = "/usr/share/doc/awx"
|
||||
|
||||
|
||||
def use_scm_version():
|
||||
return False if version_file() else True
|
||||
|
||||
|
||||
def get_version_from_file():
|
||||
vf = version_file()
|
||||
if vf:
|
||||
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')
|
||||
|
||||
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"
|
||||
webconfig = "/etc/nginx"
|
||||
siteconfig = "/etc/nginx/sites-enabled"
|
||||
# sosreport-3.1 (and newer) look in '/usr/share/sosreport/sos/plugins'
|
||||
# sosreport-3.0 looks in '/usr/lib/python2.7/dist-packages/sos/plugins'
|
||||
# debian/<package>.links will create symlinks to support both versions
|
||||
sosconfig = "/usr/share/sosreport/sos/plugins"
|
||||
else:
|
||||
sysinit = "/etc/rc.d/init.d"
|
||||
webconfig = "/etc/nginx"
|
||||
siteconfig = "/etc/nginx/sites-enabled"
|
||||
# The .spec will create symlinks to support multiple versions of sosreport
|
||||
sosconfig = "/usr/share/sosreport/sos/plugins"
|
||||
|
||||
#####################################################################
|
||||
# Helper Functions
|
||||
|
||||
|
||||
def explode_glob_path(path):
|
||||
"""Take a glob and hand back the full recursive expansion,
|
||||
ignoring links.
|
||||
"""
|
||||
|
||||
result = []
|
||||
includes = glob.glob(path)
|
||||
for item in includes:
|
||||
if os.path.isdir(item) and not os.path.islink(item):
|
||||
result.extend(explode_glob_path(os.path.join(item, "*")))
|
||||
else:
|
||||
result.append(item)
|
||||
return result
|
||||
|
||||
|
||||
def proc_data_files(data_files):
|
||||
"""Because data_files doesn't natively support globs...
|
||||
let's add them.
|
||||
"""
|
||||
|
||||
result = []
|
||||
|
||||
# If running in a virtualenv, don't return data files that would install to
|
||||
# system paths (mainly useful for running tests via tox).
|
||||
if hasattr(sys, 'real_prefix'):
|
||||
return result
|
||||
|
||||
for dir, files in data_files:
|
||||
includes = []
|
||||
for item in files:
|
||||
includes.extend(explode_glob_path(item))
|
||||
result.append((dir, includes))
|
||||
return result
|
||||
|
||||
|
||||
class egg_info_dev(_egg_info):
|
||||
def find_sources(self):
|
||||
# when we generate a .egg-info for the development
|
||||
# environment, it's not really critical that we
|
||||
# parse the MANIFEST.in (which is actually quite expensive
|
||||
# in Docker for Mac)
|
||||
pass
|
||||
|
||||
|
||||
#####################################################################
|
||||
|
||||
|
||||
setup(
|
||||
name=os.getenv('NAME', 'awx'),
|
||||
version=get_version_from_file(),
|
||||
author='Ansible, Inc.',
|
||||
author_email='info@ansible.com',
|
||||
description='awx: API, UI and Task Engine for Ansible',
|
||||
long_description='AWX provides a web-based user interface, REST API and ' 'task engine built on top of Ansible',
|
||||
license='Apache License 2.0',
|
||||
keywords='ansible',
|
||||
url='http://github.com/ansible/awx',
|
||||
packages=['awx'],
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Environment :: Web Environment',
|
||||
'Framework :: Django',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Information Technology',
|
||||
'Intended Audience :: System Administrators' 'License :: Apache License 2.0',
|
||||
'Natural Language :: English',
|
||||
'Operating System :: OS Independent',
|
||||
'Operating System :: POSIX',
|
||||
'Programming Language :: Python',
|
||||
'Topic :: System :: Installation/Setup',
|
||||
'Topic :: System :: Systems Administration',
|
||||
],
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'awx-manage = awx:manage',
|
||||
],
|
||||
'awx.credential_plugins': [
|
||||
'conjur = awx.main.credential_plugins.conjur:conjur_plugin',
|
||||
'hashivault_kv = awx.main.credential_plugins.hashivault:hashivault_kv_plugin',
|
||||
'hashivault_ssh = awx.main.credential_plugins.hashivault:hashivault_ssh_plugin',
|
||||
'azure_kv = awx.main.credential_plugins.azure_kv:azure_keyvault_plugin',
|
||||
'aim = awx.main.credential_plugins.aim:aim_plugin',
|
||||
'centrify_vault_kv = awx.main.credential_plugins.centrify_vault:centrify_plugin',
|
||||
'thycotic_dsv = awx.main.credential_plugins.dsv:dsv_plugin',
|
||||
'thycotic_tss = awx.main.credential_plugins.tss:tss_plugin',
|
||||
],
|
||||
},
|
||||
data_files=proc_data_files(
|
||||
[
|
||||
("%s" % homedir, ["awx/static/favicon.ico"]),
|
||||
("%s" % siteconfig, ["config/awx-nginx.conf"]),
|
||||
# ("%s" % webconfig, ["config/uwsgi_params"]),
|
||||
("%s" % sharedir, ["tools/scripts/request_tower_configuration.sh", "tools/scripts/request_tower_configuration.ps1"]),
|
||||
(
|
||||
"%s" % docdir,
|
||||
[
|
||||
"docs/licenses/*",
|
||||
],
|
||||
),
|
||||
(
|
||||
"%s" % bindir,
|
||||
[
|
||||
"tools/scripts/automation-controller-service",
|
||||
"tools/scripts/failure-event-handler",
|
||||
"tools/scripts/awx-python",
|
||||
],
|
||||
),
|
||||
("%s" % sosconfig, ["tools/sosreport/controller.py"]),
|
||||
]
|
||||
),
|
||||
options={
|
||||
'aliases': {'dev_build': 'clean --all egg_info sdist', 'release_build': 'clean --all egg_info -b "" sdist'},
|
||||
'build_scripts': {
|
||||
'executable': '/usr/bin/awx-python',
|
||||
},
|
||||
},
|
||||
cmdclass={'egg_info_dev': egg_info_dev},
|
||||
**extra_setup_args,
|
||||
)
|
||||
@ -5,7 +5,7 @@
|
||||
tasks:
|
||||
- name: Get version from SCM if not explicitly provided
|
||||
shell: |
|
||||
python setup.py --version | cut -d + -f -1
|
||||
python3 -m setuptools_scm | cut -d + -f -1
|
||||
args:
|
||||
chdir: '../../'
|
||||
register: setup_py_version
|
||||
|
||||
@ -43,7 +43,7 @@ RUN dnf -y update && dnf install -y 'dnf-command(config-manager)' && \
|
||||
xmlsec1-devel \
|
||||
xmlsec1-openssl-devel
|
||||
|
||||
RUN pip3 install virtualenv
|
||||
RUN pip3 install virtualenv setuptools_scm build
|
||||
|
||||
|
||||
# Install & build requirements
|
||||
|
||||
21
tools/scripts/egg_info_dev
Executable file
21
tools/scripts/egg_info_dev
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/env python3
|
||||
|
||||
import setuptools
|
||||
from setuptools.command.egg_info import egg_info as _egg_info
|
||||
|
||||
|
||||
class egg_info_dev(_egg_info):
|
||||
def find_sources(self):
|
||||
# when we generate a .egg-info for the development
|
||||
# environment, it's not really critical that we
|
||||
# parse the MANIFEST.in (which is actually quite expensive
|
||||
# in Docker for Mac)
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setuptools.setup(
|
||||
script_name = 'setup.py',
|
||||
script_args = ['egg_info_dev'],
|
||||
cmdclass={'egg_info_dev': egg_info_dev},
|
||||
)
|
||||
4
tools/scripts/scm_version.py
Normal file
4
tools/scripts/scm_version.py
Normal file
@ -0,0 +1,4 @@
|
||||
from setuptools_scm import get_version
|
||||
|
||||
version = get_version(root='../..', relative_to=__file__)
|
||||
print(version)
|
||||
Loading…
x
Reference in New Issue
Block a user