|
9 | 9 | from os.path import abspath, dirname, exists, join |
10 | 10 | from os import environ |
11 | 11 | from setuptools import find_packages, setup |
| 12 | +from warnings import warn |
12 | 13 |
|
13 | 14 | try: # for pip >= 10 |
14 | 15 | # noinspection PyProtectedMember,PyPackageRequirements |
|
25 | 26 | 'sdk.txt', |
26 | 27 | ), session='None') |
27 | 28 |
|
28 | | -# Try to write VERSION file from Travis tag |
29 | | -TRAVIS_TAG = environ.get('TRAVIS_TAG') |
30 | | -if TRAVIS_TAG and TRAVIS_TAG.strip(): |
31 | | - with open('VERSION', 'w') as version_file: |
32 | | - version_file.write(TRAVIS_TAG.strip()) |
| 29 | +# Get path to version file |
| 30 | +version_path = join( |
| 31 | + dirname(abspath(__file__)), |
| 32 | + 'VERSION' |
| 33 | +) |
| 34 | + |
| 35 | +# Try to write version file from Travis tag |
| 36 | +travis_tag = environ.get('TRAVIS_TAG') |
| 37 | +if travis_tag and travis_tag.strip(): |
| 38 | + with open(version_path, 'w') as version_file: |
| 39 | + version_file.write(travis_tag.strip()) |
33 | 40 |
|
34 | | -# Try to read VERSION from file |
| 41 | +# Try to read version from file |
35 | 42 | try: |
36 | | - with open('VERSION', 'r') as version_file: |
| 43 | + with open(version_path, 'r') as version_file: |
37 | 44 | VERSION = version_file.read().strip() |
38 | 45 | except IOError: |
39 | | - raise EnvironmentError('VERSION file could not be read.') |
| 46 | + warn('`{}` file could not be read.'.format(version_path), RuntimeWarning) |
| 47 | + VERSION = '' |
40 | 48 |
|
41 | 49 | PACKAGES = find_packages(exclude=['tests*']) |
42 | 50 |
|
|
0 commit comments