From b53b993c681ec67af553a0d55dd83f294f8048fd Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 9 Feb 2021 02:12:37 -0500 Subject: [PATCH] recover in-place usage by defaulting to version 0 and changing it back after installation --- python/install.py | 7 +++++++ python/lammps/__init__.py | 2 +- python/lammps/core.py | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/python/install.py b/python/install.py index db3fea639d..bd0874593f 100644 --- a/python/install.py +++ b/python/install.py @@ -150,3 +150,10 @@ if tryuser: setup(**setup_kwargs) except: print("Installation into user site package folder failed.") + +# restore __version__ == 0 for in place usage +with open(os.path.join('lammps','__init__.py'), "r+") as f: + content = f.read() + f.seek(0) + f.write(re.sub(vregex, lambda match: '{}{}'.format(match.group(1), 0), content)) + f.truncate() diff --git a/python/lammps/__init__.py b/python/lammps/__init__.py index d79ebe3e9f..e73e514d8c 100644 --- a/python/lammps/__init__.py +++ b/python/lammps/__init__.py @@ -5,4 +5,4 @@ from .pylammps import * # automatically updated during installation -__version__ = 20201224 +__version__ = 0 diff --git a/python/lammps/core.py b/python/lammps/core.py index 1ae6ff5286..1dc135359d 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -382,8 +382,9 @@ class lammps(object): self._available_styles = None # check if liblammps version matches the installed python module version + # but not for in-place usage, i.e. when the version is 0 import lammps - if lammps.__version__ != self.lib.lammps_version(self.lmp): + if lammps.__version__ > 0 and lammps.__version__ != self.lib.lammps_version(self.lmp): raise(AttributeError("LAMMPS Python module installed for LAMMPS version %d, but shared library is version %d" \ % (lammps.__version__, self.lib.lammps_version(self.lmp))))