From c324d754a0644f2a50c5b376ca3318b8fc1a3396 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Mon, 12 Apr 2021 10:51:44 -0400 Subject: [PATCH] when installing the LAMMPS python package create a valid version id --- python/install.py | 8 +++++--- python/lammps/__init__.py | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/python/install.py b/python/install.py index 6e4c509f07..fbff02a1b5 100644 --- a/python/install.py +++ b/python/install.py @@ -10,7 +10,7 @@ build target in the conventional and CMake based build systems # copy LAMMPS shared library and lammps package to system dirs from __future__ import print_function -import sys,os,shutil +import sys,os,shutil,time from argparse import ArgumentParser parser = ArgumentParser(prog='install.py', @@ -80,13 +80,15 @@ if args.dir: 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): with open(header, 'r') as f: line = f.readline() start_pos = line.find('"')+1 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) diff --git a/python/lammps/__init__.py b/python/lammps/__init__.py index 93c46819c0..2c0e7a6fe3 100644 --- a/python/lammps/__init__.py +++ b/python/lammps/__init__.py @@ -38,7 +38,7 @@ def get_version_number(): if not vstring: 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 __version__ = get_version_number()