diff --git a/.travis.yml b/.travis.yml index a4e27b3f..657c4f09 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ before_script: - sudo apt-get install graphviz script: - - ./setup_environment.sh --robot + - ./setup_environment.py - source ./quantum_package.rc - qp_create_ninja.py --production ./config/gfortran_example.cfg - ninja diff --git a/COMPILE_RUN.md b/COMPILE_RUN.md index 7e9025b9..4e52aa9b 100644 --- a/COMPILE_RUN.md +++ b/COMPILE_RUN.md @@ -12,11 +12,11 @@ The script to create the dependencies file (aka `build.ninja`) is `create_ninja_ ## Compilation Flag -You need to specify all the flag useful for the compilation: like the optimization one, the mkl one .``$QPACKAGE_ROOT/config`` contains ``ifort.cfg`` and ``gfortran.cfg`` files which have the compiler flags that will be used to compile the code. You can edit these files to modify the compiling option. Put the file path when calling `create_ninja_build.py` +You need to specify all the flag useful for the compilation: like the optimization one, the mkl one .``$QP_ROOT/config`` contains ``ifort.cfg`` and ``gfortran.cfg`` files which have the compiler flags that will be used to compile the code. You can edit these files to modify the compiling option. Put the file path when calling `create_ninja_build.py` ## Example to create the Ninja file -`create_ninja_build.py --production $QPACKAGE_ROOT/config/ifort.cfg` +`create_ninja_build.py --production $QP_ROOT/config/ifort.cfg` # WARNING @@ -24,8 +24,8 @@ For now reload this command if you add a `IRP.f90` or `EZFIO.cfg` file or modify ## Compile -Just type `ninja` if you are in `$QPACKAGE_ROOT` (or `ninja -f $QPACKAGE_ROOT/build.ninja` elsewhere). The compilation will take approximately 3 min. +Just type `ninja` if you are in `$QP_ROOT` (or `ninja -f $QP_ROOT/build.ninja` elsewhere). The compilation will take approximately 3 min. If you have set the `--developement` flag in a specific module you can go in the corresponding IRPF90_temp and run `ninja` to only make the module and submodule binaries. (You can use the `-f` option too) -Now go in `$QPACKAGE_ROOT/ocaml` and type `make` \ No newline at end of file +Now go in `$QP_ROOT/ocaml` and type `make` diff --git a/data/Makefile b/data/Makefile deleted file mode 100644 index d02ec62b..00000000 --- a/data/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -all: executables - -.PHONY: executables - -executables: - cd $(QPACKAGE_ROOT)/src ; $(MAKE) executables - mv $(QPACKAGE_ROOT)/src/executables . diff --git a/doc/code_architecture/Script.md b/doc/code_architecture/Script.md index b5c19dcd..6c5ff34a 100644 --- a/doc/code_architecture/Script.md +++ b/doc/code_architecture/Script.md @@ -1,17 +1,17 @@ # `ei_handler.py` -This script in located in `$QPACKAGE_ROOT/scripts/ezfio_interface/`. +This script in located in `$QP_ROOT/scripts/ezfio_interface/`. It provide all the resource need to deal with the `EZFIO.cfg` files : - - The creation of `$MODULE_LOWER_ezfio_config` in `$QPACKAGE_ROOT/ezfio/config` + - The creation of `$MODULE_LOWER_ezfio_config` in `$QP_ROOT/ezfio/config` - The `ezfio_interface.irp.f` who containt all the provider associate (in `$MODULE/`) - - The `$MODULE_LOWER_ezfio_defaults` in `$QPACKAGE_ROOT/data/` + - The `$MODULE_LOWER_ezfio_defaults` in `$QP_ROOT/data/` - The `Input_$MODULE_LOWER.ml` for the *qp_edit* For more information you can type `ei_handler.py -h` # `module_handler.py` -This script in located in `$QPACKAGE_ROOT/scripts/module/`. +This script in located in `$QP_ROOT/scripts/module/`. It provide all the resource related to the tree dependancy of the modules. If more useful as a librairy than a cli. @@ -23,19 +23,21 @@ It have some usefull property: - The dict of the root - The list reduced tree (For a list of module in input return only the root) +For tree syntax you can check http://en.wikipedia.org/wiki/Tree_%28data_structure%29#Terminologies_used_in_Trees + In the cli mode: - From a `NEEDED_CHILDREN_MODULE` file you can have all the descendant, and a png representation who correspond. # `qp_install_module.py` -This script is located in `$QPACKAGE_ROOT/scripts/module/`. +This script is located in `$QP_ROOT/scripts/module/`. It is usefull when you need to install a new module. (From the soon to come repo or from scratch). # `qp_create_ninja.py` -This script is located in `$QPACKAGE_ROOT/scripts/compilation/`. +This script is located in `$QP_ROOT/scripts/compilation/`. It will create the `build.ninja` file. It will use intersifly the `module_handler.py` module. To read all the flag for the compilation the module `read_compilation_cfg.py` is used. diff --git a/install/Downloads/.gitignore b/install/Downloads/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/install/_build/.gitignore b/install/_build/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/install/scripts/build.sh b/install/scripts/build.sh new file mode 100755 index 00000000..6b7fc80a --- /dev/null +++ b/install/scripts/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash -x +# This script should be included + +BUILD=_build/${TARGET} +rm -rf -- ${BUILD} +mkdir ${BUILD} || exit 1 +tar -zxf Downloads/${TARGET}.tar.gz --strip-components=1 --directory=${BUILD} || exit 1 +_install || exit 1 +rm -rf -- ${BUILD} _build/${TARGET}.log +exit 0 \ No newline at end of file diff --git a/scripts/install/fetch_from_web.py b/install/scripts/fetch_from_web.py similarity index 100% rename from scripts/install/fetch_from_web.py rename to install/scripts/fetch_from_web.py diff --git a/install/scripts/install_curl.sh b/install/scripts/install_curl.sh new file mode 100755 index 00000000..c3a48024 --- /dev/null +++ b/install/scripts/install_curl.sh @@ -0,0 +1,19 @@ +#!/bin/bash -x +TARGET=curl + +function _install() +{ + cd .. + QP_ROOT=$PWD + cd - + cd ${BUILD} || return 1 + mv curl.ermine ${QP_ROOT}/bin/curl || return 1 +} + +BUILD=_build/${TARGET} +rm -rf -- ${BUILD} +mkdir ${BUILD} || exit 1 +tar -xvjf Downloads/${TARGET}.tar.bz2 --strip-components=1 --directory=${BUILD} || exit 1 +_install || exit 1 +rm -rf -- ${BUILD} _build/${TARGET}.log +exit 0 \ No newline at end of file diff --git a/install/scripts/install_docopt.sh b/install/scripts/install_docopt.sh new file mode 100755 index 00000000..d632ebd6 --- /dev/null +++ b/install/scripts/install_docopt.sh @@ -0,0 +1,10 @@ +#!/bin/bash -x + +TARGET=docopt + +function _install() +{ + cp -R ${BUILD} . || exit 1 +} + +source scripts/build.sh diff --git a/install/scripts/install_emsl.sh b/install/scripts/install_emsl.sh new file mode 100755 index 00000000..a87f91ec --- /dev/null +++ b/install/scripts/install_emsl.sh @@ -0,0 +1,10 @@ +#!/bin/bash -x + +TARGET=emsl + +function _install() +{ + cp -R ${BUILD} . || exit 1 +} + +source scripts/build.sh diff --git a/install/scripts/install_ezfio.sh b/install/scripts/install_ezfio.sh new file mode 100755 index 00000000..4d7ac7e7 --- /dev/null +++ b/install/scripts/install_ezfio.sh @@ -0,0 +1,16 @@ +#!/bin/bash -x + +TARGET=ezfio + +function _install() +{ + cd .. + QP_ROOT=$PWD + cd - + rm -rf ${QP_ROOT}/EZFIO + cd ${BUILD}/config || return 1 + cd - + mv ${BUILD} ${QP_ROOT}/install/EZFIO || return 1 +} + +source scripts/build.sh diff --git a/install/scripts/install_irpf90.sh b/install/scripts/install_irpf90.sh new file mode 100755 index 00000000..60bcf6dc --- /dev/null +++ b/install/scripts/install_irpf90.sh @@ -0,0 +1,24 @@ +#!/bin/bash -x + +TARGET=irpf90 +function _install() +{ + cd .. + QP_ROOT=$PWD + cd - + + make -C ${BUILD} || return 1 + rm -rf -- ./irpf90 + mv ${BUILD} . || return 1 + [[ -x ./irpf90/bin/irpf90 ]] || return 1 + [[ -x ./irpf90/bin/irpman ]] || return 1 + rm -rf -- ../bin/irpf90 ../bin/irpman + echo 'exec ${QP_ROOT}/install/irpf90/bin/irpf90 $@' > ../bin/irpf90 || return 1 + echo 'exec ${QP_ROOT}/install/irpf90/bin/irpman $@' > ../bin/irpman || return 1 + chmod +x ../bin/irpf90 ../bin/irpman || return 1 + return 0 +} + +source scripts/build.sh + + diff --git a/install/scripts/install_m4.sh b/install/scripts/install_m4.sh new file mode 100755 index 00000000..ca62a025 --- /dev/null +++ b/install/scripts/install_m4.sh @@ -0,0 +1,15 @@ +#!/bin/bash -x + +TARGET=m4 + +function _install() +{ + cd .. + QP_ROOT=$PWD + cd - + cd ${BUILD} + ./configure && make || exit 1 + ln -sf ${PWD}/src/m4 ${QP_ROOT}/bin || exit 1 +} + +source scripts/build.sh diff --git a/install/scripts/install_ninja.sh b/install/scripts/install_ninja.sh new file mode 100755 index 00000000..2aab6edd --- /dev/null +++ b/install/scripts/install_ninja.sh @@ -0,0 +1,14 @@ +#!/bin/bash -x + +TARGET=ninja + +function _install() +{ + cd ${BUILD} || return 1 + ./configure.py --bootstrap || return 1 + cd - + mv ${BUILD}/ninja ../bin/ || return 1 + return 0 +} + +source scripts/build.sh \ No newline at end of file diff --git a/install/scripts/install_ocaml.sh b/install/scripts/install_ocaml.sh new file mode 100755 index 00000000..34410c62 --- /dev/null +++ b/install/scripts/install_ocaml.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +cd .. +QP_ROOT=$PWD +cd - + +# Normal installation +PACKAGES="core cryptokit ocamlfind sexplib" + +declare -i i +i=$(gcc -dumpversion | cut -d '.' -f 2) +if [[ i -lt 6 ]] +then + echo "GCC version $(gcc -dumpversion) too old. GCC >= 4.6 required." + exit 1 +fi + +if [[ -d ${HOME}/.opam ]] +then + source ${HOME}/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true +fi + +cd Downloads || exit 1 +chmod +x ocaml.sh || exit 1 + +echo N | ./ocaml.sh ${QP_ROOT}/bin/ || exit 1 + +${QP_ROOT}/bin/opam config setup -a -q || exit 1 + +export LD_LIBRARY_PATH=${QP_ROOT}/lib:${LD_LIBRARY_PATH} +export LIBRARY_PATH=${QP_ROOT}/lib:${LIBRARY_PATH} +export C_INCLUDE_PATH=${QP_ROOT}/lib:${C_INCLUDE_PATH} +source ${HOME}/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true + +${QP_ROOT}/bin/opam install ${PACKAGES} -y -q || exit 1 +rm -f ../_build/ocaml.log +exit 0 + + diff --git a/install/scripts/install_patch.sh b/install/scripts/install_patch.sh new file mode 100755 index 00000000..10522401 --- /dev/null +++ b/install/scripts/install_patch.sh @@ -0,0 +1,19 @@ +#!/bin/bash -x + +TARGET=patch + +function _install() +{ + mkdir ${TARGET} + cd .. + QP_ROOT=$PWD + cd - + cd ${BUILD} + ./configure --prefix=${QP_ROOT}/install/${TARGET} && make || exit 1 + make install || exit 1 + cd - + cp ${TARGET}/bin/${TARGET} ${QP_ROOT}/bin || exit 1 + rm -R -- ${TARGET} || exit 1 +} + +source scripts/build.sh \ No newline at end of file diff --git a/install/scripts/install_resultsFile.sh b/install/scripts/install_resultsFile.sh new file mode 100755 index 00000000..d4238d5f --- /dev/null +++ b/install/scripts/install_resultsFile.sh @@ -0,0 +1,11 @@ +#!/bin/bash -x + +TARGET=resultsFile + +function _install() +{ + cp -R ${BUILD} . || exit 1 +} + +source scripts/build.sh + diff --git a/install/scripts/install_zlib.sh b/install/scripts/install_zlib.sh new file mode 100755 index 00000000..26139f5c --- /dev/null +++ b/install/scripts/install_zlib.sh @@ -0,0 +1,19 @@ +#!/bin/bash -x + +TARGET=zlib + +function _install() +{ + rm -rf -- ${TARGET} + mkdir ${TARGET} || exit 1 + cd .. + QP_ROOT=$PWD + cd - + cd ${BUILD} + ./configure && make || exit 1 + make install prefix=$QP_ROOT/install/${TARGET} || exit 1 + ln -s -f $QP_ROOT/install/${TARGET}/lib/libz.so $QP_ROOT/lib || exit 1 + ln -s -f $QP_ROOT/install/${TARGET}/lib/libz.a $QP_ROOT/lib || exit 1 +} + +source scripts/build.sh diff --git a/lib/.gitignore b/lib/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/ocaml/Makefile b/ocaml/Makefile index 7e514d1a..6bf8d81b 100644 --- a/ocaml/Makefile +++ b/ocaml/Makefile @@ -1,9 +1,9 @@ .NOPARALLEL: -# Check if QPACKAGE_ROOT is defined -ifndef QPACKAGE_ROOT +# Check if QP_ROOT is defined +ifndef QP_ROOT $(info -------------------- Error --------------------) -$(info QPACKAGE_ROOT undefined. Source the quantum_package.rc script) +$(info QP_ROOT undefined. Source the quantum_package.rc script) $(info -----------------------------------------------) $(error ) endif @@ -32,10 +32,10 @@ default: $(ALL_TESTS) $(ALL_EXE) .gitignore echo $$i ; \ done > .gitignore -executables: $(QPACKAGE_ROOT)/data/executables +executables: $(QP_ROOT)/data/executables -$(QPACKAGE_ROOT)/data/executables: - $(QPACKAGE_ROOT)/scripts/module/create_executables_list.sh +$(QP_ROOT)/data/executables: + $(QP_ROOT)/scripts/module/create_executables_list.sh external_libs: opam install cryptokit core @@ -62,8 +62,8 @@ qp_run.native: $(MLFILES) $(MLIFILES) executables $(OCAMLBUILD) $*.native -use-ocamlfind $(PKGS) ln -s $*.native $* -ezfio.ml: ${QPACKAGE_ROOT}/EZFIO/Ocaml/ezfio.ml - cp ${QPACKAGE_ROOT}/EZFIO/Ocaml/ezfio.ml . +ezfio.ml: ${QP_ROOT}/install/EZFIO/Ocaml/ezfio.ml + cp ${QP_ROOT}/install/EZFIO/Ocaml/ezfio.ml . qptypes_generator.byte: qptypes_generator.ml $(OCAMLBUILD) qptypes_generator.byte -use-ocamlfind @@ -71,8 +71,8 @@ qptypes_generator.byte: qptypes_generator.ml Qptypes.ml: qptypes_generator.byte ./qptypes_generator.byte > Qptypes.ml -${QPACKAGE_ROOT}/EZFIO/Ocaml/ezfio.ml: - $(MAKE) -C ${QPACKAGE_ROOT}/src ezfio +${QP_ROOT}/install/EZFIO/Ocaml/ezfio.ml: + $(MAKE) -C ${QP_ROOT}/install/src ezfio Input_auto_generated.ml qp_edit.ml: ei_handler.py ocaml_global diff --git a/ocaml/Qpackage.ml b/ocaml/Qpackage.ml index a3862f11..ef4476c6 100644 --- a/ocaml/Qpackage.ml +++ b/ocaml/Qpackage.ml @@ -5,8 +5,8 @@ open Qputils;; (** Variables related to the quantum package installation *) let root = - match (Sys.getenv "QPACKAGE_ROOT") with - | None -> failwith "QPACKAGE_ROOT environment variable is not set. + match (Sys.getenv "QP_ROOT") with + | None -> failwith "QP_ROOT environment variable is not set. Please source the quantum_package.rc file." | Some x -> x ;; @@ -59,7 +59,7 @@ let executables = lazy ( |> List.filter ~f:(fun x -> x <> "") in match e with - | [a;b] -> (a,String.substr_replace_all ~pattern:"$QPACKAGE_ROOT" ~with_:root b) + | [a;b] -> (a,String.substr_replace_all ~pattern:"$QP_ROOT" ~with_:root b) | _ -> ("","") ) in diff --git a/scripts/cache_compile.py b/scripts/cache_compile.py deleted file mode 100755 index 9898eae5..00000000 --- a/scripts/cache_compile.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python - -import os -import sys -import shelve -import hashlib -import re - -r = re.compile(ur'-c\s+(\S+\.[fF]90)\s+-o\s+(\S+\.o)') -p = re.compile(ur'-I IRPF90_temp/\S*\s+') -mod = re.compile(ur'module\s+(?P\S+).+end\s?module\s+(?P=mod)?', re.MULTILINE | re.IGNORECASE) - -TMPDIR="/tmp/qp_compiler/" - -def main(): - # Create temp directory - if "qp_compiler" not in os.listdir("/tmp"): - os.mkdir("/tmp/qp_compiler/") - - line = sys.argv[1:] - command = " ".join(line) - command_clean = p.sub('',command) - - try: - match = r.search(command_clean) - input = match.group(1) - output = match.group(2) - except: - os.system(command) - return - m = hashlib.md5() - - # Fread : read input - with open(input,'r') as file: - fread = file.read() - m.update( " ".join( [ command, fread ] )) - - # Md5 Key containing command + content of Fread - key = TMPDIR+m.hexdigest() - try: - # Try to return the content of the .o file - with open(key,'r') as file: - result = file.read() - except IOError: - # Compile the file -> .o - os.system(command) - # Read the .o - with open(output,'r') as file: - result = file.read() - # Copy the .o in database - if not mod.search(fread.replace('\n',' ')): - with open(key,'w') as file: - file.write(result) - else: - print input+' -> module' - else: - # Write the .o file - with open(output,'w') as file: - file.write(result) - -if __name__ == '__main__': - main() diff --git a/scripts/compilation/cache_compile.py b/scripts/compilation/cache_compile.py index d6aac8be..398dc1b9 100755 --- a/scripts/compilation/cache_compile.py +++ b/scripts/compilation/cache_compile.py @@ -104,5 +104,5 @@ if __name__ == '__main__': try: cache_utility(command) - except: + except OSError: process = subprocess.Popen(command, shell=True) diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index 343ccd89..620c5f1b 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -24,11 +24,11 @@ except ImportError: # \_| | (_) |_) (_| | \/ (_| | | (_| |_) | (/_ _> # -QPACKAGE_ROOT = os.environ['QPACKAGE_ROOT'] -QPACKAGE_ROOT_SRC = join(QPACKAGE_ROOT, 'src') -QPACKAGE_ROOT_EZFIO = join(QPACKAGE_ROOT, 'EZFIO') +QP_ROOT = os.environ['QP_ROOT'] +QP_ROOT_SRC = join(QP_ROOT, 'src') +QP_ROOT_EZFIO = join(QP_ROOT, 'install', 'EZFIO') -EZFIO_LIB = join(QPACKAGE_ROOT_EZFIO, "lib", "libezfio.a") +EZFIO_LIB = join(QP_ROOT, "lib", "libezfio.a") # # |\ | _. ._ _ _ _| _|_ ._ | _ @@ -57,8 +57,7 @@ def ninja_create_env_variable(pwd_config_file): l_string.append(str_) lib_lapack = get_compilation_option(pwd_config_file, "LAPACK_LIB") - lib_ezfio = join(QPACKAGE_ROOT_EZFIO, "lib", "libezfio_irp.a") - l_string.append("{0} = {1} {2}".format("LIB", lib_lapack, lib_ezfio)) + l_string.append("{0} = {1} {2}".format("LIB", lib_lapack, EZFIO_LIB)) l_string.append("") @@ -76,14 +75,14 @@ def dict_module_genelogy_path(d_module_genelogy): """ d = dict() for module_rel, l_children_rel in d_module_genelogy.iteritems(): - module_abs = join(QPACKAGE_ROOT_SRC, module_rel) + module_abs = join(QP_ROOT_SRC, module_rel) p = Path(module_abs, module_rel) try: - d[p] = Path(join(QPACKAGE_ROOT_SRC, l_children_rel), + d[p] = Path(join(QP_ROOT_SRC, l_children_rel), l_children_rel) except: - d[p] = [Path(join(QPACKAGE_ROOT_SRC, children), children) + d[p] = [Path(join(QP_ROOT_SRC, children), children) for children in l_children_rel] return d @@ -100,7 +99,7 @@ def get_l_module_with_ezfio_cfg(): """ from os import listdir from os.path import isfile, join - qp_src = QPACKAGE_ROOT_SRC + qp_src = QP_ROOT_SRC return [join(qp_src, m) for m in listdir(qp_src) if isfile(join(qp_src, m, "EZFIO.cfg"))] @@ -113,10 +112,10 @@ def get_l_ezfio_config(): l = [] - cmd = "{0}/*/*.ezfio_config".format(QPACKAGE_ROOT_SRC) + cmd = "{0}/*/*.ezfio_config".format(QP_ROOT_SRC) for path_in_module in glob.glob(cmd): name_lower = os.path.split(path_in_module)[1].lower() - path_in_ezfio = join(QPACKAGE_ROOT_EZFIO, "config", name_lower) + path_in_ezfio = join(QP_ROOT_EZFIO, "config", name_lower) l.append(EZ_config_path(path_in_module, path_in_ezfio)) return l @@ -147,7 +146,7 @@ def get_children_of_ezfio_cfg(l_module_with_ezfio_cfg): """ From a module list of ezfio_cfg return all the stuff create by him """ - config_folder = join(QPACKAGE_ROOT_EZFIO, "config") + config_folder = join(QP_ROOT_EZFIO, "config") l_util = dict() @@ -223,8 +222,9 @@ def ninja_ezfio_rule(): l_flag = ["export {0}='${0}'".format(flag) for flag in ["FC", "FCFLAGS", "IRPF90"]] - l_cmd = ["cd {0}".format(QPACKAGE_ROOT_EZFIO) - ] + l_flag + ["ninja"] + l_cmd = ["cd {0}".format(QP_ROOT_EZFIO) + ] + l_flag + ["ninja && ln -f {0} {1}".format(join(QP_ROOT, 'install', 'EZFIO',"lib","libezfio.a"), + EZFIO_LIB)] l_string = ["rule build_ezfio", " command = {0}".format(" ; ".join(l_cmd)), @@ -245,7 +245,7 @@ def ninja_ezfio_build(l_ezfio_config, l_util): str_ = " ".join(l_ezfio_config + l_ezfio_from_cfg) - ezfio_make_config = join(QPACKAGE_ROOT_EZFIO,"make.config") + ezfio_make_config = join(QP_ROOT_EZFIO, "make.config") l_string = ["build {0} {1}: build_ezfio {2}".format(EZFIO_LIB, ezfio_make_config, str_), ""] @@ -262,7 +262,7 @@ def get_source_destination(path_module, l_needed_molule): Return a list of Sym_link = namedtuple('Sym_link', ['source', 'destination']) for a module """ - return [Sym_link(m.abs, join(QPACKAGE_ROOT_SRC, path_module.rel, m.rel)) + return [Sym_link(m.abs, join(QP_ROOT_SRC, path_module.rel, m.rel)) for m in l_needed_molule] @@ -296,29 +296,30 @@ def ninja_symlink_build(path_module, l_symlink): # o ._ ._ _|_ (_| / \ ._ _ _. | _ # | | |_) | | \_/ o | | | (_| |< (/_ # | -def get_l_file_for_module(path_module_abs): +def get_l_file_for_module(path_module): ''' return the list of irp.f in a module ''' - l_irp = [] + l_depend = [] l_src = [] l_obj = [] l_template = [] - for f in os.listdir(path_module_abs): + for f in os.listdir(path_module.abs): if f.lower().endswith(tuple([".template.f", ".include.f"])): - l_template.append(join(path_module_abs, f)) + l_template.append(join(path_module.abs, f)) elif f.endswith(".irp.f"): - l_irp.append(join(path_module_abs, f)) + l_depend.append(join(path_module.abs, f)) elif f.lower().endswith(tuple([".f", ".f90", ".c", ".cpp", ".cxx"])): - l_src.append(join(path_module_abs, f)) + l_depend.append(join(path_module.abs,f)) + l_src.append(f) obj = '{0}.o'.format(os.path.splitext(f)[0]) - l_obj.append(join(path_module_abs, obj)) + l_obj.append(obj) elif f == "EZFIO.cfg": - l_irp.append(join(path_module_abs, "ezfio_interface.irp.f")) + l_depend.append(join(path_module.abs, "ezfio_interface.irp.f")) - d = {"l_irp": l_irp, + d = {"l_depend": l_depend, "l_src": l_src, "l_obj": l_obj, "l_template": l_template} @@ -334,11 +335,21 @@ def get_file_dependency(d_info_module): for module, l_children in d_info_module.iteritems(): - for key, values in get_l_file_for_module(module.abs).iteritems(): + for key, values in get_l_file_for_module(module).iteritems(): + if key in ["l_src"]: + values = [join(module.abs,o) for o in values] + if key in ["l_obj"]: + values = [join(module.abs,"IRPF90_temp",o) for o in values] + d_irp[module][key] = values for children in l_children: - for key, values in get_l_file_for_module(children.abs).iteritems(): + for key, values in get_l_file_for_module(children).iteritems(): + if key in ["l_src"]: + values = [join(module.abs,children.rel,o) for o in values] + if key in ["l_obj"]: + values = [join(module.abs,"IRPF90_temp",children.rel,o) for o in values] + d_irp[module][key].extend(values) return d_irp @@ -388,24 +399,24 @@ def ninja_irpf90_make_build(path_module, l_needed_molule, d_irp): l_creation = [join(path_module.abs, i) for i in ["irpf90.make", "irpf90_entities", "tags", - "IRPF90_temp/build.ninja"]] + "build.ninja"]] str_creation = " ".join(l_creation) # ~#~#~#~#~#~#~#~#~#~ # # D e p e n d a n c y # # ~#~#~#~#~#~#~#~#~#~ # - l_irp_need = d_irp[path_module]["l_irp"] + l_depend = d_irp[path_module]["l_depend"] l_src = d_irp[path_module]["l_src"] l_obj = d_irp[path_module]["l_obj"] l_template = d_irp[path_module]["l_template"] if l_needed_molule: - l_destination = ["l_symlink_{0}".format(path_module.rel)] + l_symlink = ["l_symlink_{0}".format(path_module.rel)] else: - l_destination = [] + l_symlink = [] - str_depend = " ".join(l_irp_need + l_destination + l_src + l_template) + str_depend = " ".join(l_depend + l_symlink + l_template) # ~#~#~#~#~#~#~#~#~#~#~ # # N i n j a _ b u i l d # @@ -521,7 +532,7 @@ def ninja_binaries_rule(): # c m d # # ~#~#~ # - l_cmd = ["cd $module/IRPF90_temp", "ninja"] + l_cmd = ["cd $module", "ninja"] # ~#~#~#~#~#~ # # s t r i n g # @@ -543,7 +554,7 @@ def ninja_binaries_build(path_module, l_children, d_binaries): # c m d # # ~#~#~ # - ninja_module_path = join(path_module.abs, "IRPF90_temp", "build.ninja") + ninja_module_path = join(path_module.abs, "build.ninja") l_abs_bin = [binary.abs for binary in d_binaries[path_module]] # ~#~#~#~#~#~ # @@ -694,5 +705,5 @@ if __name__ == "__main__": l_string += ninja_binaries_build(module_to_compile, l_children, d_binaries_production) - with open(join(QPACKAGE_ROOT, "build.ninja"), "w+") as f: + with open(join(QP_ROOT, "build.ninja"), "w+") as f: f.write("\n".join(l_string)) diff --git a/scripts/compilation/read_compilation_cfg.py b/scripts/compilation/read_compilation_cfg.py index 592b017c..f3ca01ce 100755 --- a/scripts/compilation/read_compilation_cfg.py +++ b/scripts/compilation/read_compilation_cfg.py @@ -36,7 +36,7 @@ def get_compilation_option(pwd_cfg, flag_name): if __name__ == '__main__': - qpackage_root = os.environ['QPACKAGE_ROOT'] + qpackage_root = os.environ['QP_ROOT'] pwd_cfg = os.path.join(qpackage_root, "config/gfortran_example.cfg") print get_compilation_option(pwd_cfg, "FC") diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 2d551db9..7e7482e8 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -21,11 +21,11 @@ Options: (aka all with the `interface: input` parameter) in `${pwd}` --ezfio_config Create the `${module_lower}_ezfio_interface_config` in - `${QPACKAGE_ROOT}/EZFIO/config/` + `${QP_ROOT}/EZFIO/config/` This file is needed by *EZFIO* to create the `libezfio.so` --ocaml Create the `Input_module.lower.ml` for the *qp_edit* --ezfio_default Create the `${module_lower}_ezfio_interface_default` in - `${QPACKAGE_ROOT}/data/ezfio_defaults` needed by + `${QP_ROOT}/data/ezfio_defaults` needed by the ocaml ocaml_global Create the qp_edit @@ -100,7 +100,7 @@ def get_type_dict(): # ~#~#~#~#~ # # P i c l e # # ~#~#~#~#~ # - qpackage_root = os.environ['QPACKAGE_ROOT'] + qpackage_root = os.environ['QP_ROOT'] # ~#~#~#~ # # I n i t # @@ -325,7 +325,7 @@ def save_ezfio_provider(path_head, dict_code_provider): path = "{0}/ezfio_interface.irp.f".format(path_head) l_output = ["! DO NOT MODIFY BY HAND", - "! Created by $QPACKAGE_ROOT/scripts/ezfio_interface.py", + "! Created by $QP_ROOT/scripts/ezfio_interface.py", "! from file {0}/EZFIO.cfg".format(path_head), "\n"] @@ -368,7 +368,7 @@ def create_ezfio_stuff(dict_ezfio_cfg, config_or_default="config"): if begin[0] == '-': a_size_raw.append("{0}+{1}+1".format(end, begin[1:])) else: - a_size_raw.append("{0}-{1}+1".format(end, begin)) + a_size_raw.append("{0}-{1}+1".format(end, begin)) size_raw = ",".join(a_size_raw) @@ -452,12 +452,10 @@ def create_ezfio_config(dict_ezfio_cfg): def save_ezfio_config(module_lower, str_ezfio_config): """ Write the str_ezfio_config in - "$QPACKAGE_ROOT/EZFIO/{0}.ezfio_interface_config".format(module_lower) + "$QP_ROOT/EZFIO/{0}.ezfio_interface_config".format(module_lower) """ - - root_ezfio = "{0}/EZFIO".format(os.environ['QPACKAGE_ROOT']) - path = "{0}/config/{1}.ezfio_interface_config".format(root_ezfio, - module_lower) + name = "{0}.ezfio_interface_config".format(module_lower) + path = os.path.join(os.environ['QP_EZFIO'], "config", name) with open(path, "w+") as f: f.write(str_ezfio_config) @@ -471,11 +469,11 @@ def create_ezfio_default(dict_ezfio_cfg): def save_ezfio_default(module_lower, str_ezfio_default): """ Write the str_ezfio_config in - "$QPACKAGE_ROOT/data/ezfio_defaults/{0}.ezfio_interface_default".format(module_lower) + "$QP_ROOT/data/ezfio_defaults/{0}.ezfio_interface_default".format(module_lower) """ root_ezfio_default = "{0}/data/ezfio_defaults/".format( - os.environ['QPACKAGE_ROOT']) + os.environ['QP_ROOT']) path = "{0}/{1}.ezfio_interface_default".format(root_ezfio_default, module_lower) with open(path, "w+") as f: @@ -580,10 +578,10 @@ def create_ocaml_input(dict_ezfio_cfg, module_lower): def save_ocaml_input(module_lower, str_ocaml_input): """ Write the str_ocaml_input in - $QPACKAGE_ROOT/ocaml/Input_{0}.ml".format(module_lower) + $QP_ROOT/ocaml/Input_{0}.ml".format(module_lower) """ - path = "{0}/ocaml/Input_{1}.ml".format(os.environ['QPACKAGE_ROOT'], + path = "{0}/ocaml/Input_{1}.ml".format(os.environ['QP_ROOT'], module_lower) with open(path, "w+") as f: @@ -600,7 +598,7 @@ def get_l_module_with_auto_generate_ocaml_lower(): # I n i t # # ~#~#~#~ # - mypath = "{0}/src".format(os.environ['QPACKAGE_ROOT']) + mypath = "{0}/src".format(os.environ['QP_ROOT']) # ~#~#~#~#~#~#~#~ # # L _ f o l d e r # @@ -641,7 +639,7 @@ def create_ocaml_input_global(l_module_with_auto_generate_ocaml_lower): from ezfio_generate_ocaml import EZFIO_ocaml - qpackage_root = os.environ['QPACKAGE_ROOT'] + qpackage_root = os.environ['QP_ROOT'] path = qpackage_root + "/scripts/ezfio_interface/qp_edit_template" with open(path, "r") as f: @@ -663,10 +661,10 @@ def create_ocaml_input_global(l_module_with_auto_generate_ocaml_lower): def save_ocaml_input_auto(str_ocaml_input_global): """ Write the str_ocaml_input in - $QPACKAGE_ROOT/ocaml/Input_auto_generated.ml + $QP_ROOT/ocaml/Input_auto_generated.ml """ - path = "{0}/ocaml/Input_auto_generated.ml".format(os.environ['QPACKAGE_ROOT']) + path = "{0}/ocaml/Input_auto_generated.ml".format(os.environ['QP_ROOT']) with open(path, "w+") as f: f.write(str_ocaml_input_global) @@ -675,10 +673,10 @@ def save_ocaml_input_auto(str_ocaml_input_global): def save_ocaml_qp_edit(str_ocaml_qp_edit): """ Write the str_ocaml_qp_edit in - $QPACKAGE_ROOT/ocaml/qp_edit.ml + $QP_ROOT/ocaml/qp_edit.ml """ - path = "{0}/ocaml/qp_edit.ml".format(os.environ['QPACKAGE_ROOT']) + path = "{0}/ocaml/qp_edit.ml".format(os.environ['QP_ROOT']) with open(path, "w+") as f: f.write(str_ocaml_qp_edit) @@ -773,7 +771,7 @@ if __name__ == "__main__": # G e t _ l _ d i c t _ e z f i o _ c f g # # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# # - qpackage_root_src = join(os.environ['QPACKAGE_ROOT'], "src") + qpackage_root_src = join(os.environ['QP_ROOT'], "src") l_module_with_ezfio = [] diff --git a/scripts/ezfio_interface/qp_convert_output_to_ezfio.py b/scripts/ezfio_interface/qp_convert_output_to_ezfio.py index 0857f598..ff7ad225 100755 --- a/scripts/ezfio_interface/qp_convert_output_to_ezfio.py +++ b/scripts/ezfio_interface/qp_convert_output_to_ezfio.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ -This function acceep +convert output of gamess/GAU$$IAN to ezfio Usage: qp_convert_output_to_ezfio.py [--ezfio=] @@ -24,14 +24,14 @@ from functools import reduce try: - QPACKAGE_ROOT = os.environ["QPACKAGE_ROOT"] + QP_ROOT = os.environ["QP_ROOT"] except: - print "Error: QPACKAGE_ROOT environment variable not found." + print "Error: QP_ROOT environment variable not found." sys.exit(1) else: - sys.path = [QPACKAGE_ROOT + "/EZFIO/Python", - QPACKAGE_ROOT + "/resultsFile", - QPACKAGE_ROOT + "/scripts"] + sys.path + sys.path = [QP_ROOT + "/install/EZFIO/Python", + QP_ROOT + "/resultsFile", + QP_ROOT + "/scripts"] + sys.path # ~#~#~#~#~#~ # # I m p o r t # diff --git a/scripts/ezfio_interface/qp_edit_template b/scripts/ezfio_interface/qp_edit_template index 2990a193..218b21ae 100644 --- a/scripts/ezfio_interface/qp_edit_template +++ b/scripts/ezfio_interface/qp_edit_template @@ -260,7 +260,7 @@ Edit input data | Assert_failure (file, line, ch) as e -> begin Printf.eprintf "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n\n"; - Printf.eprintf "Assert error in file $QPACKAGE_ROOT/ocaml/%s, line %d, character %d\n\n" file line ch; + Printf.eprintf "Assert error in file $QP_ROOT/ocaml/%s, line %d, character %d\n\n" file line ch; Printf.eprintf "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-\n\n"; (* restore_backup ezfio_file; *) raise e diff --git a/scripts/generate_h_apply.py b/scripts/generate_h_apply.py index 85eb63d3..563a7a56 100755 --- a/scripts/generate_h_apply.py +++ b/scripts/generate_h_apply.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import os -file = open(os.environ["QPACKAGE_ROOT"]+'/src/Determinants/H_apply.template.f','r') +file = open(os.environ["QP_ROOT"]+'/src/Determinants/H_apply.template.f','r') template = file.read() file.close() diff --git a/scripts/get_basis.sh b/scripts/get_basis.sh index 5db71852..ec07aa6d 100755 --- a/scripts/get_basis.sh +++ b/scripts/get_basis.sh @@ -8,15 +8,14 @@ # Prints in stdout the name of a temporary file containing the basis set. # -if [[ -z ${QPACKAGE_ROOT} ]] +if [[ -z ${QP_ROOT} ]] then - print "The QPACKAGE_ROOT environment variable is not set." + print "The QP_ROOT environment variable is not set." print "Please reload the quantum_package.rc file." exit -1 fi -export EMSL_API_ROOT="${QPACKAGE_ROOT}"/EMSL_Basis/ -export PYTHONPATH="${EMSL_API_ROOT}":${PYTHONPATH} +export EMSL_API_ROOT="${QP_ROOT}"/install/emsl tmpfile="$1" shift diff --git a/scripts/install/install_curl.sh b/scripts/install/install_curl.sh deleted file mode 100755 index 5f32e384..00000000 --- a/scripts/install/install_curl.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# Installs curl for ocaml -# Mon Jan 12 18:52:48 CET 2015 - -CURL="curl-7.30.0.ermine" -CURL_URL="http://qmcchem.ups-tlse.fr/files/scemama/${CURL}.tar.bz2" - -if [[ -z ${QPACKAGE_ROOT} ]] -then - echo "The QPACKAGE_ROOT environment variable is not set." - echo "Please reload the quantum_package.rc file." - exit -1 -fi - -cd ${QPACKAGE_ROOT} - -curl -kL "https://github.com/LCPQ/quantum_package" &> /dev/null -if [[ $? -eq 0 ]] -then - exit 0 -fi - -rm -f -- ${QPACKAGE_ROOT}/bin/curl -${QPACKAGE_ROOT}/scripts/install/fetch_from_web.py ${CURL_URL} CURL.tar.bz2 -tar -jxf CURL.tar.bz2 && rm CURL.tar.bz2 ||exit 1 -cd ${CURL} || exit 1 -mv curl.ermine ${QPACKAGE_ROOT}/bin/curl -cd ${QPACKAGE_ROOT} -rm -rf -- ${CURL} - diff --git a/scripts/install/install_docopt.sh b/scripts/install/install_docopt.sh deleted file mode 100755 index 862e61cd..00000000 --- a/scripts/install/install_docopt.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Installs docopt -# lundi 27 avril 2015, 16:51:34 (UTC+0200) - -DOCOPT="docopt.py" -DOCOPT_URL="https://raw.githubusercontent.com/docopt/docopt/master/${DOCOPT}" - -if [[ -z ${QPACKAGE_ROOT} ]] -then - echo "The QPACKAGE_ROOT environment variable is not set." - echo "Please reload the quantum_package.rc file." - exit -1 -fi - -cd ${QPACKAGE_ROOT} - -rm -f -- scripts/${DOCOPT}{,c} -${QPACKAGE_ROOT}/scripts/install/fetch_from_web.py ${DOCOPT_URL} ${DOCOPT} - -mv ${DOCOPT} scripts/utility/${DOCOPT} diff --git a/scripts/install/install_emsl.sh b/scripts/install/install_emsl.sh deleted file mode 100755 index b0bbc820..00000000 --- a/scripts/install/install_emsl.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# Installs EMSL_Basis_Set_Exchange_Local -# Mon Jan 12 12:57:19 CET 2015 - -BASE="EMSL_Basis_Set_Exchange_Local" -URL="https://github.com/LCPQ/${BASE}/archive/master.tar.gz" - -if [[ -z ${QPACKAGE_ROOT} ]] -then - echo "The QPACKAGE_ROOT environment variable is not set." - echo "Please reload the quantum_package.rc file." - exit -1 -fi - -cd ${QPACKAGE_ROOT} - -${QPACKAGE_ROOT}/scripts/install/fetch_from_web.py ${URL} ${QPACKAGE_ROOT}/${BASE}.tar.gz -tar -zxf ${BASE}.tar.gz && rm ${BASE}.tar.gz ||exit 1 -rm -rf EMSL_Basis -mv ${BASE}-master EMSL_Basis - - diff --git a/scripts/install/install_ezfio.sh b/scripts/install/install_ezfio.sh deleted file mode 100755 index 7e9a39e2..00000000 --- a/scripts/install/install_ezfio.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Installs EZFIO -# Mon Jan 12 16:06:44 CET 2015 - -BASE="ezfio" -URL="https://github.com/LCPQ/${BASE}/archive/master.tar.gz" - -if [[ -z ${QPACKAGE_ROOT} ]] -then - echo "The QPACKAGE_ROOT environment variable is not set." - echo "Please reload the quantum_package.rc file." - exit -1 -fi - -cd ${QPACKAGE_ROOT} - -rm -rf -- EZFIO -${QPACKAGE_ROOT}/scripts/install/fetch_from_web.py ${URL} ${QPACKAGE_ROOT}/${BASE}.tar.gz -tar -zxf ${BASE}.tar.gz && rm ${BASE}.tar.gz ||exit 1 -mv EZFIO-master EZFIO - - - diff --git a/scripts/install/install_irpf90.sh b/scripts/install/install_irpf90.sh deleted file mode 100755 index 251cd9f3..00000000 --- a/scripts/install/install_irpf90.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# -# Installs irpf90 -# Mon Jan 12 16:00:20 CET 2015 - -BASE="irpf90" -URL="https://github.com/LCPQ/${BASE}/archive/master.tar.gz" - -# Check the QPACKAGE_ROOT directory -if [[ -z ${QPACKAGE_ROOT} ]] -then - echo "The QPACKAGE_ROOT environment variable is not set." - echo "Please reload the quantum_package.rc file." - exit 1 -fi - -cd ${QPACKAGE_ROOT} - - -${QPACKAGE_ROOT}/scripts/install/fetch_from_web.py ${URL} ${QPACKAGE_ROOT}/${BASE}.tar.gz -tar -zxf ${BASE}.tar.gz && rm ${BASE}.tar.gz ||exit 1 -mv ${BASE}-master irpf90 -make -C irpf90 -rm -rf -- bin/irpf90 bin/irpman -echo '${QPACKAGE_ROOT}/irpf90/bin/irpf90 $@' > bin/irpf90 -echo '${QPACKAGE_ROOT}/irpf90/bin/irpman $@' > bin/irpman -chmod +x bin/irpf90 bin/irpman - - diff --git a/scripts/install/install_m4.sh b/scripts/install/install_m4.sh deleted file mode 100755 index 6495b82e..00000000 --- a/scripts/install/install_m4.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# Installs m4 for ocaml -# Thu Oct 23 22:02:08 CEST 2014 - -M4_URL="http://ftp.gnu.org/gnu/m4/m4-latest.tar.gz" -M4=$(which m4) - -# Check the QPACKAGE_ROOT directory -if [[ -z ${QPACKAGE_ROOT} ]] -then - echo "The QPACKAGE_ROOT environment variable is not set." - echo "Please reload the quantum_package.rc file." - exit 1 -fi - -cd ${QPACKAGE_ROOT} - -rm -f l${QPACKAGE_ROOT}/bin/m4 -if [[ -z ${M4} ]] -then - rm -f -- bin/m4 - ${QPACKAGE_ROOT}/scripts/install/fetch_from_web.py ${M4_URL} M4.tar.gz - tar -zxf M4.tar.gz && rm M4.tar.gz ||exit 1 - cd m4* || exit 1 - ./configure && make || exit 1 - ln -s ${PWD}/src/m4 ${QPACKAGE_ROOT}/bin -else - ln -s ${M4} ${QPACKAGE_ROOT}/bin/m4 -fi - diff --git a/scripts/install/install_ninja.sh b/scripts/install/install_ninja.sh deleted file mode 100755 index e54c5366..00000000 --- a/scripts/install/install_ninja.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -# -# Installs the ninja build system -# Thu May 28 13:21:16 CEST 2015 - -BASE="ninja" -URL="https://github.com/martine/ninja/archive/master.tar.gz" - -if [[ -z ${QPACKAGE_ROOT} ]] -then - echo "The QPACKAGE_ROOT environment variable is not set." - echo "Please reload the quantum_package.rc file." - exit -1 -fi - -cd ${QPACKAGE_ROOT} - -${QPACKAGE_ROOT}/scripts/install/fetch_from_web.py ${URL} ${QPACKAGE_ROOT}/${BASE}.tar.gz -tar -zxf ${BASE}.tar.gz && rm ${BASE}.tar.gz ||exit 1 -rm -rf ${BASE} -mv ${BASE}-master ${BASE} -cd ${BASE} -./configure.py --bootstrap diff --git a/scripts/install/install_ocaml.sh b/scripts/install/install_ocaml.sh deleted file mode 100755 index fe02e9df..00000000 --- a/scripts/install/install_ocaml.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -# -# Downloads and installs ocaml, opam and core library -# Thu Oct 23 21:58:40 CEST 2014 - -PACKAGES="core cryptokit" -OPAM_BASE=$HOME/.opam - -# Check the QPACKAGE_ROOT directory -if [[ -z ${QPACKAGE_ROOT} ]] -then - echo "The QPACKAGE_ROOT environment variable is not set." - echo "Please reload the quantum_package.rc file." - exit 1 -fi - -cd ${QPACKAGE_ROOT} - - -if [[ -f quantum_package.rc ]] -then - source quantum_package.rc -fi -make -C ocaml Qptypes.ml &> /dev/null - -if [[ $? -ne 0 ]] -then - - if [[ -d ${OPAM_BASE} ]] - then - echo "${OPAM_BASE} exists." - echo "Re-install ? [y/N]" - while read -r -n 1 -s answer; do - if [[ $answer = [YyNn] ]]; then - if [[ $answer = [Yy] ]] ; then - echo " - Remove your directory ${OPAM_BASE}" - echo " - Restart setup" - exit 1 - fi - if [[ $answer = [Nn] ]] ; then - make -C ocaml Qptypes.ml - exit 0 - fi - fi - done - fi -fi -${QPACKAGE_ROOT}/scripts/install/fetch_from_web.py \ - "https://raw.github.com/ocaml/opam/master/shell/opam_installer.sh" opam_installer.sh -chmod +x opam_installer.sh -echo N | ./opam_installer.sh ${QPACKAGE_ROOT}/bin - -if [[ ! -f ${QPACKAGE_ROOT}/bin/opam ]] -then - echo "Installation of OPAM failed" - exit 2 -fi -rm -f opam_installer.sh -${QPACKAGE_ROOT}/bin/opam config setup -a --dot-profile ${QPACKAGE_ROOT}/quantum_package.rc - -source ${QPACKAGE_ROOT}/quantum_package.rc -echo Y | opam install ${PACKAGES} - -make -C ocaml Qptypes.ml - -exit 0 - diff --git a/scripts/install/install_resultsFile.sh b/scripts/install/install_resultsFile.sh deleted file mode 100755 index dc5c5d11..00000000 --- a/scripts/install/install_resultsFile.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Installs the resultsFile Python library -# Mon Jan 19 15:08:18 CET 2015 - -URL="https://github.com/LCPQ/resultsFile/archive/master.tar.gz" - -# Check the QPACKAGE_ROOT directory -if [[ -z ${QPACKAGE_ROOT} ]] -then - echo "The QPACKAGE_ROOT environment variable is not set." - echo "Please reload the quantum_package.rc file." - exit 1 -fi - -cd ${QPACKAGE_ROOT} - - -rm -rf resultsFile-master -${QPACKAGE_ROOT}/scripts/install/fetch_from_web.py ${URL} ${QPACKAGE_ROOT}/resultsFile.tar.gz -tar -zxf resultsFile.tar.gz && rm resultsFile.tar.gz ||exit 1 -mv resultsFile-master resultsFile - - diff --git a/scripts/install/install_zlib.sh b/scripts/install/install_zlib.sh deleted file mode 100755 index 30f0055b..00000000 --- a/scripts/install/install_zlib.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -# -# Installs zlib for ocaml cryptokit -# Mon Jan 12 18:52:48 CET 2015 - -ZLIB="zlib-1.2.8" -ZLIB_URL="http://zlib.net/${ZLIB}.tar.gz" - -# Check the QPACKAGE_ROOT directory -if [[ -z ${QPACKAGE_ROOT} ]] -then - echo "The QPACKAGE_ROOT environment variable is not set." - echo "Please reload the quantum_package.rc file." - exit 1 -fi - -cd ${QPACKAGE_ROOT} - - -cat > /tmp/main.c << EOF -int main () {} -EOF -gcc /tmp/main.c -lz -if [[ $? -eq 0 ]] -then - rm /tmp/main.c "a.out" - exit 0 -fi -rm /tmp/main.c - -${QPACKAGE_ROOT}/scripts/install/fetch_from_web.py ${ZLIB_URL} ZLIB.tar.gz -tar -zxf ZLIB.tar.gz && rm ZLIB.tar.gz ||exit 1 -cd ${ZLIB} || exit 1 -./configure && make -make install prefix=$QPACKAGE_ROOT -cd ${QPACKAGE_ROOT} -rm -rf -- ${ZLIB} - diff --git a/scripts/make_binary.sh b/scripts/make_binary.sh index 832be596..d18e0d04 100755 --- a/scripts/make_binary.sh +++ b/scripts/make_binary.sh @@ -6,15 +6,15 @@ # -# Check the QPACKAGE_ROOT directory -if [[ -z ${QPACKAGE_ROOT} ]] +# Check the QP_ROOT directory +if [[ -z ${QP_ROOT} ]] then - echo "The QPACKAGE_ROOT environment variable is not set." + echo "The QP_ROOT environment variable is not set." echo "Please reload the quantum_package.rc file." exit 1 fi -cd ${QPACKAGE_ROOT} +cd ${QP_ROOT} if [[ -f quantum_package.rc \ && -f README.md \ && -d src \ @@ -35,7 +35,7 @@ fi # Build all sources -for dir in ${QPACKAGE_ROOT}/{src,ocaml} +for dir in ${QP_ROOT}/{src,ocaml} do make -C ${dir} if [[ $? -ne 0 ]] @@ -46,7 +46,7 @@ done # Copy the files in the static directory -QPACKAGE_STATIC=${QPACKAGE_ROOT}/quantum_package_static +QPACKAGE_STATIC=${QP_ROOT}/quantum_package_static function find_libs () { @@ -58,7 +58,7 @@ function find_libs () function find_exec () { - find ${QPACKAGE_ROOT}/$1 -perm /u+x -type f + find ${QP_ROOT}/$1 -perm /u+x -type f } @@ -111,12 +111,12 @@ cd - for i in ${FORTRAN_EXEC} do i=$(basename $i) - echo $i \$QPACKAGE_ROOT/bin/$i + echo $i \$QP_ROOT/bin/$i done >> ${QPACKAGE_STATIC}/data/executables -cp ${QPACKAGE_ROOT}/data/ezfio_defaults ${QPACKAGE_STATIC}/data +cp ${QP_ROOT}/data/ezfio_defaults ${QPACKAGE_STATIC}/data mkdir -p ${QPACKAGE_STATIC}/src/Bitmask -cp ${QPACKAGE_ROOT}/src/Bitmask/bitmasks_module.f90 ${QPACKAGE_STATIC}/src/Bitmask +cp ${QP_ROOT}/src/Bitmask/bitmasks_module.f90 ${QPACKAGE_STATIC}/src/Bitmask # echo "Copying dynamic libraries" @@ -143,10 +143,10 @@ cp -- ${QPACKAGE_STATIC}/extra_lib/lib{[gi]omp*,mkl*,lapack*,blas*,z*} ${QPACKAG echo "Copying EMSL_Basis directory" # ---------------------------- -cp -r -- ${QPACKAGE_ROOT}/EMSL_Basis ${QPACKAGE_STATIC}/ +cp -r -- ${QP_ROOT}/EMSL_Basis ${QPACKAGE_STATIC}/ if [[ $? -ne 0 ]] ; then - echo 'cp -r -- ${QPACKAGE_ROOT}/EMSL_Basis ${QPACKAGE_STATIC}/' + echo 'cp -r -- ${QP_ROOT}/EMSL_Basis ${QPACKAGE_STATIC}/' exit 1 fi @@ -155,10 +155,10 @@ fi echo "Copying scripts directory" # ------------------------- -cp -r -- ${QPACKAGE_ROOT}/scripts ${QPACKAGE_STATIC}/ +cp -r -- ${QP_ROOT}/scripts ${QPACKAGE_STATIC}/ if [[ $? -ne 0 ]] ; then - echo 'cp -r -- ${QPACKAGE_ROOT}/scripts ${QPACKAGE_STATIC}/' + echo 'cp -r -- ${QP_ROOT}/scripts ${QPACKAGE_STATIC}/' exit 1 fi @@ -168,13 +168,13 @@ echo "Creating quantum_package.rc" # --------------------------- cat << EOF > ${QPACKAGE_STATIC}/quantum_package.rc -export QPACKAGE_ROOT=\$( cd \$(dirname "\${BASH_SOURCE}") ; pwd -P ) -export LD_LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LD_LIBRARY_PATH} -export LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LIBRARY_PATH} -export PYTHONPATH="\${QPACKAGE_ROOT}"/scripts:\${PYTHONPATH} -export PATH="\${QPACKAGE_ROOT}"/scripts:\${PATH} -export PATH="\${QPACKAGE_ROOT}"/bin:\${PATH} -export PATH="\${QPACKAGE_ROOT}"/ocaml:\${PATH} +export QP_ROOT=\$( cd \$(dirname "\${BASH_SOURCE}") ; pwd -P ) +export LD_LIBRARY_PATH="\${QP_ROOT}"/lib:\${LD_LIBRARY_PATH} +export LIBRARY_PATH="\${QP_ROOT}"/lib:\${LIBRARY_PATH} +export PYTHONPATH="\${QP_ROOT}"/scripts:\${PYTHONPATH} +export PATH="\${QP_ROOT}"/scripts:\${PATH} +export PATH="\${QP_ROOT}"/bin:\${PATH} +export PATH="\${QP_ROOT}"/ocaml:\${PATH} EOF #exit 0 diff --git a/scripts/module/clean_modules.sh b/scripts/module/clean_modules.sh index 19db6f46..c4ec9dc4 100755 --- a/scripts/module/clean_modules.sh +++ b/scripts/module/clean_modules.sh @@ -2,13 +2,13 @@ # # Cleans a module directory -if [[ -z ${QPACKAGE_ROOT} ]] +if [[ -z ${QP_ROOT} ]] then - print "The QPACKAGE_ROOT environment variable is not set." + print "The QP_ROOT environment variable is not set." print "Please reload the quantum_package.rc file." exit -1 fi -source ${QPACKAGE_ROOT}/scripts/qp_include.sh +source ${QP_ROOT}/scripts/qp_include.sh function do_clean() { diff --git a/scripts/module/create_executables_list.sh b/scripts/module/create_executables_list.sh index 549eb3f6..2f530379 100755 --- a/scripts/module/create_executables_list.sh +++ b/scripts/module/create_executables_list.sh @@ -2,20 +2,20 @@ # # Thu Mar 26 01:27:14 CET 2015 -if [[ -z ${QPACKAGE_ROOT} ]] +if [[ -z ${QP_ROOT} ]] then - print "The QPACKAGE_ROOT environment variable is not set." + print "The QP_ROOT environment variable is not set." print "Please reload the quantum_package.rc file." exit -1 fi -cd ${QPACKAGE_ROOT}/data +cd ${QP_ROOT}/data rm -f executables -EXES=$(find ${QPACKAGE_ROOT}/src -perm /u+x -type f | grep -e "${QPACKAGE_ROOT}/src/[^/]*/[^/]*$" |sort ) +EXES=$(find ${QP_ROOT}/src -perm /u+x -type f | grep -e "${QP_ROOT}/src/[^/]*/[^/]*$" |sort ) for EXE in $EXES do - printf "%-30s %s\n" $(basename $EXE) $EXE | sed "s|${QPACKAGE_ROOT}|\$QPACKAGE_ROOT|g" >> executables + printf "%-30s %s\n" $(basename $EXE) $EXE | sed "s|${QP_ROOT}|\$QP_ROOT|g" >> executables done diff --git a/scripts/module/create_gitignore.sh b/scripts/module/create_gitignore.sh index a56a54b0..dde75e70 100755 --- a/scripts/module/create_gitignore.sh +++ b/scripts/module/create_gitignore.sh @@ -5,13 +5,13 @@ # Tue Jan 13 14:18:05 CET 2015 # -if [[ -z ${QPACKAGE_ROOT} ]] +if [[ -z ${QP_ROOT} ]] then - print "The QPACKAGE_ROOT environment variable is not set." + print "The QP_ROOT environment variable is not set." print "Please reload the quantum_package.rc file." exit -1 fi -source ${QPACKAGE_ROOT}/scripts/qp_include.sh +source ${QP_ROOT}/scripts/qp_include.sh function do_gitingore() diff --git a/scripts/module/module_handler.py b/scripts/module/module_handler.py index 6e9f0ba7..e8d58889 100755 --- a/scripts/module/module_handler.py +++ b/scripts/module/module_handler.py @@ -30,13 +30,13 @@ except ImportError: # Canot cache for namedtuple are not hashable def get_dict_child(): - """Loop over MODULE in QPACKAGE_ROOT/src, open all the NEEDED_CHILDREN_MODULES + """Loop over MODULE in QP_ROOT/src, open all the NEEDED_CHILDREN_MODULES and create a dict[MODULE] = [sub module needed, ...] """ d_ref = dict() - qpackage_root = os.environ['QPACKAGE_ROOT'] - dir_ = os.path.join(qpackage_root, 'src') + qp_root = os.environ['QP_ROOT'] + dir_ = os.path.join(qp_root, 'src') for o in os.listdir(dir_): diff --git a/scripts/module/qp_install_module.py b/scripts/module/qp_install_module.py index 11e8d7ea..2c5dd4fe 100755 --- a/scripts/module/qp_install_module.py +++ b/scripts/module/qp_install_module.py @@ -61,7 +61,7 @@ if __name__ == '__main__': elif arguments["create"]: l_children = arguments[""] - qpackage_root = os.environ['QPACKAGE_ROOT'] + qpackage_root = os.environ['QP_ROOT'] path = os.path.join(qpackage_root, "src", arguments[""]) print "You will create the module:" diff --git a/scripts/perturbation.py b/scripts/perturbation.py index 8b0f8b01..fab02b25 100755 --- a/scripts/perturbation.py +++ b/scripts/perturbation.py @@ -2,7 +2,7 @@ import os -Pert_dir = os.environ["QPACKAGE_ROOT"]+"/src/Perturbation/" +Pert_dir = os.environ["QP_ROOT"]+"/src/Perturbation/" perturbations = [] diff --git a/scripts/pseudo/put_pseudo_in_ezfio.py b/scripts/pseudo/put_pseudo_in_ezfio.py index d5dfb584..ff63a18d 100755 --- a/scripts/pseudo/put_pseudo_in_ezfio.py +++ b/scripts/pseudo/put_pseudo_in_ezfio.py @@ -17,9 +17,9 @@ from docopt import docopt from subprocess import Popen, PIPE -qpackage_root = os.environ['QPACKAGE_ROOT'] +qpackage_root = os.environ['QP_ROOT'] -EZFIO = "{0}/EZFIO".format(qpackage_root) +EZFIO = "{0}/install/EZFIO".format(qpackage_root) sys.path = [EZFIO + "/Python"] + sys.path from ezfio import ezfio @@ -51,7 +51,7 @@ def get_pseudo_str(l_atom): 10.11238853 0 1.14052020 |1><1| """ - EMSL_root = "{0}/EMSL_Basis/".format(qpackage_root) + EMSL_root = "{0}/install/emsl/".format(qpackage_root) EMSL_path = "{0}/EMSL_api.py".format(EMSL_root) db_path = "{0}/db/Pseudo.db".format(EMSL_root) diff --git a/scripts/qp_include.sh b/scripts/qp_include.sh index 9146215f..f67e942f 100644 --- a/scripts/qp_include.sh +++ b/scripts/qp_include.sh @@ -13,23 +13,23 @@ function unique_list() function check_current_dir_is_src() { - if [[ "${PWD}" == "${QPACKAGE_ROOT}/src" ]] + if [[ "${PWD}" == "${QP_ROOT}/src" ]] then return 0 else - echo "Current directory should be \$QPACKAGE_ROOT/src" + echo "Current directory should be \$QP_ROOT/src" exit -1 fi } function check_current_dir_is_module() { - # If the prefix ${QPACKAGE_ROOT}/src/ can be removed from $PWD, it means that - # $PWD is somewhere below ${QPACKAGE_ROOT}/src/ so it is a module. - # If the prefix ${QPACKAGE_ROOT}/src/ can not be removed from $PWD, then - # "${PWD##${QPACKAGE_ROOT}/src/}" == "$PWD". + # If the prefix ${QP_ROOT}/src/ can be removed from $PWD, it means that + # $PWD is somewhere below ${QP_ROOT}/src/ so it is a module. + # If the prefix ${QP_ROOT}/src/ can not be removed from $PWD, then + # "${PWD##${QP_ROOT}/src/}" == "$PWD". - if [[ "${PWD##${QPACKAGE_ROOT}/src/}" != "$PWD" ]] + if [[ "${PWD##${QP_ROOT}/src/}" != "$PWD" ]] then return 0 else diff --git a/scripts/qp_set_frozen_core.py b/scripts/qp_set_frozen_core.py index bd36a2c0..843df4b3 100755 --- a/scripts/qp_set_frozen_core.py +++ b/scripts/qp_set_frozen_core.py @@ -3,7 +3,7 @@ import os import sys -sys.path = [ os.environ["QPACKAGE_ROOT"]+"/EZFIO/Python" ] + sys.path +sys.path = [ os.environ["QP_ROOT"]+"/EZFIO/Python" ] + sys.path from ezfio import ezfio ezfio.set_filename(sys.argv[1]) diff --git a/scripts/save_current_mos.sh b/scripts/save_current_mos.sh index 36149ae2..4ad81e93 100755 --- a/scripts/save_current_mos.sh +++ b/scripts/save_current_mos.sh @@ -4,9 +4,9 @@ # directory, where xxx is the corresponding mo_label. # Wed Apr 2 14:35:15 CEST 2014 -if [[ -z ${QPACKAGE_ROOT} ]] +if [[ -z ${QP_ROOT} ]] then - print "The QPACKAGE_ROOT environment variable is not set." + print "The QP_ROOT environment variable is not set." print "Please reload the quantum_package.rc file." exit -1 fi diff --git a/scripts/upgrade/upgrade_ezfio.sh b/scripts/upgrade/upgrade_ezfio.sh index c35a2dbd..71ee990a 100755 --- a/scripts/upgrade/upgrade_ezfio.sh +++ b/scripts/upgrade/upgrade_ezfio.sh @@ -3,24 +3,24 @@ # Upgrades the EZFIO library from the web. # Tue Nov 4 00:53:13 CET 2014 -if [[ -z ${QPACKAGE_ROOT} ]] +if [[ -z ${QP_ROOT} ]] then - print "The QPACKAGE_ROOT environment variable is not set." + print "The QP_ROOT environment variable is not set." print "Please reload the quantum_package.rc file." fi -cd -- ${QPACKAGE_ROOT} -mv -- ${QPACKAGE_ROOT}/EZFIO ${QPACKAGE_ROOT}/EZFIO.old +cd -- ${QP_ROOT} +mv -- ${QP_ROOT}/EZFIO ${QP_ROOT}/EZFIO.old -${QPACKAGE_ROOT}/scripts/install/install_ezfio.sh +${QP_ROOT}/scripts/install/install_ezfio.sh if [[ $? -eq 0 ]] then - rm -rf -- ${QPACKAGE_ROOT}/EZFIO.old + rm -rf -- ${QP_ROOT}/EZFIO.old echo "Successfully updated EZFIO" else - rm -rf -- ${QPACKAGE_ROOT}/EZFIO - mv -- ${QPACKAGE_ROOT}/EZFIO.old ${QPACKAGE_ROOT}/EZFIO + rm -rf -- ${QP_ROOT}/EZFIO + mv -- ${QP_ROOT}/EZFIO.old ${QP_ROOT}/EZFIO echo "Failed to update EZFIO" fi diff --git a/scripts/upgrade/upgrade_irpf90.sh b/scripts/upgrade/upgrade_irpf90.sh index dea48014..7f48614d 100755 --- a/scripts/upgrade/upgrade_irpf90.sh +++ b/scripts/upgrade/upgrade_irpf90.sh @@ -3,23 +3,23 @@ # Upgrades IRPF90 from the web. # Wed Mar 25 11:41:04 CET 2015 -if [[ -z ${QPACKAGE_ROOT} ]] +if [[ -z ${QP_ROOT} ]] then - print "The QPACKAGE_ROOT environment variable is not set." + print "The QP_ROOT environment variable is not set." print "Please reload the quantum_package.rc file." fi -cd -- ${QPACKAGE_ROOT} -mv -f -- ${QPACKAGE_ROOT}/irpf90 ${QPACKAGE_ROOT}/irpf90.old +cd -- ${QP_ROOT} +mv -f -- ${QP_ROOT}/irpf90 ${QP_ROOT}/irpf90.old -${QPACKAGE_ROOT}/scripts/install/install_irpf90.sh +${QP_ROOT}/scripts/install/install_irpf90.sh if [[ $? -eq 0 ]] then - rm -rf -- ${QPACKAGE_ROOT}/irpf90.old + rm -rf -- ${QP_ROOT}/irpf90.old echo "Successfully updated IRPF90" else - rm -rf -- ${QPACKAGE_ROOT}/irpf90 - mv -- ${QPACKAGE_ROOT}/irpf90.old ${QPACKAGE_ROOT}/irpf90 + rm -rf -- ${QP_ROOT}/irpf90 + mv -- ${QP_ROOT}/irpf90.old ${QP_ROOT}/irpf90 echo "Failed to update IRPF90" fi diff --git a/setup_environment.py b/setup_environment.py new file mode 100755 index 00000000..cdf1b1ed --- /dev/null +++ b/setup_environment.py @@ -0,0 +1,383 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import subprocess +import os +import sys +import pprint + +from os.path import join + +# __ _ +# /__ | _ |_ _. | o ._ _|_ _ +# \_| |_ (_) |_) (_| | | | | | (_) +# + +QP_ROOT = os.getcwd() +QP_ROOT_BIN = join(QP_ROOT, "bin") +QP_ROOT_INSTALL = join(QP_ROOT, "install") + +d_dependancy = { + "ocaml": ["m4", "curl", "zlib", "patch", "gcc"], + "m4": ["make"], + "curl": ["make"], + "zlib": ["gcc", "make"], + "patch": ["make"], + "ezfio": ["irpf90"], + "irpf90": ["python"], + "docopt": ["python"], + "resultsFile": ["python"], + "emsl": ["python"], + "gcc": [], + "python": [], + "ninja": ["gcc", "python"], + "make": [] +} + +from collections import namedtuple + +Info = namedtuple("Info", ["url", "description", "default_path"]) + +path_github = {"head": "http://github.com/", "tail": "archive/master.tar.gz"} + +ocaml = Info( + url='http://raw.github.com/ocaml/opam/master/shell/opam_installer.sh', + description=' ocaml (it will take some time roughly 20min)', + default_path=join(QP_ROOT_BIN, "opam")) + +m4 = Info( + url="http://ftp.gnu.org/gnu/m4/m4-latest.tar.gz", + description=" m4", + default_path=join(QP_ROOT_BIN, "m4")) + +curl = Info( + url="http://qmcchem.ups-tlse.fr/files/scemama/curl-7.30.0.ermine.tar.bz2", + description=" curl", + default_path=join(QP_ROOT_BIN, "curl")) + +zlib = Info( + url='http://zlib.net/zlib-1.2.8.tar.gz', + description=' zlib', + default_path=join(QP_ROOT_INSTALL, "zlib")) + +path = Info( + url='ftp://ftp.gnu.org/gnu/patch/patch-2.7.5.tar.gz', + description=' path', + default_path=join(QP_ROOT_BIN, "patch")) + +irpf90 = Info( + url='{head}/scemama/irpf90/archive/v1.6.6.tar.gz'.format(**path_github), + description=' irpf90', + default_path=join(QP_ROOT_BIN, "irpf90")) + +docopt = Info( + url='{head}/docopt/docopt/{tail}'.format(**path_github), + description=' docop', + default_path=join(QP_ROOT_INSTALL, "docopt")) + +resultsFile = Info( + url='{head}/LCPQ/resultsFile/{tail}'.format(**path_github), + description=' resultsFile', + default_path=join(QP_ROOT_INSTALL, "resultsFile")) + +ninja = Info( + url='{head}/martine/ninja/{tail}'.format(**path_github), + description=' nina', + default_path=join(QP_ROOT_BIN, "ninja")) + +emsl = Info( + url='{head}/LCPQ/EMSL_Basis_Set_Exchange_Local/{tail}'.format(** + path_github), + description=' emsl', + default_path=join(QP_ROOT_INSTALL, "emsl")) + +ezfio = Info( + url='{head}/LCPQ/EZFIO/{tail}'.format(**path_github), + description=' EZFIO', + default_path=join(QP_ROOT_INSTALL, "EZFIO")) + +d_info = dict() + +for m in ["ocaml", "m4", "curl", "zlib", "path", "irpf90", "docopt", + "resultsFile", "ninja", "emsl", "ezfio"]: + exec ("d_info['{0}']={0}".format(m)) + +l_need = [] + + +# _ +# |_ ._ _ _|_ o _ ._ +# | |_| | | (_ |_ | (_) | | +# +def check_output(*popenargs, **kwargs): + """Run command with arguments and return its output as a byte string. + + Backported from Python 2.7 as it's implemented as pure python on stdlib. + + >>> check_output(['/usr/bin/python', '--version']) + Python 2.6.2 + """ + process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) + output, unused_err = process.communicate() + retcode = process.poll() + if retcode: + cmd = kwargs.get("args") + if cmd is None: + cmd = popenargs[0] + error = subprocess.CalledProcessError(retcode, cmd) + error.output = output + raise error + return output + + +def check_python(): + req_version = (2, 6) + cur_version = sys.version_info + + # Check python + if cur_version >= req_version: + l_installed["python"] = "" + else: + print "To old version (need >2.5). Abort" + sys.exit(1) + + +def check_avabiliy(binary): + + if binary == "python": + check_python() + + try: + return check_output(["which", binary]) + except subprocess.CalledProcessError: + default_path = d_info[binary].default_path + if os.path.exists(default_path): + return default_path + else: + return 0 + + +def splitext(path): + for ext in ['.tar.gz', '.tar.bz2']: + if path.endswith(ext): + return path[:-len(ext)], path[-len(ext):] + return os.path.splitext(path) + + +l_installed = dict() + +print """ + _ + / |_ _ _ | o ._ _ + \_ | | (/_ (_ |< | | | (_| + _| +""" + +# Check all the other +for i in d_dependancy.keys(): + print "Checking if you have {0} avalaible...".format(i), + + r = check_avabiliy(i) + if r: + print "OK" + l_installed[i] = r.strip() + else: + print "We will try to compile if from source in a few moment" + l_need.append(i) + +# Expend the need_stuff for all the genealogy + +d_need_genealogy = dict() + +for need in l_need: + d_need_genealogy[need] = None + for childen in d_dependancy[need]: + if childen not in l_installed: + d_need_genealogy[childen] = None + +l_need_genealogy = d_need_genealogy.keys() + +print """ + __ + (_ ._ _ ._ _ _. ._ + __) |_| | | | | | | (_| | \/ + / +""" + +print "You have already installed :" +def f( (a1,a2), (key,value) ): + return tuple(max(x,len(y)) for (x,y) in [(a1,key), (a2,value)] ) +fmt_tuple =reduce(f, l_installed.iteritems(), (0,0)) +for k,v in l_installed.iteritems(): + fmt = "{0:<%d} : {1:<%d}"%fmt_tuple + print fmt.format( k, v ) + +print """ + ___ + | ._ _ _|_ _. | | _. _|_ o _ ._ + _|_ | | _> |_ (_| | | (_| |_ | (_) | | + +""" + +if l_need_genealogy: + print "You need to install" + pprint.pprint(l_need_genealogy) +else: + print "Nothing to do" + sys.exit() + +if "ninja" in l_need_genealogy: + + print """ +# ~#~#~#~#~#~#~#~#~#~#~#~#~ # +# I n s t a l l _ n i n j a # +# ~#~#~#~#~#~#~#~#~#~#~#~#~ # +""" + url = d_info["ninja"].url + extension = splitext(url)[1] + path_archive = "Downloads/{0}{1}".format("ninja", extension) + + l_cmd = ["cd install &&", + "wget {0} -O {1} -o /dev/null &&".format(url, path_archive), + "./scripts/install_ninja.sh 2> /dev/null &&", "cd -"] + + check_output(" ".join(l_cmd), shell=True) + + print "Done" + l_need_genealogy.remove("ninja") + +print """ +# ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # +# C r e a t i n g _ n i n j a # +# ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # +""" + + +def create_rule(): + + l_rules = [ + "rule download", " command = wget ${url} -O ${out} -o /dev/null", + " description = Downloading ${descr}", "", "rule install", + " command = ./scripts/install_${target}.sh > _build/${target}.log 2>&1", + " description = Installing ${descr}", "" + ] + + return l_rules + +l_string = create_rule() + +l_build = [] + +for need in l_need_genealogy: + + if need == "ocaml": + continue + + url = d_info[need].url + extension = splitext(url)[1] + + archive_path = "Downloads/{0}{1}".format(need, extension) + + descr = d_info[need].description + + # Build to dowload + l_build += ["build {0}: download".format(archive_path), + " url = {0}".format(url), + " descr = {0}".format(descr), ""] + + # Build to install + l_dependancy = [d_info[i].default_path for i in d_dependancy[need] if i in l_need_genealogy] + + l_build += ["build {0}: install {1} {2}".format(d_info[need].default_path, + archive_path, + " ".join(l_dependancy)), + " target = {0}".format(need), + " descr = {0}".format(descr), ""] + +l_string += l_build + +path = join(QP_ROOT_INSTALL, "build.ninja") +with open(path, "w+") as f: + f.write("\n".join(l_string)) + +print "Done" +print "You can check at {0}".format(path) + +print """ +# ~#~#~#~#~#~#~#~#~ # +# R u n _ n i n j a # +# ~#~#~#~#~#~#~#~#~ # +""" + +if [i for i in l_need_genealogy if i not in "ocaml"]: + subprocess.check_call("./bin/ninja -C install", shell=True) + +print "Done" + +if "ocaml" in l_need_genealogy: + + print """ +# ~#~#~#~#~#~#~#~#~#~#~#~#~ # +# I n s t a l l _ o c a m l # +# ~#~#~#~#~#~#~#~#~#~#~#~#~ # +""" + url = d_info["ocaml"].url + extension = splitext(url)[1] + path_archive = "Downloads/{0}{1}".format("ocaml", extension) + + l_cmd = ["cd install &&", + "wget {0} -O {1} -o /dev/null &&".format(url, path_archive), + "./scripts/install_ocaml.sh --fast"] + + os.system(" ".join(l_cmd)) + + print "Done" + l_need_genealogy.remove("ocaml") + + +print """ +# ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # +# C r e a t e q u a n t u m _ p a c k a g e . r c +# ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # +""" + +python_path = [join(QP_ROOT, "scripts"), join(QP_ROOT, "install")] + +l_python = [join(QP_ROOT, "scripts")] +for dir_ in python_path: + for folder in os.listdir(dir_): + path = join(dir_, folder) + if os.path.isdir(path): + l_python.append(path) + + +def find_path(bin_): + try: + locate = l_installed[bin_] + except KeyError: + locate = d_info[bin_].default_path + return locate + + +l_rc = [ + 'export QP_ROOT={0}'.format(QP_ROOT), + 'export QP_EZFIO={0}'.format(find_path('ezfio')), + 'export IRPF90={0}'.format(find_path("irpf90")), + 'export NINJA={0}'.format(find_path("ninja")), + 'export QP_PYTHON={0}'.format(":".join(l_python)), + "", + 'export PYTHONPATH="${PYTHONPATH}":"${QP_PYTHON}"', + 'export PATH="${PATH}":"${QP_PYTHON}":"${QP_ROOT}"/bin:"${QP_ROOT}"/ocaml', + 'export LD_LIBRARY_PATH="${QP_ROOT}"/lib:"${LD_LIBRARY_PATH}"', + 'export LIBRARY_PATH="${QP_ROOT}"/lib:"${LIBRARY_PATH}"', "" + 'source ${HOME}/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true', + "" +] + +path = join(QP_ROOT, "quantum_package.rc") +with open(path, "w+") as f: + f.write("\n".join(l_rc)) + +print "Done" +print "You can check at {0}".format(path) +print "Don't forget to source it" diff --git a/setup_environment.sh b/setup_environment.sh deleted file mode 100755 index 0eb5e20d..00000000 --- a/setup_environment.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -# -# Setup script. Downloads dependencies if they are not already present -# in the current installation. -# Thu Oct 23 22:02:08 CEST 2014 - -BLUE="" -RED="" -BLACK="(B" - -QPACKAGE_ROOT="$( cd "$(dirname "$BASH_SOURCE")" ; pwd -P )" - - -cat << EOF > quantum_package.rc -export QPACKAGE_ROOT=\$( cd \$(dirname "\${BASH_SOURCE}") ; pwd -P ) -export IRPF90="\${QPACKAGE_ROOT}/bin/irpf90" -export LD_LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LD_LIBRARY_PATH} -export LIBRARY_PATH="\${QPACKAGE_ROOT}"/lib:\${LIBRARY_PATH} -export C_INCLUDE_PATH="\${QPACKAGE_ROOT}"/include:\${C_INCLUDE_PATH} - -export PYTHONPATH=\${PYTHONPATH}\$(find "\${QPACKAGE_ROOT}"/scripts -type d -printf ":%p") - -export PATH=\${PATH}\$(find "\${QPACKAGE_ROOT}"/scripts -type d -printf ":%p") -export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/bin -export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/ocaml -export PATH=\${PATH}:"\${QPACKAGE_ROOT}"/ninja -source "\${QPACKAGE_ROOT}"/bin/irpman &> /dev/null -EOF - - -source quantum_package.rc -mkdir -p install_logs -echo "${BLUE}===== Installing IRPF90 ===== ${BLACK}" -${QPACKAGE_ROOT}/scripts/install/install_irpf90.sh | tee ${QPACKAGE_ROOT}/install_logs/install_irpf90.log -if [[ ! -d ${QPACKAGE_ROOT}/irpf90 ]] || [[ ! -x ${QPACKAGE_ROOT}/bin/irpf90 ]] || [[ ! -x ${QPACKAGE_ROOT}/bin/irpman ]] -then - echo $RED "Error in IRPF90 installation" $BLACK - exit 1 -fi - -mkdir -p ${QPACKAGE_ROOT}/install_logs - -echo "${BLUE}===== Installing Ninja ===== ${BLACK}" -${QPACKAGE_ROOT}/scripts/install/install_ninja.sh | tee ${QPACKAGE_ROOT}/install_logs/install_ninja.log - -echo "${BLUE}===== Installing Zlib ===== ${BLACK}" -${QPACKAGE_ROOT}/scripts/install/install_zlib.sh | tee ${QPACKAGE_ROOT}/install_logs/install_zlib.log - -echo "${BLUE}===== Installing Curl ===== ${BLACK}" -${QPACKAGE_ROOT}/scripts/install/install_curl.sh | tee ${QPACKAGE_ROOT}/install_logs/install_curl.log - -echo "${BLUE}===== Installing M4 ===== ${BLACK}" -${QPACKAGE_ROOT}/scripts/install/install_m4.sh | tee ${QPACKAGE_ROOT}/install_logs/install_m4.log - -echo "${BLUE}===== Installing Docopt ===== ${BLACK}" -${QPACKAGE_ROOT}/scripts/install/install_docopt.sh | tee ${QPACKAGE_ROOT}/install_logs/install_docopt.log - -echo "${BLUE}===== Installing EMSL Basis set library ===== ${BLACK}" -${QPACKAGE_ROOT}/scripts/install/install_emsl.sh | tee ${QPACKAGE_ROOT}/install_logs/install_emsl.log - -if [[ ! -d ${QPACKAGE_ROOT}/EMSL_Basis ]] -then - echo $RED "Error in EMSL Basis set library installation" $BLACK - exit 1 -fi - -echo "${BLUE}===== Installing EZFIO ===== ${BLACK}" - -${QPACKAGE_ROOT}/scripts/install/install_ezfio.sh | tee ${QPACKAGE_ROOT}/install_logs/install_ezfio.log -if [[ ! -d ${QPACKAGE_ROOT}/EZFIO ]] -then - echo $RED "Error in EZFIO installation" $BLACK - exit 1 -fi - - -echo "${BLUE}===== Installing Ocaml compiler and libraries ===== ${BLACK}" -rm -f -- ocaml/Qptypes.ml -${QPACKAGE_ROOT}/scripts/install/install_ocaml.sh | tee ${QPACKAGE_ROOT}/install_logs/install_ocaml.log - -if [[ ! -f ${QPACKAGE_ROOT}/ocaml/Qptypes.ml ]] -then - echo $RED "Error in Ocaml installation" $BLACK - exit 1 -fi - -echo "${BLUE}===== Installing resultsFile Python library ===== ${BLACK}" -${QPACKAGE_ROOT}/scripts/install/install_resultsFile.sh -if [[ ! -d ${QPACKAGE_ROOT}/resultsFile ]] -then - echo $RED "Error in resultsFile installation" $BLACK - exit 1 -fi - - -echo $RED " -======================================================= -To complete the installation, add the following line to -your ~/.bashrc: - -source ${QPACKAGE_ROOT}/quantum_package.rc - -======================================================= -" $BLACK - - - - -if [[ $1 == "--robot" ]] ; -then - exit 0 -else - source quantum_package.rc - exec bash -fi - diff --git a/src/Ezfio_files/output.irp.f b/src/Ezfio_files/output.irp.f index 1a45e865..ac693caf 100644 --- a/src/Ezfio_files/output.irp.f +++ b/src/Ezfio_files/output.irp.f @@ -10,7 +10,7 @@ END_PROVIDER BEGIN_SHELL [ /bin/bash ] - for NAME in $(\ls -d ${QPACKAGE_ROOT}/src/*/) + for NAME in $(\ls -d ${QP_ROOT}/src/*/) do NAME=$(basename ${NAME}) cat << EOF diff --git a/src/MOs/utils.irp.f b/src/MOs/utils.irp.f index 21d04c27..38357c5d 100644 --- a/src/MOs/utils.irp.f +++ b/src/MOs/utils.irp.f @@ -3,7 +3,7 @@ subroutine save_mos double precision, allocatable :: buffer(:,:) integer :: i,j - call system('$QPACKAGE_ROOT/scripts/save_current_mos.sh '//trim(ezfio_filename)) + call system('$QP_ROOT/scripts/save_current_mos.sh '//trim(ezfio_filename)) call ezfio_set_mo_basis_mo_tot_num(mo_tot_num) call ezfio_set_mo_basis_mo_label(mo_label) diff --git a/src/Perturbation/perturbation.irp.f b/src/Perturbation/perturbation.irp.f index 57dd5ffa..208deab5 100644 --- a/src/Perturbation/perturbation.irp.f +++ b/src/Perturbation/perturbation.irp.f @@ -2,7 +2,7 @@ BEGIN_SHELL [ /usr/bin/env python ] from perturbation import perturbations import os -filename = os.environ["QPACKAGE_ROOT"]+"/src/Perturbation/perturbation.template.f" +filename = os.environ["QP_ROOT"]+"/src/Perturbation/perturbation.template.f" file = open(filename,'r') template = file.read() file.close() diff --git a/src/README.rst b/src/README.rst index f74a56f9..7d7560ea 100644 --- a/src/README.rst +++ b/src/README.rst @@ -31,7 +31,7 @@ Creating a new module ===================== Every new module should be created using the interactive ``create_module.sh`` -script located in the ``${QPACKAGE_ROOT}/scripts`` directory. This will create +script located in the ``${QP_ROOT}/scripts`` directory. This will create all the required files with correct templates. @@ -88,7 +88,7 @@ HTML, man, etc. Creating a shell script ======================= -Shell scripts should be located in the ``${QPACKAGE_ROOT}/scripts`` directory. +Shell scripts should be located in the ``${QP_ROOT}/scripts`` directory. Relative paths should be avoided as much as possible, and the result of commands should be always checked. For example, when creating a directory the existence of the directory has to be checked. diff --git a/testing_no_regression/unit_test.py b/testing_no_regression/unit_test.py index 6fc13696..968c9759 100755 --- a/testing_no_regression/unit_test.py +++ b/testing_no_regression/unit_test.py @@ -5,9 +5,9 @@ import subprocess import os import sys -qpackage_root = os.environ['QPACKAGE_ROOT'] +qpackage_root = os.environ['QP_ROOT'] -EZFIO = "{0}/EZFIO".format(qpackage_root) +EZFIO = "{0}/install/EZFIO".format(qpackage_root) sys.path = [EZFIO + "/Python"] + sys.path from ezfio import ezfio