recover in-place usage by defaulting to version 0 and changing it back after installation

This commit is contained in:
Axel Kohlmeyer
2021-02-09 02:12:37 -05:00
parent 7826b58f73
commit b53b993c68
3 changed files with 10 additions and 2 deletions

View File

@ -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()