Merge pull request #42 from shanemcd/fix-sdist-version

Fix reported version when installing from sdist
This commit is contained in:
Shane McDonald 2017-07-25 11:16:56 -04:00 committed by GitHub
commit d13ff93f26
4 changed files with 20 additions and 9 deletions

1
.gitignore vendored
View File

@ -107,6 +107,7 @@ local/
*.mo
requirements/vendor
.i18n_built
VERSION
# AWX python libs populated by requirements.txt
awx/lib/.deps_built

View File

@ -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

View File

@ -56,11 +56,11 @@ endif
ifeq ($(OFFICIAL),yes)
SETUP_TAR_NAME=$(NAME)-setup-$(RELEASE_VERSION)
SDIST_TAR_NAME=$(NAME)-$(RELEASE_VERSION)
WHEEL_NAME=$(NAME)-$(RELEASE_VERSION)
WHEEL_NAME=$(NAME)-$(RELEASE_VERSION)
else
SETUP_TAR_NAME=$(NAME)-setup-$(RELEASE_VERSION)-$(RELEASE)
SDIST_TAR_NAME=$(NAME)-$(RELEASE_VERSION)-$(RELEASE)
WHEEL_NAME=$(NAME)-$(RELEASE_VERSION)_$(RELEASE)
WHEEL_NAME=$(NAME)-$(RELEASE_VERSION)_$(RELEASE)
endif
SDIST_COMMAND ?= sdist
@ -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,11 +536,11 @@ dev_build:
release_build:
$(PYTHON) setup.py release_build
dist/$(SDIST_TAR_FILE): ui-release
BUILD="$(BUILD)" $(PYTHON) setup.py $(SDIST_COMMAND)
dist/$(SDIST_TAR_FILE): ui-release VERSION
$(PYTHON) setup.py $(SDIST_COMMAND)
dist/$(WHEEL_FILE): ui-release
BUILD="$(BUILD)" $(PYTHON) setup.py $(WHEEL_COMMAND)
$(PYTHON) setup.py $(WHEEL_COMMAND)
sdist: dist/$(SDIST_TAR_FILE)
@echo "#############################################"
@ -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) > $@

View File

@ -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"):