From f0d9dd40f873fe50ebe498b694aa27b58d05b182 Mon Sep 17 00:00:00 2001 From: Javier San Juan Cervera Date: Tue, 9 Apr 2019 13:00:02 +0200 Subject: [PATCH 1/6] Travis version tag is now written to file --- setup.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 48de3af..7501c87 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,20 @@ 'sdk.txt', ), session='None') -VERSION = environ.get('TRAVIS_TAG') +# Try to write VERSION file from Travis tag +TRAVIS_TAG = environ.get('TRAVIS_TAG').strip() +if TRAVIS_TAG: + with open('VERSION', 'w') as version_file: + version_file.write(TRAVIS_TAG) + +# Try to read VERSION from file +with open('VERSION', 'r') as version_file: + VERSION = version_file.read().strip() + +# If VERSION is not defined, raise error +if not VERSION: + raise EnvironmentError('VERSION not defined.') + PACKAGES = find_packages(exclude=['tests*']) DOC = '' From 87e9a8af348e04ab74474e2f2815cc047ebbb9cd Mon Sep 17 00:00:00 2001 From: Javier San Juan Cervera Date: Tue, 9 Apr 2019 13:05:09 +0200 Subject: [PATCH 2/6] Fixed stripping of Travis Tag --- setup.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index 7501c87..7e3ce79 100644 --- a/setup.py +++ b/setup.py @@ -26,18 +26,17 @@ ), session='None') # Try to write VERSION file from Travis tag -TRAVIS_TAG = environ.get('TRAVIS_TAG').strip() -if TRAVIS_TAG: +TRAVIS_TAG = environ.get('TRAVIS_TAG') +if TRAVIS_TAG and TRAVIS_TAG.strip(): with open('VERSION', 'w') as version_file: - version_file.write(TRAVIS_TAG) + version_file.write(TRAVIS_TAG.strip()) # Try to read VERSION from file -with open('VERSION', 'r') as version_file: - VERSION = version_file.read().strip() - -# If VERSION is not defined, raise error -if not VERSION: - raise EnvironmentError('VERSION not defined.') +try: + with open('VERSION', 'r') as version_file: + VERSION = version_file.read().strip() +except IOError: + raise EnvironmentError('VERSION file could not be read.') PACKAGES = find_packages(exclude=['tests*']) From 51c3d734be83527a61c9ff08297811d30a666df3 Mon Sep 17 00:00:00 2001 From: Javier San Juan Cervera Date: Tue, 9 Apr 2019 13:06:51 +0200 Subject: [PATCH 3/6] Added VERSION file. --- VERSION | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..71a64cc --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v15.0 \ No newline at end of file From 33eeb65791e0b4aef0b15854109b31d560b663b9 Mon Sep 17 00:00:00 2001 From: Javier San Juan Cervera Date: Tue, 9 Apr 2019 13:24:29 +0200 Subject: [PATCH 4/6] VERSION set to v15.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 71a64cc..3821c79 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v15.0 \ No newline at end of file +v15.1 \ No newline at end of file From 189cbcab9806799069d60f4beaa141d182eddd07 Mon Sep 17 00:00:00 2001 From: Javier San Juan Cervera Date: Tue, 9 Apr 2019 16:01:15 +0200 Subject: [PATCH 5/6] Requested changes --- VERSION | 1 - setup.py | 24 ++++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) delete mode 100644 VERSION diff --git a/VERSION b/VERSION deleted file mode 100644 index 3821c79..0000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -v15.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 7e3ce79..f5ad3e1 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,7 @@ from os.path import abspath, dirname, exists, join from os import environ from setuptools import find_packages, setup +from warnings import warn try: # for pip >= 10 # noinspection PyProtectedMember,PyPackageRequirements @@ -25,18 +26,25 @@ 'sdk.txt', ), session='None') -# Try to write VERSION file from Travis tag -TRAVIS_TAG = environ.get('TRAVIS_TAG') -if TRAVIS_TAG and TRAVIS_TAG.strip(): - with open('VERSION', 'w') as version_file: - version_file.write(TRAVIS_TAG.strip()) +# Get path to version file +version_path = join( + dirname(abspath(__file__)), + 'VERSION' +) + +# Try to write version file from Travis tag +travis_tag = environ.get('TRAVIS_TAG') +if travis_tag and travis_tag.strip(): + with open(version_path, 'w') as version_file: + version_file.write(travis_tag.strip()) -# Try to read VERSION from file +# Try to read version from file try: - with open('VERSION', 'r') as version_file: + with open(version_path, 'r') as version_file: VERSION = version_file.read().strip() except IOError: - raise EnvironmentError('VERSION file could not be read.') + warn('`{}` file could not be read.'.format(version_path), RuntimeWarning) + VERSION = '' PACKAGES = find_packages(exclude=['tests*']) From 64f78db93362688e3b106d3de06a47915d97431b Mon Sep 17 00:00:00 2001 From: Javier San Juan Cervera Date: Wed, 10 Apr 2019 13:07:14 +0200 Subject: [PATCH 6/6] Removing TRAVIS_TAG dependency from Python code, and hardcoding version in place using sed on Travis script. --- .travis.yml | 1 + setup.py | 24 +----------------------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index 97e56cd..37bca56 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,7 @@ install: script: - flake8 connect - pytest --cov-report=xml --cov=./connect +- sed -i "s/version='0.0.0'/version='${TRAVIS_TAG}'/g" setup.py after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/setup.py b/setup.py index f5ad3e1..fd3354e 100644 --- a/setup.py +++ b/setup.py @@ -7,9 +7,7 @@ """ from os.path import abspath, dirname, exists, join -from os import environ from setuptools import find_packages, setup -from warnings import warn try: # for pip >= 10 # noinspection PyProtectedMember,PyPackageRequirements @@ -26,26 +24,6 @@ 'sdk.txt', ), session='None') -# Get path to version file -version_path = join( - dirname(abspath(__file__)), - 'VERSION' -) - -# Try to write version file from Travis tag -travis_tag = environ.get('TRAVIS_TAG') -if travis_tag and travis_tag.strip(): - with open(version_path, 'w') as version_file: - version_file.write(travis_tag.strip()) - -# Try to read version from file -try: - with open(version_path, 'r') as version_file: - VERSION = version_file.read().strip() -except IOError: - warn('`{}` file could not be read.'.format(version_path), RuntimeWarning) - VERSION = '' - PACKAGES = find_packages(exclude=['tests*']) DOC = '' @@ -55,7 +33,7 @@ setup( name='connect-sdk', author='Ingram Micro', - version=VERSION, + version='0.0.0', keywords='sdk connect connect automation', packages=PACKAGES, description='Connect Python SDK',