when installing the LAMMPS python package create a valid version id
This commit is contained in:
@ -10,7 +10,7 @@ build target in the conventional and CMake based build systems
|
|||||||
# copy LAMMPS shared library and lammps package to system dirs
|
# copy LAMMPS shared library and lammps package to system dirs
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import sys,os,shutil
|
import sys,os,shutil,time
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
parser = ArgumentParser(prog='install.py',
|
parser = ArgumentParser(prog='install.py',
|
||||||
@ -80,13 +80,15 @@ if args.dir:
|
|||||||
|
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
# extract version string from header
|
# extract LAMMPS version string from header
|
||||||
|
# and convert to python packaging compatible version
|
||||||
def get_lammps_version(header):
|
def get_lammps_version(header):
|
||||||
with open(header, 'r') as f:
|
with open(header, 'r') as f:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
start_pos = line.find('"')+1
|
start_pos = line.find('"')+1
|
||||||
end_pos = line.find('"', start_pos)
|
end_pos = line.find('"', start_pos)
|
||||||
return "".join(line[start_pos:end_pos].split())
|
t = time.strptime("".join(line[start_pos:end_pos].split()), "%d%b%Y")
|
||||||
|
return "{}.{}.{}".format(t.tm_year,t.tm_mon,t.tm_mday)
|
||||||
|
|
||||||
verstr = get_lammps_version(args.version)
|
verstr = get_lammps_version(args.version)
|
||||||
|
|
||||||
|
|||||||
@ -38,7 +38,7 @@ def get_version_number():
|
|||||||
if not vstring:
|
if not vstring:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
t = time.strptime(vstring, "%d%b%Y")
|
t = time.strptime(vstring, "%Y.%m.%d")
|
||||||
return t.tm_year*10000 + t.tm_mon*100 + t.tm_mday
|
return t.tm_year*10000 + t.tm_mon*100 + t.tm_mday
|
||||||
|
|
||||||
__version__ = get_version_number()
|
__version__ = get_version_number()
|
||||||
|
|||||||
Reference in New Issue
Block a user