mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +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
20
setup.py
20
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:
|
||||||
proc = subprocess.Popen('git show HEAD --format=%ct', shell=True,
|
if 'SOURCE_DATE_EPOCH' in os.environ:
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
date = int(os.environ['SOURCE_DATE_EPOCH'])
|
||||||
date = proc.stdout.readline()
|
else:
|
||||||
if sys.version_info[0] >= 3:
|
proc = subprocess.Popen('git show HEAD --format=%ct', shell=True,
|
||||||
date = date.decode()
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
|
date = proc.stdout.readline()
|
||||||
|
if sys.version_info[0] >= 3:
|
||||||
|
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