Skip to content

Commit

Permalink
Recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
JDBetteridge committed Nov 10, 2024
1 parent 7ae7e5a commit ca816f0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@


def get_petsc_dir():
"""Attempts to find the PETSc directory on the system
"""
petsc_dir = os.environ.get("PETSC_DIR")
petsc_arch = os.environ.get("PETSC_ARCH", "")
if petsc_dir is None:
Expand All @@ -37,6 +39,18 @@ def get_petsc_dir():
return pathlist


def _requirements(deps, pkg):
"""Recursively obtain the dependencies of a package using pkgconfig
"""
deps = pkgconfig.requires(pkg)
if len(deps[0]):
for p in deps:
deps.extend(_requirements(deps, p))
return deps
else:
return []


# JBTODO: This is deprecated behaviour, what to do?:
if "clean" in sys.argv[1:]:
# Forcibly remove the results of Cython.
Expand Down Expand Up @@ -117,6 +131,9 @@ def __getitem__(self, key):
)
elif pkgconfig.exists("hdf5"):
hdf5_ = ExternalDependency(**pkgconfig.parse("hdf5"))
deps = _requirements([], "hdf5")
for pkg in deps:
hdf5_ += ExternalDependency(**pkgconfig.parse(pkg))
else:
# Set the library name and hope for the best
hdf5_ = ExternalDependency(libraries=["hdf5"])
Expand Down

0 comments on commit ca816f0

Please sign in to comment.