forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpetsc_msys2_fixup.py
executable file
·53 lines (40 loc) · 1.19 KB
/
petsc_msys2_fixup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python2
#* This file is part of the MOOSE framework
#* https://www.mooseframework.org
#*
#* All rights reserved, see COPYRIGHT for full restrictions
#* https://github.com/idaholab/moose/blob/master/COPYRIGHT
#*
#* Licensed under LGPL 2.1, please see LICENSE for details
#* https://www.gnu.org/licenses/lgpl-2.1.html
import re
import os
import sys
try:
petscdir = os.environ['PETSC_DIR']
petscarch = os.environ['PETSC_ARCH']
except Exception as e:
print("Set the PETSC_DIR and PETSC_ARCH environment variables first!")
sys.exit(1)
file = "%s/%s/lib/petsc/conf/petscvariables" % (petscdir, petscarch)
remove = ['C:msys64mingw64lib', ' -LC:\\msys64\\mingw64\\lib']
try:
f = open(file, "r")
lines = f.readlines()
f.close()
except Exception as e:
print("Reading the PETSc variables file '%s' failed!" % file)
sys.exit(1)
def remove_all(text, items):
for i in items:
text = text.replace(i, '')
return text
newlines = [remove_all(l,remove) for l in lines]
try:
f = open(file, "w")
f.writelines(newlines)
f.close()
except Exception as e:
print("Writing the PETSc variables file '%s' failed!" % file)
sys.exit(1)
print("Success!")