Skip to content

Commit

Permalink
Gather the CC used by PETSc for UW3 extensions.
Browse files Browse the repository at this point in the history
Hopefully this is a fix for effiectively getting mpicc.
Need to test using conda next.
  • Loading branch information
julesghub committed Jan 16, 2025
1 parent 5b61923 commit 3186550
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
)
raise RuntimeError(msg)

### set CC env variable
os.environ["CC"] = os.popen('which mpicc').read().strip()

def configure():

INCLUDE_DIRS = []
Expand Down Expand Up @@ -66,13 +63,28 @@ def configure():
join(PETSC_DIR, "include"),
]
LIBRARY_DIRS += [join(PETSC_DIR, PETSC_ARCH, "lib")]
petscvars = join(PETSC_DIR,PETSC_ARCH,"lib","petsc","conf","petscvariables")
else:
if PETSC_ARCH:
pass # XXX should warn ...
INCLUDE_DIRS += [join(PETSC_DIR, "include")]
LIBRARY_DIRS += [join(PETSC_DIR, "lib")]
petscvars = join(PETSC_DIR,"lib","petsc","conf","petscvariables")

LIBRARIES += ["petsc"]

# set CC compiler to be PETSc's compiler.
# This ought include mpi's details, ie mpicc --showme,
# needed to compile UW cython extensions
compiler = ""
with open(petscvars,"r") as f:
for line in f:
line = line.strip()
if line.startswith("CC ="):
compiler = line.split("=",1)[1].strip()
#print(f"***\n The c compiler is: {compiler}\n*****")
os.environ["CC"] = compiler

# PETSc for Python
INCLUDE_DIRS += [petsc4py.get_include()]

Expand Down

0 comments on commit 3186550

Please sign in to comment.