mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
Fix version when installing from sdist
When installing an sdist, setup.py is invoked on the machine you're installing on. We extract the version from a git tag, but the repo is not included in the sdist. The git describe --long command will silently fail and cause the installed package to report version 0.0.0.0.
This commit is contained in:
parent
0cf376ca6f
commit
7695cb6419
1
.gitignore
vendored
1
.gitignore
vendored
@ -107,6 +107,7 @@ local/
|
||||
*.mo
|
||||
requirements/vendor
|
||||
.i18n_built
|
||||
VERSION
|
||||
|
||||
# AWX python libs populated by requirements.txt
|
||||
awx/lib/.deps_built
|
||||
|
||||
@ -22,6 +22,7 @@ include tools/scripts/failure-event-handler
|
||||
include tools/scripts/tower-python
|
||||
include awx/playbooks/library/mkfifo.py
|
||||
include tools/sosreport/*
|
||||
include VERSION
|
||||
include COPYING
|
||||
include Makefile
|
||||
prune awx/public
|
||||
|
||||
8
Makefile
8
Makefile
@ -86,7 +86,7 @@ UI_RELEASE_FLAG_FILE = awx/ui/.release_built
|
||||
reprepro setup_tarball virtualbox-ovf virtualbox-centos-7 \
|
||||
virtualbox-centos-6 clean-bundle setup_bundle_tarball \
|
||||
ui-docker-machine ui-docker ui-release ui-devel \
|
||||
ui-test ui-deps ui-test-ci ui-test-saucelabs jlaska
|
||||
ui-test ui-deps ui-test-ci ui-test-saucelabs jlaska VERSION
|
||||
|
||||
# remove ui build artifacts
|
||||
clean-ui:
|
||||
@ -117,6 +117,7 @@ clean: clean-ui clean-dist
|
||||
rm -rf requirements/vendor
|
||||
rm -rf tmp
|
||||
rm -rf $(I18N_FLAG_FILE)
|
||||
rm -f VERSION
|
||||
mkdir tmp
|
||||
rm -rf build $(NAME)-$(VERSION) *.egg-info
|
||||
find . -type f -regex ".*\.py[co]$$" -delete
|
||||
@ -535,7 +536,7 @@ dev_build:
|
||||
release_build:
|
||||
$(PYTHON) setup.py release_build
|
||||
|
||||
dist/$(SDIST_TAR_FILE): ui-release
|
||||
dist/$(SDIST_TAR_FILE): ui-release VERSION
|
||||
BUILD="$(BUILD)" $(PYTHON) setup.py $(SDIST_COMMAND)
|
||||
|
||||
dist/$(WHEEL_FILE): ui-release
|
||||
@ -621,3 +622,6 @@ clean-elk:
|
||||
|
||||
psql-container:
|
||||
docker run -it --net tools_default --rm postgres:9.4.1 sh -c 'exec psql -h "postgres" -p "5432" -U postgres'
|
||||
|
||||
VERSION:
|
||||
echo $(RELEASE_VERSION) > $@
|
||||
|
||||
11
setup.py
11
setup.py
@ -7,7 +7,6 @@ import os
|
||||
import glob
|
||||
import sys
|
||||
import subprocess
|
||||
import re
|
||||
from setuptools import setup
|
||||
from distutils.command.sdist import sdist
|
||||
|
||||
@ -26,8 +25,14 @@ else:
|
||||
|
||||
|
||||
def get_version():
|
||||
ver = subprocess.Popen("git describe --long | cut -f1-1 -d -", shell=True, stdout=subprocess.PIPE).stdout.read().strip()
|
||||
return re.sub(r'-([0-9]+)-.*', r'.\1', ver)
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
version_file = os.path.join(current_dir, 'VERSION')
|
||||
if os.path.isfile(version_file):
|
||||
with open(version_file, 'r') as file:
|
||||
version = file.read().strip()
|
||||
else:
|
||||
version = subprocess.Popen("git describe --long | cut -d - -f 1-1", shell=True, stdout=subprocess.PIPE).stdout.read().strip()
|
||||
return version
|
||||
|
||||
|
||||
if os.path.exists("/etc/debian_version"):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user