parent
8de704d7ae
commit
e80101d98c
46
setup.py
46
setup.py
|
|
@ -19,26 +19,8 @@ requirements_setup = read_req('setup.txt')
|
||||||
requirements_validation = read_req('validation.txt')
|
requirements_validation = read_req('validation.txt')
|
||||||
|
|
||||||
|
|
||||||
try:
|
def drf_yasg_setup(**kwargs):
|
||||||
# this is a workaround for being able to install the package from source without working from a git checkout
|
setup(
|
||||||
# it is needed for building succesfully on Heroku
|
|
||||||
from setuptools_scm import get_version
|
|
||||||
except ImportError:
|
|
||||||
get_version = None
|
|
||||||
|
|
||||||
try:
|
|
||||||
version = get_version()
|
|
||||||
version_kwargs = {'use_scm_version': True}
|
|
||||||
except Exception:
|
|
||||||
if any(any(dist in arg for dist in ['sdist', 'bdist']) for arg in sys.argv):
|
|
||||||
raise
|
|
||||||
|
|
||||||
import time
|
|
||||||
timestamp_ms = int(time.time() * 1000)
|
|
||||||
timestamp_str = hex(timestamp_ms)[2:].zfill(16)
|
|
||||||
version_kwargs = {'version': '0.0.0rc0+dummy.' + timestamp_str}
|
|
||||||
|
|
||||||
setup(
|
|
||||||
name='drf-yasg',
|
name='drf-yasg',
|
||||||
packages=find_packages('src'),
|
packages=find_packages('src'),
|
||||||
package_dir={'': 'src'},
|
package_dir={'': 'src'},
|
||||||
|
|
@ -78,5 +60,25 @@ setup(
|
||||||
'Topic :: Documentation',
|
'Topic :: Documentation',
|
||||||
'Topic :: Software Development :: Code Generators',
|
'Topic :: Software Development :: Code Generators',
|
||||||
],
|
],
|
||||||
**version_kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
drf_yasg_setup(use_scm_version=True)
|
||||||
|
except LookupError as e:
|
||||||
|
if os.getenv('CI', 'false') == 'true' or os.getenv('TRAVIS', 'false') == 'true':
|
||||||
|
raise
|
||||||
|
|
||||||
|
if 'setuptools-scm' in str(e):
|
||||||
|
import time
|
||||||
|
|
||||||
|
timestamp_ms = int(time.time() * 1000)
|
||||||
|
timestamp_str = hex(timestamp_ms)[2:].zfill(16)
|
||||||
|
dummy_version = '0.0.0rc0+noscm' + timestamp_str
|
||||||
|
|
||||||
|
drf_yasg_setup(version=dummy_version)
|
||||||
|
print(str(e), file=sys.stderr)
|
||||||
|
print("failed to detect version, build was done using dummy version " + dummy_version, file=sys.stderr)
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue