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
4 changed files with 20 additions and 9 deletions

1
.gitignore vendored
View File

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

View File

@@ -22,6 +22,7 @@ include tools/scripts/failure-event-handler
include tools/scripts/tower-python include tools/scripts/tower-python
include awx/playbooks/library/mkfifo.py include awx/playbooks/library/mkfifo.py
include tools/sosreport/* include tools/sosreport/*
include VERSION
include COPYING include COPYING
include Makefile include Makefile
prune awx/public prune awx/public

View File

@@ -56,11 +56,11 @@ endif
ifeq ($(OFFICIAL),yes) ifeq ($(OFFICIAL),yes)
SETUP_TAR_NAME=$(NAME)-setup-$(RELEASE_VERSION) SETUP_TAR_NAME=$(NAME)-setup-$(RELEASE_VERSION)
SDIST_TAR_NAME=$(NAME)-$(RELEASE_VERSION) SDIST_TAR_NAME=$(NAME)-$(RELEASE_VERSION)
WHEEL_NAME=$(NAME)-$(RELEASE_VERSION) WHEEL_NAME=$(NAME)-$(RELEASE_VERSION)
else else
SETUP_TAR_NAME=$(NAME)-setup-$(RELEASE_VERSION)-$(RELEASE) SETUP_TAR_NAME=$(NAME)-setup-$(RELEASE_VERSION)-$(RELEASE)
SDIST_TAR_NAME=$(NAME)-$(RELEASE_VERSION)-$(RELEASE) SDIST_TAR_NAME=$(NAME)-$(RELEASE_VERSION)-$(RELEASE)
WHEEL_NAME=$(NAME)-$(RELEASE_VERSION)_$(RELEASE) WHEEL_NAME=$(NAME)-$(RELEASE_VERSION)_$(RELEASE)
endif endif
SDIST_COMMAND ?= sdist SDIST_COMMAND ?= sdist
@@ -86,7 +86,7 @@ UI_RELEASE_FLAG_FILE = awx/ui/.release_built
reprepro setup_tarball virtualbox-ovf virtualbox-centos-7 \ reprepro setup_tarball virtualbox-ovf virtualbox-centos-7 \
virtualbox-centos-6 clean-bundle setup_bundle_tarball \ virtualbox-centos-6 clean-bundle setup_bundle_tarball \
ui-docker-machine ui-docker ui-release ui-devel \ 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 # remove ui build artifacts
clean-ui: clean-ui:
@@ -117,6 +117,7 @@ clean: clean-ui clean-dist
rm -rf requirements/vendor rm -rf requirements/vendor
rm -rf tmp rm -rf tmp
rm -rf $(I18N_FLAG_FILE) rm -rf $(I18N_FLAG_FILE)
rm -f VERSION
mkdir tmp mkdir tmp
rm -rf build $(NAME)-$(VERSION) *.egg-info rm -rf build $(NAME)-$(VERSION) *.egg-info
find . -type f -regex ".*\.py[co]$$" -delete find . -type f -regex ".*\.py[co]$$" -delete
@@ -535,11 +536,11 @@ dev_build:
release_build: release_build:
$(PYTHON) setup.py 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) $(PYTHON) setup.py $(SDIST_COMMAND)
dist/$(WHEEL_FILE): ui-release dist/$(WHEEL_FILE): ui-release
BUILD="$(BUILD)" $(PYTHON) setup.py $(WHEEL_COMMAND) $(PYTHON) setup.py $(WHEEL_COMMAND)
sdist: dist/$(SDIST_TAR_FILE) sdist: dist/$(SDIST_TAR_FILE)
@echo "#############################################" @echo "#############################################"
@@ -621,3 +622,6 @@ clean-elk:
psql-container: psql-container:
docker run -it --net tools_default --rm postgres:9.4.1 sh -c 'exec psql -h "postgres" -p "5432" -U postgres' 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 glob
import sys import sys
import subprocess import subprocess
import re
from setuptools import setup from setuptools import setup
from distutils.command.sdist import sdist from distutils.command.sdist import sdist
@@ -26,8 +25,14 @@ else:
def get_version(): def get_version():
ver = subprocess.Popen("git describe --long | cut -f1-1 -d -", shell=True, stdout=subprocess.PIPE).stdout.read().strip() current_dir = os.path.dirname(os.path.abspath(__file__))
return re.sub(r'-([0-9]+)-.*', r'.\1', ver) 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"): if os.path.exists("/etc/debian_version"):