refactor python module wheel building and installation to be less prone to race conditions

This commit is contained in:
Axel Kohlmeyer
2023-03-24 17:43:52 -04:00
parent bd59c3ea69
commit ab48b834f7
4 changed files with 55 additions and 52 deletions

View File

@ -4,17 +4,15 @@ from setuptools import setup
from setuptools.dist import Distribution
from sys import version_info
import os,time
LAMMPS_PYTHON_DIR = os.path.dirname(os.path.realpath(__file__))
LAMMPS_DIR = os.path.dirname(LAMMPS_PYTHON_DIR)
LAMMPS_SOURCE_DIR = os.path.join(LAMMPS_DIR, 'src')
if not os.path.exists(LAMMPS_SOURCE_DIR):
versionfile = os.environ.get("LAMMPS_VERSION_FILE")
if not versionfile:
# allows installing and building wheel from current directory
LAMMPS_DIR = os.path.realpath(os.path.join(os.environ['PWD'], '..'))
LAMMPS_SOURCE_DIR = os.path.join(LAMMPS_DIR, 'src')
versionfile = os.path.join(LAMMPS_DIR, 'src', 'version.h')
def get_lammps_version():
version_h_file = os.path.join(LAMMPS_SOURCE_DIR, 'version.h')
version_h_file = os.path.join(versionfile)
with open(version_h_file, 'r') as f:
line = f.readline()
start_pos = line.find('"')+1