mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 23:17:32 -02:30
Transition from setup.py to setup.cfg
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -113,7 +113,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install playbook dependencies
|
- name: Install playbook dependencies
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install docker
|
python3 -m pip install docker setuptools_scm
|
||||||
|
|
||||||
- name: Build AWX image
|
- name: Build AWX image
|
||||||
working-directory: awx
|
working-directory: awx
|
||||||
|
|||||||
2
.github/workflows/stage.yml
vendored
2
.github/workflows/stage.yml
vendored
@@ -65,7 +65,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install playbook dependencies
|
- name: Install playbook dependencies
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install docker
|
python3 -m pip install docker setuptools_scm
|
||||||
|
|
||||||
- name: Build and stage AWX
|
- name: Build and stage AWX
|
||||||
working-directory: awx
|
working-directory: awx
|
||||||
|
|||||||
18
Makefile
18
Makefile
@@ -5,8 +5,8 @@ NPM_BIN ?= npm
|
|||||||
CHROMIUM_BIN=/tmp/chrome-linux/chrome
|
CHROMIUM_BIN=/tmp/chrome-linux/chrome
|
||||||
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
|
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
|
||||||
MANAGEMENT_COMMAND ?= awx-manage
|
MANAGEMENT_COMMAND ?= awx-manage
|
||||||
VERSION := $(shell $(PYTHON) -m setuptools_scm)
|
VERSION := $(shell $(PYTHON) tools/scripts/scm_version.py)
|
||||||
COLLECTION_VERSION := $(shell $(PYTHON) -m setuptools_scm | cut -d . -f 1-3)
|
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
|
# NOTE: This defaults the container image version to the branch that's active
|
||||||
COMPOSE_TAG ?= $(GIT_BRANCH)
|
COMPOSE_TAG ?= $(GIT_BRANCH)
|
||||||
@@ -45,7 +45,7 @@ I18N_FLAG_FILE = .i18n_built
|
|||||||
.PHONY: awx-link clean clean-tmp clean-venv requirements requirements_dev \
|
.PHONY: awx-link clean clean-tmp clean-venv requirements requirements_dev \
|
||||||
develop refresh adduser migrate dbchange \
|
develop refresh adduser migrate dbchange \
|
||||||
receiver test test_unit test_coverage coverage_html \
|
receiver test test_unit test_coverage coverage_html \
|
||||||
dev_build release_build sdist \
|
sdist \
|
||||||
ui-release ui-devel \
|
ui-release ui-devel \
|
||||||
VERSION PYTHON_VERSION docker-compose-sources \
|
VERSION PYTHON_VERSION docker-compose-sources \
|
||||||
.git/hooks/pre-commit
|
.git/hooks/pre-commit
|
||||||
@@ -269,7 +269,7 @@ api-lint:
|
|||||||
yamllint -s .
|
yamllint -s .
|
||||||
|
|
||||||
awx-link:
|
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/setup.py egg_info_dev
|
||||||
cp -f /tmp/awx.egg-link /var/lib/awx/venv/awx/lib/$(PYTHON)/site-packages/awx.egg-link
|
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
|
TEST_DIRS ?= awx/main/tests/unit awx/main/tests/functional awx/conf/tests awx/sso/tests
|
||||||
@@ -420,21 +420,13 @@ ui-test-general:
|
|||||||
$(NPM_BIN) run --prefix awx/ui pretest
|
$(NPM_BIN) run --prefix awx/ui pretest
|
||||||
$(NPM_BIN) run --prefix awx/ui/ test-general --runInBand
|
$(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
|
HEADLESS ?= no
|
||||||
ifeq ($(HEADLESS), yes)
|
ifeq ($(HEADLESS), yes)
|
||||||
dist/$(SDIST_TAR_FILE):
|
dist/$(SDIST_TAR_FILE):
|
||||||
else
|
else
|
||||||
dist/$(SDIST_TAR_FILE): $(UI_BUILD_FLAG_FILE)
|
dist/$(SDIST_TAR_FILE): $(UI_BUILD_FLAG_FILE)
|
||||||
endif
|
endif
|
||||||
$(PYTHON) setup.py $(SDIST_COMMAND)
|
$(PYTHON) -m build -s
|
||||||
ln -sf $(SDIST_TAR_FILE) dist/awx.tar.gz
|
ln -sf $(SDIST_TAR_FILE) dist/awx.tar.gz
|
||||||
|
|
||||||
sdist: dist/$(SDIST_TAR_FILE)
|
sdist: dist/$(SDIST_TAR_FILE)
|
||||||
|
|||||||
@@ -6,9 +6,40 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import warnings
|
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__']
|
__all__ = ['__version__']
|
||||||
|
|
||||||
|
|
||||||
@@ -21,7 +52,6 @@ try:
|
|||||||
except ImportError: # pragma: no cover
|
except ImportError: # pragma: no cover
|
||||||
MODE = 'production'
|
MODE = 'production'
|
||||||
|
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
|
[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]
|
[tool.black]
|
||||||
line-length = 160
|
line-length = 160
|
||||||
fast = true
|
fast = true
|
||||||
skip-string-normalization = true
|
skip-string-normalization = true
|
||||||
exclude = "awx_collection"
|
exclude = "awx_collection"
|
||||||
|
|
||||||
[build-system]
|
|
||||||
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
|
|
||||||
|
|
||||||
|
|
||||||
[tool.setuptools_scm]
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
build
|
||||||
django-debug-toolbar==3.2.4
|
django-debug-toolbar==3.2.4
|
||||||
django-rest-swagger
|
django-rest-swagger
|
||||||
# pprofile - re-add once https://github.com/vpelletier/pprofile/issues/41 is addressed
|
# 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:
|
tasks:
|
||||||
- name: Get version from SCM if not explicitly provided
|
- name: Get version from SCM if not explicitly provided
|
||||||
shell: |
|
shell: |
|
||||||
python setup.py --version | cut -d + -f -1
|
python3 -m setuptools_scm | cut -d + -f -1
|
||||||
args:
|
args:
|
||||||
chdir: '../../'
|
chdir: '../../'
|
||||||
register: setup_py_version
|
register: setup_py_version
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ RUN dnf -y update && dnf install -y 'dnf-command(config-manager)' && \
|
|||||||
xmlsec1-devel \
|
xmlsec1-devel \
|
||||||
xmlsec1-openssl-devel
|
xmlsec1-openssl-devel
|
||||||
|
|
||||||
RUN pip3 install virtualenv
|
RUN pip3 install virtualenv setuptools_scm build
|
||||||
|
|
||||||
|
|
||||||
# Install & build requirements
|
# Install & build requirements
|
||||||
|
|||||||
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)
|
||||||
20
tools/scripts/setup.py
Executable file
20
tools/scripts/setup.py
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
# This file only exists for the purposes of generating the development environment's awx.egg-info file
|
||||||
|
# because pip install -e is painfully slow. If anyone finds a better way to do this, I'll buy you a drink.
|
||||||
|
|
||||||
|
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(
|
||||||
|
cmdclass={'egg_info_dev': egg_info_dev},
|
||||||
|
)
|
||||||
5
tox.ini
5
tox.ini
@@ -1,12 +1,17 @@
|
|||||||
|
[tox]
|
||||||
|
isolated_build = True
|
||||||
|
|
||||||
[testenv:linters]
|
[testenv:linters]
|
||||||
deps =
|
deps =
|
||||||
make
|
make
|
||||||
black
|
black
|
||||||
flake8
|
flake8
|
||||||
|
setuptools-scm
|
||||||
yamllint
|
yamllint
|
||||||
allowlist_externals = make
|
allowlist_externals = make
|
||||||
setenv =
|
setenv =
|
||||||
BLACK_ARGS = --check
|
BLACK_ARGS = --check
|
||||||
|
PYTHON = python3
|
||||||
commands =
|
commands =
|
||||||
make black
|
make black
|
||||||
flake8 awx awxkit awx_collection
|
flake8 awx awxkit awx_collection
|
||||||
|
|||||||
Reference in New Issue
Block a user