def run_install(location, python_path): NAME = "NLOpt" FOLDER = "nlopt-2.5.0" TARFILE = "v2.5.0.tar.gz" URL = "https://github.com/stevengj/nlopt/archive/v2.5.0.tar.gz" HASH = "ada08c648bf9b52faf8729412ff6dd6d" HELPURL = "https://nlopt.readthedocs.io/en/latest/" VERSION = "2.5.0" os.chdir(location) cwd = os.getcwd() if cwd.endswith("/"): cwd = cwd[:-1] if not os.path.exists(FOLDER): os.system("mkdir %s" % FOLDER) os.system("mkdir %s/build" % FOLDER) download_file(cwd, URL, HASH) os.system("tar -C %s/ -xzf %s" % (FOLDER, TARFILE)) os.system("mv %s/%s %s/src" % (FOLDER, FOLDER, FOLDER)) os.mkdir("%s/src/build" % FOLDER) os.chdir("%s/src/build" % FOLDER) # Specific Install Instructions os.system( "cmake .. -DCMAKE_INSTALL_PREFIX=%s/nlopt-2.5.0/build -DPYTHON_EXECUTABLE=%s" % (cwd, python_path)) os.system("make; make install") ############################### os.chdir("../../../") else: print("%s folder already exists, so will not re-install." % NAME) mod_file = '''help([[ For detailed instructions, go to: $HELPURL$ ]]) whatis("Version: $VERSION$") whatis("Keywords: $NAME$") whatis("URL: $HELPURL$") whatis("Description: $NAME$") prepend_path("PATH", "$CWD$/$FOLDER$/build/bin") prepend_path("LD_LIBRARY_PATH", "$CWD$/$FOLDER$/build/lib64") prepend_path("PYTHONPATH", "$CWD$/$FOLDER$/build/lib/python2.7/site-packages") ''' rep = { "$CWD$": cwd, "$FOLDER$": FOLDER, "$NAME$": NAME, "$VERSION$": VERSION, "$HELPURL$": HELPURL } for identifier, word in rep.items(): while identifier in mod_file: mod_file = mod_file.replace(identifier, str(word)) save_module(mod_file, FOLDER)
def run_install(location): NAME = "swig" FOLDER = "swig-3.0.12" TARFILE = "swig-3.0.12.tar.gz" URL = "http://prdownloads.sourceforge.net/swig/swig-3.0.12.tar.gz" HASH = "82133dfa7bba75ff9ad98a7046be687c" HELPURL = "https://www.swig.org" VERSION = "3.0.12" os.chdir(location) cwd = os.getcwd() if cwd.endswith("/"): cwd = cwd[:-1] if not os.path.exists(FOLDER): os.system("mkdir %s" % FOLDER) os.system("mkdir %s/build" % FOLDER) download_file(cwd, URL, HASH) # Untar the folder and make it into the build src ideal os.system("tar -C %s/ -xzf %s" % (FOLDER, TARFILE)) os.system("mv %s/%s %s/src" % (FOLDER, FOLDER, FOLDER)) # Go into the src directory os.chdir("%s/src" % FOLDER) # Specific Install Instructions os.system("./configure --prefix=%s/%s/build" % (cwd, FOLDER)) os.system("make; make install") ############################### os.chdir("../../") else: print("%s folder already exists, so will not re-install." % NAME) mod_file = '''help([[ For detailed instructions, go to: $HELPURL$ ]]) whatis("Version: $VERSION$") whatis("Keywords: $NAME$") whatis("URL: $HELPURL$") whatis("Description: $NAME$") prepend_path("PATH", "$CWD$/$FOLDER$/build/bin") ''' rep = { "$CWD$": cwd, "$FOLDER$": FOLDER, "$NAME$": NAME, "$VERSION$": VERSION, "$HELPURL$": HELPURL } for identifier, word in rep.items(): while identifier in mod_file: mod_file = mod_file.replace(identifier, str(word)) save_module(mod_file, FOLDER)
def run_install(anaconda_path): homedir = os.path.expanduser("~") potential_anaconda_install_dirs = [ homedir + "/anaconda", homedir + "/anaconda2", "/software/apps/anaconda/5.2/python/2.7" ] if anaconda_path is not None: potential_anaconda_install_dirs += [anaconda_path] for folder in potential_anaconda_install_dirs: if os.path.exists(folder): print("Found anaconda at %s" % folder) anaconda_path = folder break if anaconda_path is not None and anaconda_path.strip() not in ["", "None"]: if anaconda_path.endswith("/"): anaconda_path = anaconda_path[:-1] else: print("Could not find anaconda, so will install it.") download_file( homedir, "https://repo.continuum.io/archive/Anaconda2-5.2.0-Linux-x86_64.sh", "5c034a4ab36ec9b6ae01fa13d8a04462" ) os.system('bash ~/Anaconda2-5.2.0-Linux-x86_64.sh -fb') anaconda_path = homedir + "/anaconda2" anaconda_module = ''' help([[ For detailed instructions, go to: http://www.anaconda.com ]]) whatis("Version: Anaconda 5.2.0, Python 2.7") whatis("Description: Anaconda, Python") prepend_path("PATH", "$ANACONDA/bin") prepend_path("LD_LIBRARY_PATH", "$ANACONDA/lib") '''.replace("$ANACONDA", anaconda_path).replace("$ANACONDA", anaconda_path) save_module(anaconda_module, "anaconda-2.7") return anaconda_path
def run_install(location, VERSION, SFFX, name, extra_lammps_packages=[], smrff_path=None, MODULEDIR=None, compiler="mpicxx"): LAMMPS_MAKEFILE = ''' # mpi = MPI with its default compiler SHELL = /bin/sh # --------------------------------------------------------------------- # compiler/linker settings # specify flags and libraries needed for your compiler CC = $CC$ # Wall and Wextra simply print additional warnings # m64 compiles for 64 bit memory # static-libgcc and static-libstdc++ are to make the final binary as # portable as possible # g means to compile this with debugging flags CCFLAGS = -std=c++11 -g -O3 -m64 -static-libgcc -static-libstdc++ -Wall -Wextra SHFLAGS = -fPIC DEPFLAGS = -M LINK = $CC$ LINKFLAGS = -std=c++11 -g -O3 -m64 -static-libgcc -static-libstdc++ -Wall -Wextra LIB = SIZE = size ARCHIVE = ar ARFLAGS = -rc SHLIBFLAGS = -shared # --------------------------------------------------------------------- # LAMMPS-specific settings, all OPTIONAL # specify settings for LAMMPS features you will use # if you change any -D setting, do full re-compile after "make clean" # LAMMPS ifdef settings # see possible settings in Section 2.2 (step 4) of manual LMP_INC = -DLAMMPS_GZIP -DLAMMPS_MEMALIGN=64 # MPI library # see discussion in Section 2.2 (step 5) of manual # MPI wrapper compiler/linker can provide this info # can point to dummy MPI library in src/STUBS as in Makefile.serial # use -D MPICH and OMPI settings in INC to avoid C++ lib conflicts # INC = path for mpi.h, MPI compiler settings # PATH = path for MPI library # LIB = name of MPI library MPI_INC = $MPIINC$ -I$PYTHON_DIR$/include/python3.7m MPI_PATH = $MPIPATH$ -L$PYTHON_DIR$/lib MPI_LIB = $MPILIB$ -lpython3.7m # FFT library # see discussion in Section 2.2 (step 6) of manual # can be left blank to use provided KISS FFT library # INC = -DFFT setting, e.g. -DFFT_FFTW, FFT compiler settings # PATH = path for FFT library # LIB = name of FFT library FFT_INC = FFT_PATH = FFT_LIB = # JPEG and/or PNG library # see discussion in Section 2.2 (step 7) of manual # only needed if -DLAMMPS_JPEG or -DLAMMPS_PNG listed with LMP_INC # INC = path(s) for jpeglib.h and/or png.h # PATH = path(s) for JPEG library and/or PNG library # LIB = name(s) of JPEG library and/or PNG library JPG_INC = JPG_PATH = JPG_LIB = # --------------------------------------------------------------------- # build rules and dependencies # do not edit this section include Makefile.package.settings include Makefile.package EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) $(JPG_INC) $(PKG_SYSINC) EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(JPG_PATH) $(PKG_SYSPATH) EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB) EXTRA_CPP_DEPENDS = $(PKG_CPP_DEPENDS) EXTRA_LINK_DEPENDS = $(PKG_LINK_DEPENDS) # Path to src files vpath %.cpp .. vpath %.h .. # Link target $(EXE): $(OBJ) $(EXTRA_LINK_DEPENDS) \t$(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE) \t$(SIZE) $(EXE) # Library targets lib: $(OBJ) $(EXTRA_LINK_DEPENDS) \t$(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ) shlib: $(OBJ) $(EXTRA_LINK_DEPENDS) \t$(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \ \t\t$(OBJ) $(EXTRA_LIB) $(LIB) # Compilation rules %.o:%.cpp \t$(CC) $(CCFLAGS) $(SHFLAGS) $(EXTRA_INC) -c $< # Individual dependencies depend : fastdep.exe $(SRC) \t@./fastdep.exe $(EXTRA_INC) -- $^ > .depend || exit 1 fastdep.exe: ../DEPEND/fastdep.c \tcc -O -o $@ $< sinclude .depend ''' mpi_inc = "-DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1" mpi_path = "" mpi_lib = "" serial_inc = "-I../STUBS" serial_path = "-L../STUBS" serial_lib = "-lmpi_stubs" python_path = sys.executable PYTHON_DIR = python_path.split("/bin")[0] while "$PYTHON_DIR$" in LAMMPS_MAKEFILE: LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$PYTHON_DIR$", PYTHON_DIR) while "$CC$" in LAMMPS_MAKEFILE: LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$CC$", compiler) assert SFFX in ["serial", "mpi"],\ "Error - SFFX should be either serial or mpi. It was %s." % SFFX if SFFX == "mpi": LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPIINC$", mpi_inc) LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPIPATH$", mpi_path) LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPILIB$", mpi_lib) elif SFFX == "serial": LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPIINC$", serial_inc) LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPIPATH$", serial_path) LAMMPS_MAKEFILE = LAMMPS_MAKEFILE.replace("$MPILIB$", serial_lib) # Error Handling VERSION = str(VERSION) NAME = "LAMMPs" FOLDER = "lammps/" + name TARFILE = "lammps-%s.tar.gz" % VERSION URL = "https://lammps.sandia.gov/tars/lammps-%s.tar.gz" % VERSION lammps_hashes = {"16Mar18": "8059f1cac17ac74c099ba6c5a5e3a558"} if VERSION not in lammps_hashes: lammps_hashes[VERSION] = "" print( "For future reference, please store the lammps hash of this .tar.gz file." ) HASH = lammps_hashes[VERSION] HELPURL = "https://lammps.sandia.gov" os.chdir(location) cwd = os.getcwd() if cwd.endswith("/"): cwd = cwd[:-1] MODULE_LOADERS = "" if not os.path.exists(FOLDER): os.system("mkdir -p %s" % FOLDER) download_file(cwd, URL, HASH) # Untar the file to the folder openmpi/openmpi-VERSION os.system("tar -xzf %s -C %s" % (TARFILE, FOLDER)) # Now we have lammps/version/lammps-version/src # So, we mv it back os.system("mv %s/lammps-%s %s/.." % (FOLDER, VERSION, FOLDER)) os.system("rm -rf %s" % FOLDER) os.system("mv lammps/lammps-%s %s" % (VERSION, FOLDER)) # Change into src, configure, and make os.chdir("%s/src" % FOLDER) if smrff_path is not None and os.path.exists(smrff_path): print("Will install smrff into this lammps install.") if VERSION != "16Mar18": print( "WARNING! SMRFF is only guaranteed to work for lammps version 16Mar18. Will compile anyways, but good luck." ) os.system("cp -rf %s/lammps/lammps-16Mar18/src/* ." % smrff_path) fptr = open("MAKE/Makefile.%s" % SFFX, 'w') fptr.write(LAMMPS_MAKEFILE) fptr.close() for pkg in extra_lammps_packages: os.system("make yes-%s" % pkg) # Setup stubs if serial if SFFX == "serial": os.chdir("STUBS") os.system("make") os.chdir("../") # Bug fix before compiling fname = "python_impl.cpp" possibly_buggy_file = open(fname, 'r').read().strip() bad_line = " char *pystr = PY_STRING_AS_STRING(pValue);" good_line = " const char *pystr = PY_STRING_AS_STRING(pValue);" if bad_line in possibly_buggy_file: fptr = open(fname, 'w') fptr.write(possibly_buggy_file.replace(bad_line, good_line)) fptr.close() os.system("make %s -j 4" % SFFX) os.system("make %s -j 4 mode=shlib" % SFFX) ############################### os.chdir("../../../") print("CURRENT DIR = %s" % os.getcwd()) else: print("%s folder already exists, so will not re-install." % NAME) mod_file = '''help([[ For detailed instructions, go to: $HELPURL$ This version of LAMMPS was compiled with the following packages: ''' + "\n ".join(extra_lammps_packages) + ''' ''' + (" SMRFF" if smrff_path is not None else "") + ''' ]]) whatis("Version: $VERSION$") whatis("Keywords: $NAME$") whatis("URL: $HELPURL$") whatis("Description: $NAME$") prepend_path("PATH", "$CWD$/$FOLDER$/src") prepend_path("PYTHONPATH", "$CWD$/$FOLDER$/python") prepend_path("LD_LIBRARY_PATH", "$CWD$/$FOLDER$/src") $MODULE_LOADERS$ ''' rep = { "$CWD$": cwd, "$FOLDER$": FOLDER, "$NAME$": NAME, "$VERSION$": VERSION, "$HELPURL$": HELPURL, "$MODULE_LOADERS$": MODULE_LOADERS, } for identifier, word in rep.items(): while identifier in mod_file: mod_file = mod_file.replace(identifier, str(word)) HOMEDIR = os.path.expanduser("~") if MODULEDIR is None: MODULEDIR = HOMEDIR + "/.modules" if not os.path.exists("%s/lammps" % MODULEDIR): os.makedirs("%s/lammps" % MODULEDIR, exist_ok=True) save_module(mod_file, FOLDER, MODULEDIR) return cwd + "/" + FOLDER + "/src/lmp_" + SFFX
def run_install(location, version, MODULEDIR): # Error Handling version = str(version) assert version.count(".") == 2, VERSION_ERROR MAIN_VERSION = ".".join(version.split(".")[:-1]) VERSION = str(version) NAME = "OpenMPI" FOLDER = "openmpi/" + str(version) TARFILE = "openmpi-" + VERSION + ".tar.gz" URL = "https://download.open-mpi.org/release/open-mpi/v" +\ MAIN_VERSION +\ "/openmpi-" + VERSION +\ ".tar.gz" HASH = { "3.1.4": "ee6d8b66c967a38aa74e3d52a9f52ec0", "3.1.3": "121bab028a16ba50e27ab0952bf99e11", "2.1.5": "6918dc76ca4f0ba0f41fe44dfd5a976b", "2.0.2": "886698becc5bea8c151c0af2074b8392", "1.6.5": "d7e98ac8ae1a27a0e37a68b6588c3d97", } HELPURL = "https://www.open-mpi.org" os.chdir(location) cwd = os.getcwd() if cwd.endswith("/"): cwd = cwd[:-1] if not os.path.exists(FOLDER): os.system("mkdir -p %s/build" % FOLDER) download_file(cwd, URL, HASH) # Untar the file to the folder openmpi/openmpi-VERSION os.system("tar -xzf %s -C %s" % (TARFILE, FOLDER)) # Move that new folder to be named src os.system("mv %s/openmpi-%s %s/src" % (FOLDER, VERSION, FOLDER)) # Change into src, configure, and make os.chdir("%s/src" % FOLDER) os.system("./configure --prefix=%s/%s/build" % (cwd, FOLDER)) os.system("make -j 4") os.system("make install") ############################### os.chdir("../../../") else: print("%s folder already exists, so will not re-install." % NAME) mod_file = '''help([[ For detailed instructions, go to: $HELPURL$ ]]) whatis("Version: $VERSION$") whatis("Keywords: $NAME$") whatis("URL: $HELPURL$") whatis("Description: $NAME$") prepend_path("PATH", "$CWD$/$FOLDER$/build/bin") prepend_path("LD_LIBRARY_PATH", "$CWD$/$FOLDER$/build/lib") ''' rep = { "$CWD$": cwd, "$FOLDER$": FOLDER, "$NAME$": NAME, "$VERSION$": VERSION, "$HELPURL$": HELPURL } for identifier, word in rep.items(): while identifier in mod_file: mod_file = mod_file.replace(identifier, str(word)) HOMEDIR = os.path.expanduser("~") if MODULEDIR is None: MODULEDIR = HOMEDIR + "/.modules" if not os.path.exists("%s/openmpi" % MODULEDIR): os.makedirs("%s/openmpi" % MODULEDIR, exist_ok=True) save_module(mod_file, FOLDER, MODULEDIR)
def run_install(location, version): # Error Handling version = str(version) assert version.count(".") == 2, VERSION_ERROR MAIN_VERSION = ".".join(version.split(".")[:-1]) VERSION = str(version) NAME = "OpenMPI" FOLDER = "openmpi/" + str(version) TARFILE = "openmpi-" + VERSION + ".tar.gz" URL = "https://download.open-mpi.org/release/open-mpi/v" +\ MAIN_VERSION +\ "/openmpi-" + VERSION +\ ".tar.gz" HASH = { "2.1.5": "X", "2.0.2": "X", "1.6.5": "X", } HELPURL = "https://www.open-mpi.org" os.chdir(location) cwd = os.getcwd() if cwd.endswith("/"): cwd = cwd[:-1] if not os.path.exists(FOLDER): os.system("mkdir -p %s/build" % FOLDER) download_file(cwd, URL, HASH) # Untar the file to the folder openmpi/openmpi-VERSION os.system("tar -xzf %s -C %s" % (TARFILE, FOLDER)) # Move that new folder to be named src os.system("mv %s/openmpi-%s %s/src" % (FOLDER, VERSION, FOLDER)) # Change into src, configure, and make os.chdir("%s/src" % FOLDER) os.system("./configure --prefix=%s/%s/build" % (cwd, FOLDER)) os.system("make -j 4") os.system("make install") ############################### os.chdir("../../../") else: print("%s folder already exists, so will not re-install." % NAME) mod_file = '''help([[ For detailed instructions, go to: $HELPURL$ ]]) whatis("Version: $VERSION$") whatis("Keywords: $NAME$") whatis("URL: $HELPURL$") whatis("Description: $NAME$") prepend_path("PATH", "$CWD$/$FOLDER$/build/bin") prepend_path("LD_LIBRARY_PATH", "$CWD$/$FOLDER$/build/lib") ''' rep = { "$CWD$": cwd, "$FOLDER$": FOLDER, "$NAME$": NAME, "$VERSION$": VERSION, "$HELPURL$": HELPURL } for identifier, word in rep.items(): while identifier in mod_file: mod_file = mod_file.replace(identifier, str(word)) HOMEDIR = os.path.expanduser("~") if not os.path.exists("%s/.modules" % HOMEDIR): os.mkdir("%s/.modules" % HOMEDIR) if not os.path.exists("%s/.modules/openmpi" % HOMEDIR): os.mkdir("%s/.modules/openmpi" % HOMEDIR) save_module(mod_file, FOLDER)
def run_install(location, VERSION, MODULEDIR): NAME = "NLOpt" FOLDER = "nlopt/%s" % VERSION TARFILE = "v%s.tar.gz" % VERSION URL = "https://github.com/stevengj/nlopt/archive/v%s.tar.gz" % VERSION HASH = { "2.5.0": "ada08c648bf9b52faf8729412ff6dd6d", "2.6.1": "108eeca31ec184f955b3c26d016fe3fa", }[VERSION] HELPURL = "https://nlopt.readthedocs.io/en/latest/" python_path = sys.executable os.chdir(location) cwd = os.getcwd() if cwd.endswith("/"): cwd = cwd[:-1] if not os.path.exists(FOLDER): os.makedirs("%s/build" % FOLDER, exist_ok=True) download_file(cwd, URL, HASH) os.system("tar -C %s/ -xzf %s" % (FOLDER, TARFILE)) os.system("mv %s/nlopt-%s %s/src" % (FOLDER, VERSION, FOLDER)) os.makedirs("%s/src/build" % FOLDER, exist_ok=True) os.chdir("%s/src/build" % FOLDER) # Specific Install Instructions os.system( "cmake .. -DCMAKE_INSTALL_PREFIX=%s/%s/build -DPYTHON_EXECUTABLE=%s" % (cwd, FOLDER, python_path)) os.system("make; make install") ############################### os.chdir("../../../") else: print("%s folder already exists, so will not re-install." % NAME) mod_file = '''help([[ For detailed instructions, go to: $HELPURL$ This version of nlopt was compiled with python 3.7. ]]) whatis("Version: $VERSION$") whatis("Keywords: $NAME$") whatis("URL: $HELPURL$") whatis("Description: $NAME$") prepend_path("PATH", "$CWD$/$FOLDER$/build/bin") prepend_path("LD_LIBRARY_PATH", "$CWD$/$FOLDER$/build/lib") prepend_path("LD_LIBRARY_PATH", "$CWD$/$FOLDER$/build/lib64") prepend_path("PYTHONPATH", "$CWD$/$FOLDER$/build/lib/python3.7/site-packages") ''' rep = { "$CWD$": cwd, "$FOLDER$": FOLDER, "$NAME$": NAME, "$VERSION$": VERSION, "$HELPURL$": HELPURL } for identifier, word in rep.items(): while identifier in mod_file: mod_file = mod_file.replace(identifier, str(word)) HOMEDIR = os.path.expanduser("~") if MODULEDIR is None: MODULEDIR = HOMEDIR + "/.modules" if not os.path.exists("%s/nlopt" % MODULEDIR): os.makedirs("%s/nlopt" % MODULEDIR, exist_ok=True) save_module(mod_file, FOLDER, MODULEDIR)