-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·45 lines (35 loc) · 1.07 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2017, 2018 Pablo Iranzo Gómez <Pablo.Iranzo@gmail.com>
import os
import re
import time
import setuptools
# In python < 2.7.4, a lazy loading of package `pbr` will break
# setuptools if some other modules registered functions in `atexit`.
# solution from: http://bugs.python.org/issue15881#msg170215
try:
import multiprocessing # noqa
except ImportError:
pass
filename = "setup.cfg"
regexp = r"\Aversion.*([0-9]+)"
line = ""
with open(filename, "r") as f:
for line in f:
if re.match(regexp, line):
# Return earlier if match found
break
version = line.split("=")[1].strip()
try:
travis = os.environ["TRAVIS_JOB_ID"]
except:
travis = None
strings = time.strftime("%Y,%m,%d,%H,%M,%S")
t = strings.split(",")
numbers = [str(x) for x in t]
if travis:
os.environ["PBR_VERSION"] = "%s.%s.%s" % (version, travis, "".join(numbers))
else:
os.environ["PBR_VERSION"] = "%s.%s.%s" % (version, 0, "".join(numbers))
setuptools.setup(setup_requires=["pbr>=2.0.0"], pbr=True)