mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 02:49:27 +01:00
If SOURCE_DATE_EPOCH is available, use it to get a proper version instead of 'installed on'.
#1338
This commit is contained in:
parent
cd8ad1edb6
commit
36309ad1dc
10
setup.py
10
setup.py
@ -51,20 +51,22 @@ if path:
|
|||||||
VERSION_FILE = os.path.join('src', 'version.py')
|
VERSION_FILE = os.path.join('src', 'version.py')
|
||||||
version = None
|
version = None
|
||||||
try:
|
try:
|
||||||
|
if 'SOURCE_DATE_EPOCH' in os.environ:
|
||||||
|
date = int(os.environ['SOURCE_DATE_EPOCH'])
|
||||||
|
else:
|
||||||
proc = subprocess.Popen('git show HEAD --format=%ct', shell=True,
|
proc = subprocess.Popen('git show HEAD --format=%ct', shell=True,
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
date = proc.stdout.readline()
|
date = proc.stdout.readline()
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
date = date.decode()
|
date = date.decode()
|
||||||
|
date = int(date.strip())
|
||||||
version = ".".join(str(i).zfill(2) for i in
|
version = ".".join(str(i).zfill(2) for i in
|
||||||
time.strptime(time.asctime(time.gmtime(int(date.strip()))))[:3])
|
time.strptime(time.asctime(time.gmtime(date)))[:3])
|
||||||
except:
|
except:
|
||||||
if os.path.isfile(VERSION_FILE):
|
if os.path.isfile(VERSION_FILE):
|
||||||
from src.version import version
|
from src.version import version
|
||||||
else:
|
else:
|
||||||
from time import gmtime, strftime, time
|
version = 'installed on ' + strftime("%Y-%m-%dT%H-%M-%S", gmtime())
|
||||||
t = int(os.environ.get('SOURCE_DATE_EPOCH', time()))
|
|
||||||
version = 'installed on ' + strftime("%Y-%m-%dT%H-%M-%S", gmtime(t))
|
|
||||||
try:
|
try:
|
||||||
os.unlink(VERSION_FILE)
|
os.unlink(VERSION_FILE)
|
||||||
except OSError: # Does not exist
|
except OSError: # Does not exist
|
||||||
|
Loading…
Reference in New Issue
Block a user