diff --git a/setup.py b/setup.py index 43572c7f..9d31d980 100644 --- a/setup.py +++ b/setup.py @@ -24,9 +24,12 @@ long_description = f.read() # Get version from environment vars -# `TRAVIS_TAG` from Travis -# `BUILD_SOURCEBRANCHNAME` from azure -version = environ['TRAVIS_TAG'] or environ['BUILD_SOURCEBRANCHNAME'] +if hasattr(environ,'TRAVIS_TAG'): + version = environ['TRAVIS_TAG'] # `TRAVIS_TAG` from Travis +elif hasattr(environ,'BUILD_SOURCEBRANCHNAME'): + version = environ['BUILD_SOURCEBRANCHNAME'] # `BUILD_SOURCEBRANCHNAME` from azure pipelines +else: + raise Exception("This setup script should be run in CI/CD environment (TravisCI or AzurePipelines)") version = version.strip('v').strip('V') # Arguments marked as "Required" below must be included for upload to PyPI.