Skip to content

Commit

Permalink
black format
Browse files Browse the repository at this point in the history
  • Loading branch information
wortiz committed Aug 8, 2024
1 parent b598983 commit 7dcbd47
Show file tree
Hide file tree
Showing 21 changed files with 243 additions and 142 deletions.
36 changes: 30 additions & 6 deletions tpls/install-tpls.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,14 @@
package_dir = getattr(args, pc.name + "_dir")

build = Builder(
pc, jobs, download_dir, extract_dir, package_dir, logger, tpl_registry, args.build_shared
pc,
jobs,
download_dir,
extract_dir,
package_dir,
logger,
tpl_registry,
args.build_shared,
)
if build.check(True):
build.logger.log("Package {} found at {}".format(pc.name, package_dir))
Expand All @@ -124,7 +131,14 @@
build.register()
else:
build = Builder(
pc, jobs, download_dir, extract_dir, install_dir, logger, tpl_registry, args.build_shared
pc,
jobs,
download_dir,
extract_dir,
install_dir,
logger,
tpl_registry,
args.build_shared,
)

if build.check():
Expand All @@ -140,8 +154,18 @@
if not build.check():
break
build.register()
tpl_registry.config.write_config(os.path.join(install_dir,"config.sh"))
logger.log("Bash config written to {}, source with bash".format(os.path.join(install_dir, "config.sh")))
tpl_registry.config.write_config(os.path.join(install_dir, "config.sh"))
logger.log(
"Bash config written to {}, source with bash".format(
os.path.join(install_dir, "config.sh")
)
)

tpl_registry.config.write_config(os.path.join(install_dir,"config.fish"), shell="fish")
logger.log("Fish config written to {}, source with fish".format(os.path.join(install_dir, "config.fish")))
tpl_registry.config.write_config(
os.path.join(install_dir, "config.fish"), shell="fish"
)
logger.log(
"Fish config written to {}, source with fish".format(
os.path.join(install_dir, "config.fish")
)
)
12 changes: 8 additions & 4 deletions tpls/tpl_tools/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ def print_and_log(line, file):
sys.stdout.write(line)
file.write(line)


def print_and_log_err(line, file):
sys.stderr.write(line)
file.write(line)


class Builder(object):

def __init__(
Expand Down Expand Up @@ -107,7 +109,9 @@ def install_dir(self):
self._install_dir, self._package.name + "-" + self._package.version
)

def run_command(self, command_list, jobs_flag=None, parallel=False, env=None, command_id=None):
def run_command(
self, command_list, jobs_flag=None, parallel=False, env=None, command_id=None
):
command = command_list
if parallel and jobs_flag:
if jobs_flag[-1] == "=":
Expand Down Expand Up @@ -139,8 +143,6 @@ def run_command(self, command_list, jobs_flag=None, parallel=False, env=None, co
sys.stderr.write(line)
raise RuntimeError("Command resulted in a non-zero error code")



def check(self, skip_named_install=False):
self.logger.log("Checking install of {}".format(self._package.name))
install_dir = self.install_dir()
Expand Down Expand Up @@ -170,7 +172,9 @@ def check(self, skip_named_install=False):
if os.path.exists(os.path.join(checkpath, p + lib + extension)):
found = True
if not found:
self.logger.log("Failed to find library: {}".format("lib" + lib + extension))
self.logger.log(
"Failed to find library: {}".format("lib" + lib + extension)
)
return False
self.logger.log("Found library: {}".format(lib))
if hasattr(self._package, "includes"):
Expand Down
8 changes: 4 additions & 4 deletions tpls/tpl_tools/packages/arpack-ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

class Package(packages.CMakePackage):
def __init__(self):
self.name = 'arpack-ng'
self.name = "arpack-ng"
self.version = "3.9.1"
self.sha256 = "f6641deb07fa69165b7815de9008af3ea47eb39b2bb97521fbf74c97aba6e844"
self.filename = "arpack-ng-" + self.version + ".tar.gz"
self.url = (
"https://github.com/opencollab/arpack-ng/archive/refs/tags/"
+ self.version +
".tar.gz"
+ self.version
+ ".tar.gz"
)
self.libraries = ["arpack", "parpack"]

Expand All @@ -31,4 +31,4 @@ def register(self, builder):
registry = builder._registry
registry.register_package(self.name, builder.install_dir())
registry.set_environment_variable("ARPACK_DIR", builder.install_dir())
registry.append_environment_variable("CMAKE_PREFIX_PATH", builder.install_dir())
registry.append_environment_variable("CMAKE_PREFIX_PATH", builder.install_dir())
13 changes: 9 additions & 4 deletions tpls/tpl_tools/packages/cmake.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from tpl_tools.packages import packages
import os


class Package(packages.AutotoolsPackage):
def __init__(self):
self.name = "cmake"
self.version = "3.30.1"
self.sha256 = "df9b3c53e3ce84c3c1b7c253e5ceff7d8d1f084ff0673d048f260e04ccb346e1"
self.filename = "cmake-" + self.version + ".tar.gz"
self.compression = 'gz'
self.compression = "gz"
self.url = (
"https://github.com/Kitware/CMake/releases/download/v"
+ self.version
Expand All @@ -16,7 +17,7 @@ def __init__(self):
+ ".tar.gz"
)
self.executables = ["cmake"]

def configure(self, builder):
configure_options = ["./bootstrap"]
configure_options.extend(builder.get_options())
Expand All @@ -26,5 +27,9 @@ def configure(self, builder):
def register(self, builder):
registry = builder._registry
registry.register_package(self.name, builder.install_dir())
registry.register_executable(os.path.join(builder.install_dir(), 'bin', 'cmake'))
registry.append_environment_variable("PATH",os.path.join(builder.install_dir(), 'bin'))
registry.register_executable(
os.path.join(builder.install_dir(), "bin", "cmake")
)
registry.append_environment_variable(
"PATH", os.path.join(builder.install_dir(), "bin")
)
14 changes: 7 additions & 7 deletions tpls/tpl_tools/packages/fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class Package(packages.CMakePackage):
def __init__(self):
self.name = 'fmt'
self.name = "fmt"
self.version = "10.2.1"
self.sha256 = "1250e4cc58bf06ee631567523f48848dc4596133e163f02615c97f78bab6c811"
self.filename = "fmt-" + self.version + ".tar.gz"
Expand All @@ -16,11 +16,11 @@ def __init__(self):
self.libraries = ["fmt"]

def setDependencies(self, builder):
builder.set_dependency('packages.openmpi')
builder.set_dependency('packages.hdf5')
builder.set_dependency('packages.pnetcdf')
builder.set_dependency('packages.netcdf')
builder.set_dependency('packages.fmt')
builder.set_dependency("packages.openmpi")
builder.set_dependency("packages.hdf5")
builder.set_dependency("packages.pnetcdf")
builder.set_dependency("packages.netcdf")
builder.set_dependency("packages.fmt")
return

def configure_options(self, builder):
Expand All @@ -35,4 +35,4 @@ def register(self, builder):
registry = builder._registry
registry.register_package(self.name, builder.install_dir())
registry.set_environment_variable("FMT_DIR", builder.install_dir())
registry.append_environment_variable("CMAKE_PREFIX_PATH", builder.install_dir())
registry.append_environment_variable("CMAKE_PREFIX_PATH", builder.install_dir())
12 changes: 7 additions & 5 deletions tpls/tpl_tools/packages/hdf5.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from tpl_tools.packages import packages
import os


class Package(packages.AutotoolsPackage):
def __init__(self):
self.name = 'hdf5'
self.name = "hdf5"
self.version = "1.12.2"
self.sha256 = "1a88bbe36213a2cea0c8397201a459643e7155c9dc91e062675b3fb07ee38afe"
self.filename = "hdf5-" + self.version + ".tar.bz2"
Expand All @@ -17,8 +18,8 @@ def __init__(self):
self.libraries = ["hdf5"]

def setDependencies(self, builder):
builder.set_dependency('packages.openmpi')
builder.set_dependency("packages.openmpi")

def set_environment(self, builder):
builder.env = builder._registry.get_environment().copy()
builder.env["CC"] = builder._registry.get_executable("mpicc")
Expand All @@ -36,5 +37,6 @@ def register(self, builder):
registry.register_package(self.name, builder.install_dir())
registry.set_environment_variable("HDF5_DIR", builder.install_dir())
registry.append_environment_variable("CMAKE_PREFIX_PATH", builder.install_dir())
registry.append_environment_variable("PATH", os.path.join(builder.install_dir(), 'bin'))

registry.append_environment_variable(
"PATH", os.path.join(builder.install_dir(), "bin")
)
8 changes: 3 additions & 5 deletions tpls/tpl_tools/packages/metis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@

class Package(packages.CMakePackage):
def __init__(self):
self.name = 'metis'
self.name = "metis"
self.version = "5.1.0-p12"
self.sha256 = "2f16abe87394d4fd1430d66a8995076c352af40f7a4d1c5300b3b1cc9d545663"
self.filename = "petsc-pkg-metis-" + self.version + ".tar.gz"
self.url = (
"https://bitbucket.org/petsc/pkg-metis/get/v"
+ self.version +
".tar.gz"
"https://bitbucket.org/petsc/pkg-metis/get/v" + self.version + ".tar.gz"
)
self.libraries = ["metis"]
self.includes = ["metis.h"]
Expand All @@ -28,4 +26,4 @@ def register(self, builder):
registry = builder._registry
registry.register_package(self.name, builder.install_dir())
registry.set_environment_variable("METIS_DIR", builder.install_dir())
registry.append_environment_variable("CMAKE_PREFIX_PATH", builder.install_dir())
registry.append_environment_variable("CMAKE_PREFIX_PATH", builder.install_dir())
51 changes: 35 additions & 16 deletions tpls/tpl_tools/packages/mumps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@
import os
import shutil


class Package(packages.GenericPackage):
def __init__(self):
self.name = "mumps"
self.version = "5.7.3"
self.sha256 = "84a47f7c4231b9efdf4d4f631a2cae2bdd9adeaabc088261d15af040143ed112"
self.filename = "mumps-" + self.version + ".tar.gz"
self.url = (
"https://mumps-solver.org/MUMPS_"
+ self.version +
".tar.gz"
)
self.url = "https://mumps-solver.org/MUMPS_" + self.version + ".tar.gz"
self.libraries = ["dmumps", "zmumps"]

def set_environment(self, builder):
Expand All @@ -22,13 +19,24 @@ def set_environment(self, builder):
builder.env["FC"] = builder._registry.get_executable("mpifort")

def configure_options(self, builder):
with open(os.path.join(builder._extract_dir,builder._extracted_folder, "Makefile.inc"), "w") as f:
with open(
os.path.join(
builder._extract_dir, builder._extracted_folder, "Makefile.inc"
),
"w",
) as f:
f.write("LPORDDIR = $(topdir)/PORD/lib/\n")
f.write("IPORD = -I$(topdir)/PORD/include/\n")
f.write("LPORD = -L$(LPORDDIR) -lpord$(PLAT)\n")
f.write("LMETISDIR = " + builder.env["METIS_DIR"] + "/lib\n")
f.write("LPARMETISDIR = " + builder.env["PARMETIS_DIR"] + "/lib\n")
f.write("IMETIS = -I" + builder.env["METIS_DIR"] + "/include -I" + builder.env["PARMETIS_DIR"] + "/include \n")
f.write(
"IMETIS = -I"
+ builder.env["METIS_DIR"]
+ "/include -I"
+ builder.env["PARMETIS_DIR"]
+ "/include \n"
)
f.write("LMETIS = -L$(LPARMETISDIR) -lparmetis -L$(LMETISDIR) -lmetis\n")
f.write("ORDERINGSF = -Dpord -Dmetis -Dparmetis\n")
f.write("ORDERINGSC = $(ORDERINGSF)\n")
Expand All @@ -37,7 +45,9 @@ def configure_options(self, builder):
f.write("IORDERINGSC = $(IMETIS) $(IPORD)\n")
f.write("LIBEXT_SHARED = .so\n")
f.write("SONAME = -soname\n")
f.write("SHARED_OPT = -shared -Wl,-rpath," + builder.install_dir() + "/lib\n")
f.write(
"SHARED_OPT = -shared -Wl,-rpath," + builder.install_dir() + "/lib\n"
)
f.write("FPIC_OPT = -fPIC\n")
f.write("LIBEXT = .a\n")
f.write("OUTC = -o\n")
Expand All @@ -51,7 +61,13 @@ def configure_options(self, builder):
f.write("AR = ar vr \n")
f.write("RANLIB = ranlib \n")
f.write("LAPACK = " + builder.env["LAPACK_LIBRARIES"] + "\n")
f.write("SCALAP = -L" + builder.env["SCALAPACK_DIR"] + "/lib -lscalapack " + builder.env["LAPACK_LIBRARIES"] + "\n")
f.write(
"SCALAP = -L"
+ builder.env["SCALAPACK_DIR"]
+ "/lib -lscalapack "
+ builder.env["LAPACK_LIBRARIES"]
+ "\n"
)
f.write("BLAS = " + builder.env["BLAS_LIBRARIES"] + "\n")
f.write("LIBOTHERS = -lpthread\n")
f.write("CDEFS = -DAdd_\n")
Expand All @@ -65,23 +81,26 @@ def configure_options(self, builder):
f.write("LIBS = $(LIBPAR)\n")
f.write("LIBSEQNEEDED =\n")


def build(self, builder):
if builder.build_shared:
builder.run_command(["make", "allshared"], jobs_flag="-j", parallel=True)
else:
builder.run_command(["make", "all"], jobs_flag="-j", parallel=True)

def install(self, builder):
if not os.path.exists(builder.install_dir()):
os.makedirs(builder.install_dir())
build_dir = os.path.join(builder._extract_dir,builder._extracted_folder)
shutil.copytree(os.path.join(build_dir, "include"), os.path.join(builder.install_dir(), "include"))
shutil.copytree(os.path.join(build_dir, "lib"), os.path.join(builder.install_dir(), "lib"))

build_dir = os.path.join(builder._extract_dir, builder._extracted_folder)
shutil.copytree(
os.path.join(build_dir, "include"),
os.path.join(builder.install_dir(), "include"),
)
shutil.copytree(
os.path.join(build_dir, "lib"), os.path.join(builder.install_dir(), "lib")
)

def register(self, builder):
registry = builder._registry
registry.register_package(self.name, builder.install_dir())
registry.set_environment_variable("MUMPS_DIR", builder.install_dir())
registry.append_environment_variable("CMAKE_PREFIX_PATH", builder.install_dir())
registry.append_environment_variable("CMAKE_PREFIX_PATH", builder.install_dir())
Loading

0 comments on commit 7dcbd47

Please sign in to comment.