|
| 1 | +Add option in install.py to install lammps python packages in a configurable location |
| 2 | +diff --git a/python/install.py b/python/install.py |
| 3 | +index 352225e49d..ee9f2be068 100644 |
| 4 | +--- a/python/install.py |
| 5 | ++++ b/python/install.py |
| 6 | +@@ -29,6 +29,8 @@ parser.add_argument("-v", "--versionfile", required=True, |
| 7 | + help="path to the LAMMPS version.h source file") |
| 8 | + parser.add_argument("-f", "--force", action="store_true", required=False, default=False, |
| 9 | + help="force installation of LAMMPS Python package") |
| 10 | ++parser.add_argument("-i", "--installdir", required=True, |
| 11 | ++ help= "path to site-packages in lammps module") |
| 12 | + |
| 13 | + args = parser.parse_args() |
| 14 | + |
| 15 | +@@ -72,6 +74,14 @@ if args.versionfile: |
| 16 | + else: |
| 17 | + args.versionfile = os.path.abspath(args.versionfile) |
| 18 | + |
| 19 | ++if args.installdir: |
| 20 | ++ if not os.path.exists(args.installdir): |
| 21 | ++ print("\nERROR: LAMMPS site-packages file at %s does not exist\n" % args.installdir) |
| 22 | ++ parser.print_help() |
| 23 | ++ sys.exit(1) |
| 24 | ++ else: |
| 25 | ++ args.installdir = os.path.abspath(args.installdir) |
| 26 | ++ |
| 27 | + olddir = os.path.abspath('.') |
| 28 | + pythondir = os.path.abspath(os.path.join(args.package,'..')) |
| 29 | + os.putenv('LAMMPS_VERSION_FILE',os.path.abspath(args.versionfile)) |
| 30 | +@@ -146,6 +156,12 @@ else: |
| 31 | + print("Installing wheel into system site-packages folder") |
| 32 | + py_exe = sys.executable |
| 33 | + |
| 34 | ++try: |
| 35 | ++ txt = subprocess.check_output([py_exe, '-m', 'pip', 'install', '--force-reinstall', wheel, '--target', args.installdir], stderr=subprocess.STDOUT, shell=False) |
| 36 | ++ print(txt) |
| 37 | ++ sys.exit(0) |
| 38 | ++except subprocess.CalledProcessError as err: |
| 39 | ++ sys.exit(err.output.decode('UTF-8')) |
| 40 | + try: |
| 41 | + if args.force: |
| 42 | + txt = subprocess.check_output([py_exe, '-m', 'pip', 'install', '--force-reinstall', '--break-system-packages', wheel], stderr=subprocess.STDOUT, shell=False) |
0 commit comments