From 47788a23416cb71ab4360bc75cfbf64cb365f47e Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 9 Jun 2015 15:05:06 +0200 Subject: [PATCH 01/12] Remove useless updrage_programe --- scripts/upgrade/upgrade_ezfio.sh | 26 -------------------------- scripts/upgrade/upgrade_irpf90.sh | 25 ------------------------- setup_environment.py | 2 +- 3 files changed, 1 insertion(+), 52 deletions(-) delete mode 100755 scripts/upgrade/upgrade_ezfio.sh delete mode 100755 scripts/upgrade/upgrade_irpf90.sh diff --git a/scripts/upgrade/upgrade_ezfio.sh b/scripts/upgrade/upgrade_ezfio.sh deleted file mode 100755 index 71ee990a..00000000 --- a/scripts/upgrade/upgrade_ezfio.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# Upgrades the EZFIO library from the web. -# Tue Nov 4 00:53:13 CET 2014 - -if [[ -z ${QP_ROOT} ]] -then - print "The QP_ROOT environment variable is not set." - print "Please reload the quantum_package.rc file." -fi - -cd -- ${QP_ROOT} -mv -- ${QP_ROOT}/EZFIO ${QP_ROOT}/EZFIO.old - -${QP_ROOT}/scripts/install/install_ezfio.sh - -if [[ $? -eq 0 ]] -then - rm -rf -- ${QP_ROOT}/EZFIO.old - echo "Successfully updated EZFIO" -else - 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 deleted file mode 100755 index 7f48614d..00000000 --- a/scripts/upgrade/upgrade_irpf90.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -# -# Upgrades IRPF90 from the web. -# Wed Mar 25 11:41:04 CET 2015 - -if [[ -z ${QP_ROOT} ]] -then - print "The QP_ROOT environment variable is not set." - print "Please reload the quantum_package.rc file." -fi - -cd -- ${QP_ROOT} -mv -f -- ${QP_ROOT}/irpf90 ${QP_ROOT}/irpf90.old - -${QP_ROOT}/scripts/install/install_irpf90.sh - -if [[ $? -eq 0 ]] -then - rm -rf -- ${QP_ROOT}/irpf90.old - echo "Successfully updated IRPF90" -else - 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 index cdf1b1ed..426d9003 100755 --- a/setup_environment.py +++ b/setup_environment.py @@ -63,7 +63,7 @@ zlib = Info( path = Info( url='ftp://ftp.gnu.org/gnu/patch/patch-2.7.5.tar.gz', description=' path', - default_path=join(QP_ROOT_BIN, "patch")) + default_path=join(QP_ROOT, "lib", "libz.a")) irpf90 = Info( url='{head}/scemama/irpf90/archive/v1.6.6.tar.gz'.format(**path_github), From 4e707c1362b7e638335871a945354d2eae78706a Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 9 Jun 2015 15:08:06 +0200 Subject: [PATCH 02/12] Type in module_handler.py --- scripts/module/module_handler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/module/module_handler.py b/scripts/module/module_handler.py index e8d58889..7ae8e07f 100755 --- a/scripts/module/module_handler.py +++ b/scripts/module/module_handler.py @@ -52,9 +52,9 @@ def get_dict_child(): return d_ref -def l_module_generalogy_rec(d_chidlren, l_module): +def l_module_generalogy_rec(d_child, l_module): """ - From a list of module return the module and all of the genealogy + From a list of module return the module and descendant """ l = [] @@ -62,7 +62,7 @@ def l_module_generalogy_rec(d_chidlren, l_module): if module not in l: l.append(module) try: - l.extend(l_module_generalogy_rec(d_chidlren, d_chidlren[module])) + l.extend(l_module_generalogy_rec(d_child, d_child[module])) except KeyError: print >> sys.stderr, "`{0}` not submodule".format(module) print >> sys.stderr, "Check the corresponding NEEDED_CHILDREN_MODULES" From af342920867f33008e8f0e478e560b276c1ee7b7 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 9 Jun 2015 16:06:01 +0200 Subject: [PATCH 03/12] module_handler is now a module object not a class --- scripts/compilation/qp_create_ninja.py | 5 ++- scripts/module/module_handler.py | 55 ++++++++++++++------------ scripts/module/qp_install_module.py | 9 +++-- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index 620c5f1b..47eb11bc 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -39,6 +39,7 @@ EZ_config_path = namedtuple('EZ_config', ['path_in_module', 'path_in_ezfio']) EZ_handler = namedtuple('EZ_handler', ['ez_module', 'ez_cfg', 'ez_interface', 'ez_config']) Sym_link = namedtuple('Sym_link', ['source', 'destination']) +module_instance = ModuleHandler() # _ @@ -511,7 +512,7 @@ def get_dict_binaries(l_module, mode="production"): if mode == "production": - dict_root = ModuleHandler.dict_root + dict_root = module_instance.dict_root dict_root_path = dict_module_genelogy_path(dict_root) d_binaries_condensed = defaultdict(list) @@ -656,7 +657,7 @@ if __name__ == "__main__": # G e n e a l o g y _ d i c t # # ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # - d_genealogy = ModuleHandler.dict_descendant + d_genealogy = module_instance.dict_descendant d_genealogy_path = dict_module_genelogy_path(d_genealogy) d_irp = get_file_dependency(d_genealogy_path) diff --git a/scripts/module/module_handler.py b/scripts/module/module_handler.py index 7ae8e07f..25a7d10e 100755 --- a/scripts/module/module_handler.py +++ b/scripts/module/module_handler.py @@ -29,14 +29,15 @@ except ImportError: # Canot cache for namedtuple are not hashable -def get_dict_child(): +def get_dict_child(dir_=None): """Loop over MODULE in QP_ROOT/src, open all the NEEDED_CHILDREN_MODULES and create a dict[MODULE] = [sub module needed, ...] """ d_ref = dict() - qp_root = os.environ['QP_ROOT'] - dir_ = os.path.join(qp_root, 'src') + if not dir_: + qp_root = os.environ['QP_ROOT'] + dir_ = os.path.join(qp_root, 'src') for o in os.listdir(dir_): @@ -47,12 +48,17 @@ def get_dict_child(): except IOError: pass else: - d_ref[o] = l_children + if o not in d_ref: + d_ref[o] = l_children + else: + print "Module {0} alredy defined" + print "Abort" + sys.exit(1) return d_ref -def l_module_generalogy_rec(d_child, l_module): +def l_module_descendant(d_child, l_module): """ From a list of module return the module and descendant """ @@ -62,7 +68,7 @@ def l_module_generalogy_rec(d_child, l_module): if module not in l: l.append(module) try: - l.extend(l_module_generalogy_rec(d_child, d_child[module])) + l.extend(l_module_descendant(d_child, d_child[module])) except KeyError: print >> sys.stderr, "`{0}` not submodule".format(module) print >> sys.stderr, "Check the corresponding NEEDED_CHILDREN_MODULES" @@ -71,15 +77,16 @@ def l_module_generalogy_rec(d_child, l_module): return list(set(l)) -class ModuleHandler: +class ModuleHandler(): - dict_child = get_dict_child() + def __init__(self, dict_child=get_dict_child()): + self.dict_child = dict_child - @classproperty + @property def l_module(self): return self.dict_child.keys() - @classproperty + @property def dict_parent(self): """ Get a dic of the first parent @@ -93,7 +100,7 @@ class ModuleHandler: return d - @classproperty + @property def dict_descendant(self): """ Get a dic of all the genealogy desc (children and all_children) @@ -103,12 +110,12 @@ class ModuleHandler: d_child = self.dict_child for module_name in d_child: - d[module_name] = l_module_generalogy_rec(d_child, - d_child[module_name]) + d[module_name] = l_module_descendant(d_child, + d_child[module_name]) return d - @classproperty + @property def dict_root(self): """ Return a dict(module_name) = module_boss @@ -126,9 +133,8 @@ class ModuleHandler: return dict_root - @classmethod - def l_descendant_unique(cls, l_module): - d_desc = cls.dict_descendant + def l_descendant_unique(self, l_module): + d_desc = self.dict_descendant d = {} for module in l_module: @@ -137,10 +143,9 @@ class ModuleHandler: return d.keys() - @classmethod - def l_reduce_tree(cls, l_module): + def l_reduce_tree(self, l_module): """For a list of module in input return only the root""" - l_d_u = cls.l_descendant_unique(l_module) + l_d_u = self.l_descendant_unique(l_module) l_module_reduce = [] for module in l_module: if module not in l_d_u: @@ -148,8 +153,7 @@ class ModuleHandler: return l_module_reduce - @classmethod - def create_png(cls, l_module): + def create_png(self, l_module): """Create the png of the dependency tree for a l_module""" # Init @@ -170,7 +174,7 @@ class ModuleHandler: # Init graph = pydot.Dot(graph_type='digraph') - d_ref = cls.dict_child + d_ref = self.dict_child # Create all the edge for module in l_module: @@ -196,9 +200,10 @@ if __name__ == '__main__': dir_ = os.path.dirname(path_file) path_file = os.path.basename(dir_) + m = ModuleHandler() if arguments['print_descendant']: - print " ".join(sorted(ModuleHandler.l_module)) + print " ".join(sorted(m.l_module)) if arguments["create_png"]: - ModuleHandler.create_png([path_file]) + m.create_png([path_file]) diff --git a/scripts/module/qp_install_module.py b/scripts/module/qp_install_module.py index 2c5dd4fe..8c7af219 100755 --- a/scripts/module/qp_install_module.py +++ b/scripts/module/qp_install_module.py @@ -53,9 +53,10 @@ def save_new_module(path, l_child): if __name__ == '__main__': arguments = docopt(__doc__) + m_instance = ModuleHandler() if arguments["list"]: - for module in ModuleHandler.l_module: + for module in m_instance.l_module: print module elif arguments["create"]: @@ -68,7 +69,7 @@ if __name__ == '__main__': print path for children in l_children: - if children not in ModuleHandler.dict_descendant: + if children not in m_instance.dict_descendant: print "This module ({0}) is not a valide module.".format(children) print "Run `list` flag for the list of module avalaible" print "Aborting..." @@ -78,9 +79,9 @@ if __name__ == '__main__': print l_children print "You can use all the routine in this module" - print l_children + ModuleHandler.l_descendant_unique(l_children) + print l_children + m_instance.l_descendant_unique(l_children) print "This can be reduce to:" - l_child_reduce = ModuleHandler.l_reduce_tree(l_children) + l_child_reduce = m_instance.l_reduce_tree(l_children) print l_child_reduce save_new_module(path, l_child_reduce) From 8c5c1069e0634dd5028650bf9f0f45c24c63e871 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 9 Jun 2015 16:34:52 +0200 Subject: [PATCH 04/12] No we can set the root for the dict of dependancy --- scripts/module/module_handler.py | 41 ++++++++++++++++------------- scripts/module/qp_install_module.py | 4 +-- scripts/utility/decorator.py | 9 ------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/scripts/module/module_handler.py b/scripts/module/module_handler.py index 25a7d10e..0a6ef2e2 100755 --- a/scripts/module/module_handler.py +++ b/scripts/module/module_handler.py @@ -19,41 +19,44 @@ Options: import os import sys import os.path +from collections import namedtuple try: from docopt import docopt - from decorator import classproperty except ImportError: print "source .quantum_package.rc" raise # Canot cache for namedtuple are not hashable -def get_dict_child(dir_=None): +def get_dict_child(l_root_abs=None): """Loop over MODULE in QP_ROOT/src, open all the NEEDED_CHILDREN_MODULES and create a dict[MODULE] = [sub module needed, ...] """ d_ref = dict() - if not dir_: + if not l_root_abs: qp_root = os.environ['QP_ROOT'] - dir_ = os.path.join(qp_root, 'src') + l_root_abs = [os.path.join(qp_root, 'src')] - for o in os.listdir(dir_): + for root_abs in l_root_abs: + for module_rel in os.listdir(root_abs): - try: - path_file = os.path.join(dir_, o, "NEEDED_CHILDREN_MODULES") - with open(path_file, "r") as f: - l_children = f.read().split() - except IOError: - pass - else: - if o not in d_ref: - d_ref[o] = l_children + module_abs = os.path.join(root_abs, module_rel) + try: + path_file = os.path.join(module_abs, "NEEDED_CHILDREN_MODULES") + + with open(path_file, "r") as f: + l_children = f.read().split() + except IOError: + pass else: - print "Module {0} alredy defined" - print "Abort" - sys.exit(1) + if module_rel not in d_ref: + d_ref[module_rel] = l_children + else: + print "Module {0} alredy defined" + print "Abort" + sys.exit(1) return d_ref @@ -79,8 +82,8 @@ def l_module_descendant(d_child, l_module): class ModuleHandler(): - def __init__(self, dict_child=get_dict_child()): - self.dict_child = dict_child + def __init__(self, l_root_abs=None): + self.dict_child = get_dict_child(l_root_abs) @property def l_module(self): diff --git a/scripts/module/qp_install_module.py b/scripts/module/qp_install_module.py index 8c7af219..31262e48 100755 --- a/scripts/module/qp_install_module.py +++ b/scripts/module/qp_install_module.py @@ -14,7 +14,7 @@ import os try: from docopt import docopt - from module_handler import ModuleHandler + from module_handler import ModuleHandler, get_dict_child from update_README import Doc_key, Needed_key except ImportError: print "source .quantum_package.rc" @@ -53,8 +53,8 @@ def save_new_module(path, l_child): if __name__ == '__main__': arguments = docopt(__doc__) - m_instance = ModuleHandler() + m_instance = ModuleHandler() if arguments["list"]: for module in m_instance.l_module: print module diff --git a/scripts/utility/decorator.py b/scripts/utility/decorator.py index 66b9e064..9be4ea2c 100644 --- a/scripts/utility/decorator.py +++ b/scripts/utility/decorator.py @@ -15,12 +15,3 @@ def cache(func): saved[args] = result return result return newfunc - - -class classproperty(object): - - def __init__(self, fget): - self.fget = fget - - def __get__(self, owner_self, owner_cls): - return self.fget(owner_cls) From e11998adcf39294d1f37f2125dad6ff889cf5cbe Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 9 Jun 2015 19:20:18 +0200 Subject: [PATCH 05/12] It will be not that hard to implement module repositories --- scripts/module/module_handler.py | 8 ++--- scripts/module/qp_install_module.py | 55 ++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/scripts/module/module_handler.py b/scripts/module/module_handler.py index 0a6ef2e2..5bd8310e 100755 --- a/scripts/module/module_handler.py +++ b/scripts/module/module_handler.py @@ -61,7 +61,7 @@ def get_dict_child(l_root_abs=None): return d_ref -def l_module_descendant(d_child, l_module): +def get_l_module_descendant(d_child, l_module): """ From a list of module return the module and descendant """ @@ -71,7 +71,7 @@ def l_module_descendant(d_child, l_module): if module not in l: l.append(module) try: - l.extend(l_module_descendant(d_child, d_child[module])) + l.extend(get_l_module_descendant(d_child, d_child[module])) except KeyError: print >> sys.stderr, "`{0}` not submodule".format(module) print >> sys.stderr, "Check the corresponding NEEDED_CHILDREN_MODULES" @@ -113,8 +113,8 @@ class ModuleHandler(): d_child = self.dict_child for module_name in d_child: - d[module_name] = l_module_descendant(d_child, - d_child[module_name]) + d[module_name] = get_l_module_descendant(d_child, + d_child[module_name]) return d diff --git a/scripts/module/qp_install_module.py b/scripts/module/qp_install_module.py index 31262e48..03dbd350 100755 --- a/scripts/module/qp_install_module.py +++ b/scripts/module/qp_install_module.py @@ -1,12 +1,15 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ -Usage: qp_install_module.py list +Usage: qp_install_module.py list [--installed|--avalaible-local|--avalaible-remote] + qp_install_module.py install -n qp_install_module.py create -n [...] + qp_install_module.py download -n [...] + Options: list: List all the module avalaible - create: Create a new module + create: Create a new module """ import sys @@ -15,6 +18,7 @@ import os try: from docopt import docopt from module_handler import ModuleHandler, get_dict_child + from module_handler import get_l_module_descendant from update_README import Doc_key, Needed_key except ImportError: print "source .quantum_package.rc" @@ -53,17 +57,26 @@ def save_new_module(path, l_child): if __name__ == '__main__': arguments = docopt(__doc__) + qp_root_src = os.path.join(os.environ['QP_ROOT'], "src") + qp_root_plugin = os.path.join(os.environ['QP_ROOT'], "plugins") - m_instance = ModuleHandler() if arguments["list"]: + + if arguments["--installed"]: + l_repository = [qp_root_src] + + m_instance = ModuleHandler(l_repository) + for module in m_instance.l_module: print module elif arguments["create"]: + m_instance = ModuleHandler(l_repository) + l_children = arguments[""] - qpackage_root = os.environ['QP_ROOT'] - path = os.path.join(qpackage_root, "src", arguments[""]) + qp_root = os.environ['QP_ROOT'] + path = os.path.join(qp_root_src, arguments[""]) print "You will create the module:" print path @@ -85,3 +98,35 @@ if __name__ == '__main__': l_child_reduce = m_instance.l_reduce_tree(l_children) print l_child_reduce save_new_module(path, l_child_reduce) + + elif arguments["download"]: + + d_local = get_dict_child([qp_root_src]) + d_remote = get_dict_child(arguments[""]) + + d_child = d_local.copy() + d_child.update(d_remote) + + name = arguments[""] + l_module_descendant = get_l_module_descendant(d_child, [name]) + + for module in l_module_descendant: + if module not in d_local: + print "you need to install", module + + elif arguments["install"]: + + d_local = get_dict_child([qp_root_src]) + + d_plugin = get_dict_child([qp_root_plugin]) + + d_child = d_local.copy() + d_child.update(d_plugin) + + name = arguments[""] + l_module_descendant = get_l_module_descendant(d_child, [name]) + + module_to_cp = [module for module in l_module_descendant if module not in d_local] + + print "For ln -s by hand the module" + print module_to_cp From 3480ba8b19de47541a66644f82fa5e3c77524b8e Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 10 Jun 2015 10:51:29 +0200 Subject: [PATCH 06/12] Beter ninja --- scripts/compilation/qp_create_ninja.py | 43 +++++++++++++++++--------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index 47eb11bc..e0af6587 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -499,6 +499,9 @@ def get_dict_binaries(l_module, mode="production"): Example : The module Full_CI can produce the binary SCF so you dont need to compile at all the module Hartree-Fock + + But you need to change the path acordingle + Full_CI/Hartree-Fock/SCF """ d_binaries = defaultdict(list) @@ -513,11 +516,21 @@ def get_dict_binaries(l_module, mode="production"): if mode == "production": dict_root = module_instance.dict_root - dict_root_path = dict_module_genelogy_path(dict_root) + dict_root_module_path = dict_module_genelogy_path(dict_root) d_binaries_condensed = defaultdict(list) + for module in d_binaries: - d_binaries_condensed[dict_root_path[module]] += d_binaries[module] + + root_module = dict_root_module_path[module] + + if module == root_module: + d_binaries_condensed[root_module] += d_binaries[module] + else: + #We need to put the root module in the d_binarie path. + + new_path = [Path(join(QP_ROOT_SRC,root_module.rel,module.rel,i.rel),i.rel) for i in d_binaries[module]] + d_binaries_condensed[root_module] += new_path d_binaries = d_binaries_condensed @@ -533,7 +546,7 @@ def ninja_binaries_rule(): # c m d # # ~#~#~ # - l_cmd = ["cd $module", "ninja"] + l_cmd = ["cd $module", "ninja $out"] # ~#~#~#~#~#~ # # s t r i n g # @@ -663,20 +676,25 @@ if __name__ == "__main__": l_module = d_genealogy_path.keys() - d_binaries_production = get_dict_binaries(l_module, - mode="production") - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # # M o d u l e _ t o _ i r p # # ~#~#~#~#~#~#~#~#~#~#~#~#~ # if arguments["--production"]: - l_module_to_irp = d_binaries_production.keys() + + d_binaries = get_dict_binaries(l_module, + mode="production") + + l_module = d_binaries.keys() elif arguments["--development"]: - l_module_to_irp = d_genealogy_path.keys() - for module_to_compile in l_module_to_irp: + d_binaries = get_dict_binaries(l_module, + mode="development") + + l_module = d_binaries.keys() + + for module_to_compile in l_module: # ~#~#~#~#~#~#~#~ # # S y m l i n k # @@ -698,13 +716,8 @@ if __name__ == "__main__": l_string += ninja_dot_tree_build(module_to_compile) l_string += ninja_readme_build(module_to_compile) - # ~#~#~#~#~#~#~ # - # b i n a r y # - # ~#~#~#~#~#~#~ # - for module_to_compile in d_binaries_production.keys(): - l_string += ninja_binaries_build(module_to_compile, l_children, - d_binaries_production) + d_binaries) with open(join(QP_ROOT, "build.ninja"), "w+") as f: f.write("\n".join(l_string)) From b29219aa697bbf3769632d15d01cafad1ca5c99e Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 10 Jun 2015 13:44:26 +0200 Subject: [PATCH 07/12] Fix typo --- scripts/compilation/qp_create_ninja.py | 60 +++++++++++++++----------- setup_environment.py | 37 +++++++++------- 2 files changed, 56 insertions(+), 41 deletions(-) diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index 387ecd28..d2b5a37d 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -80,8 +80,7 @@ def dict_module_genelogy_path(d_module_genelogy): p = Path(module_abs, module_rel) try: - d[p] = Path(join(QP_ROOT_SRC, l_children_rel), - l_children_rel) + d[p] = Path(join(QP_ROOT_SRC, l_children_rel), l_children_rel) except: d[p] = [Path(join(QP_ROOT_SRC, children), children) for children in l_children_rel] @@ -223,9 +222,9 @@ def ninja_ezfio_rule(): l_flag = ["export {0}='${0}'".format(flag) for flag in ["FC", "FCFLAGS", "IRPF90"]] - 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)] + install_lib_ezfio = join(QP_ROOT, 'install', 'EZFIO', "lib", "libezfio.a") + l_cmd = ["cd {0}".format(QP_ROOT_EZFIO)] + l_flag + l_cmd += ["ninja && ln -f {0} {1}".format(install_lib_ezfio, EZFIO_LIB)] l_string = ["rule build_ezfio", " command = {0}".format(" ; ".join(l_cmd)), @@ -313,17 +312,19 @@ def get_l_file_for_module(path_module): elif f.endswith(".irp.f"): l_depend.append(join(path_module.abs, f)) elif f.lower().endswith(tuple([".f", ".f90", ".c", ".cpp", ".cxx"])): - l_depend.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(obj) elif f == "EZFIO.cfg": l_depend.append(join(path_module.abs, "ezfio_interface.irp.f")) - d = {"l_depend": l_depend, - "l_src": l_src, - "l_obj": l_obj, - "l_template": l_template} + d = { + "l_depend": l_depend, + "l_src": l_src, + "l_obj": l_obj, + "l_template": l_template + } return d @@ -338,18 +339,20 @@ def get_file_dependency(d_info_module): 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] + 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] + 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).iteritems(): if key in ["l_src"]: - values = [join(module.abs,children.rel,o) for o in values] + 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] + values = [join(module.abs, "IRPF90_temp", children.rel, o) + for o in values] d_irp[module][key].extend(values) @@ -527,10 +530,16 @@ def get_dict_binaries(l_module, mode="production"): if module == root_module: d_binaries_condensed[root_module] += d_binaries[module] else: - #We need to put the root module in the d_binarie path. - new_path = [Path(join(QP_ROOT_SRC,root_module.rel,module.rel,i.rel),i.rel) for i in d_binaries[module]] - d_binaries_condensed[root_module] += new_path + l_binaries = [] + for binaries in d_binaries[module]: + p_abs = join(QP_ROOT_SRC, root_module.rel, module.rel, + binaries.rel) + p_rel = binaries.rel + p = Path(p_abs, p_rel) + l_binaries.append(p) + + d_binaries_condensed[root_module] += l_binaries d_binaries = d_binaries_condensed @@ -597,11 +606,12 @@ def ninja_dot_tree_rule(): l_cmd = ["cd $module", "module_handler.py create_png"] - l_string = ["rule build_dot_tree", - " command = {0}".format(" ; ".join(l_cmd)), - " generator = 1", - " description = Generate Png representtion of the Tree Dependancies of $module", - ""] + l_string = [ + "rule build_dot_tree", " command = {0}".format(" ; ".join(l_cmd)), + " generator = 1", + " description = Generate Png representtion of the Tree Dependancies of $module", + "" + ] return l_string @@ -682,15 +692,13 @@ if __name__ == "__main__": if arguments["--production"]: - d_binaries = get_dict_binaries(l_module, - mode="production") + d_binaries = get_dict_binaries(l_module, mode="production") l_module = d_binaries.keys() elif arguments["--development"]: - d_binaries = get_dict_binaries(l_module, - mode="development") + d_binaries = get_dict_binaries(l_module, mode="development") l_module = d_binaries.keys() diff --git a/setup_environment.py b/setup_environment.py index 3ba00f36..de34b676 100755 --- a/setup_environment.py +++ b/setup_environment.py @@ -66,7 +66,7 @@ path = Info( default_path=join(QP_ROOT, "lib", "libz.a")) irpf90 = Info( - url='{head}/scemama/irpf90/archive/v1.6.6.tar.gz'.format(**path_github), + url='{head}/LCPQ/irpf90/{tail}'.format(**path_github), description=' irpf90', default_path=join(QP_ROOT_BIN, "irpf90")) @@ -190,6 +190,13 @@ def create_rule_ninja(): def finalize(): + + print """ + ___ _ + | ._ _|_ _ ._ ._ _ _. _|_ o _ ._ + _|_ | | | (_) | | | | (_| |_ | (_) | | + +""" path = join(QP_ROOT, "quantum_package.rc") print "For more info on compiling the code, read the COMPILE_RUN.md file." print "" @@ -239,7 +246,7 @@ for i in d_dependency.keys(): print "[ OK ]" l_installed[i] = r.strip() else: - print "[ will compile it ]" + print "[ Will compile it ]" l_need.append(i) print """ @@ -280,17 +287,17 @@ l_install_without_ninja = [] for need in l_install_descendant: if need == "ocaml": - l_install_with_ninja.append(need) - else: l_install_without_ninja.append(need) + else: + l_install_with_ninja.append(need) if need_to_install_ninja: print """ -# ~#~#~#~#~#~#~#~#~#~#~#~#~ # -# I n s t a l l _ n i n j a # -# ~#~#~#~#~#~#~#~#~#~#~#~#~ # -""" + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + # I n s t a l l _ n i n j a # + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + """ url = d_info["ninja"].url extension = splitext(url)[1] @@ -363,10 +370,10 @@ if l_install_with_ninja: if "ocaml" in l_install_without_ninja: print """ -# ~#~#~#~#~#~#~#~#~#~#~#~#~ # -# I n s t a l l _ o c a m l # -# ~#~#~#~#~#~#~#~#~#~#~#~#~ # -""" + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + # I n s t a l l _ o c a m l # + # ~#~#~#~#~#~#~#~#~#~#~#~#~ # + """ url = d_info["ocaml"].url extension = splitext(url)[1] @@ -382,9 +389,9 @@ if "ocaml" in l_install_without_ninja: l_install_descendant.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 -# ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~ # + _. _. ._ _|_ ._ _ ._ _. _ | _. _ _ ._ _ + (_| |_| (_| | | |_ |_| | | | |_) (_| (_ |< (_| (_| (/_ o | (_ + | __ | _| """ python_path = [join(QP_ROOT, "scripts"), join(QP_ROOT, "install")] From c63f2117cf6852571d9ccf2951f21bb383a5a3dc Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 10 Jun 2015 15:46:04 +0200 Subject: [PATCH 08/12] We can ninja in a module now --- .travis.yml | 2 +- scripts/compilation/qp_create_ninja.py | 76 ++++++++++++++++++++++++-- src/Determinants/README.rst | 4 +- 3 files changed, 75 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 26024bec..2d204aad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ before_script: script: - ./setup_environment.py - source ./quantum_package.rc - - qp_create_ninja.py --production ./config/gfortran.cfg + - qp_create_ninja.py create --production ./config/gfortran.cfg - ninja - cd ocaml ; make ; cd - - cd testing_no_regression ; ./unit_test.py diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index d2b5a37d..e780939c 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -1,7 +1,9 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ -Usage: qp_create_ninja.py (--development | --production) CONFIG_FILE +Usage: qp_create_ninja.py create (--development | --production) CONFIG_FILE + qp_create_ninja.py update + """ import os @@ -10,6 +12,7 @@ import glob from os.path import join from collections import namedtuple from collections import defaultdict +import pickle try: from module_handler import ModuleHandler @@ -378,7 +381,8 @@ def ninja_irpf90_make_rule(): # c m d # # ~#~#~ # - l_cmd = ["cd $module"] + l_flag + ["irpf90 $include_dir $IRPF90_FLAGS"] + l_cmd = ["cd $module", "rm -rf IRPF90_temp IRPF90_man" + ] + l_flag + ["irpf90 $include_dir $IRPF90_FLAGS"] # ~#~#~#~#~#~ # # s t r i n g # @@ -555,7 +559,7 @@ def ninja_binaries_rule(): # c m d # # ~#~#~ # - l_cmd = ["cd $module", "ninja -C IRPF90_temp $out"] + l_cmd = ["cd $module/IRPF90_temp", "ninja $out"] # ~#~#~#~#~#~ # # s t r i n g # @@ -589,6 +593,22 @@ def ninja_binaries_build(path_module, l_children, d_binaries): ninja_module_path), " module = {0}".format(path_module.abs), ""] + l_string += ["build module_{0}: phony {1}".format(path_module.rel, + " ".join(l_abs_bin)), ""] + + return l_string + + +# +# |\/| _ _| | _ +# | | (_) (_| |_| | (/_ +# +def create_module_ninja(): + """ + In a module create a build.ninja + """ + + l_string = ["rule all:"] return l_string @@ -624,13 +644,58 @@ def ninja_dot_tree_build(path_module): return l_string +# +# |\/| _ _| | _ +# | | (_) (_| |_| | (/_ +# + + +def create_ninja_module(path_module): + path_ninja_root = join(QP_ROOT, "build.ninja") + + l_string = [ + "rule update_ninja_common", " command = qp_create_ninja.py update", + "", "rule make_local_binaries", + " command = ninja -f {0} module_{1}".format(path_ninja_root, + path_module.rel), "" + ] + + l_string += ["rule make_all_binaries", + " command = ninja -f {0}".format(path_ninja_root), ""] + + l_string += ["build dumy_target: update_ninja_common", "", + "build all: make_all_binaries dumy_target", "", + "build local: make_local_binaries dumy_target", + "default local", ""] + + path_ninja_cur = join(path_module.abs, "build.ninja") + with open(path_ninja_cur, "w") as f: + f.write("\n".join(l_string)) + # # |\/| _. o ._ # | | (_| | | | # if __name__ == "__main__": - arguments = docopt(__doc__) + + pickle_path = os.path.join(QP_ROOT, "config", "qp_create_ninja.pickle") + + if arguments["update"]: + try: + with open(pickle_path, 'rb') as handle: + arguments = pickle.load(handle) + except IOError: + print "You need to create first my friend" + sys.exit(1) + + elif arguments["create"]: + + arguments["CONFIG_FILE"] = os.path.realpath(arguments["CONFIG_FILE"]) + + with open(pickle_path, 'wb') as handle: + pickle.dump(arguments, handle) + pwd_config_file = arguments["CONFIG_FILE"] # _ @@ -704,6 +769,9 @@ if __name__ == "__main__": for module_to_compile in l_module: + if arguments["--development"]: + create_ninja_module(module_to_compile) + # ~#~#~#~#~#~#~#~ # # S y m l i n k # # ~#~#~#~#~#~#~#~ # diff --git a/src/Determinants/README.rst b/src/Determinants/README.rst index 34392b7a..f0497d7f 100644 --- a/src/Determinants/README.rst +++ b/src/Determinants/README.rst @@ -589,7 +589,7 @@ Documentation If true, The One body DM is calculated with ignoring the Double<->Doubles extra diag elements -`pouet `_ +`pouet `_ Undocumented @@ -783,7 +783,7 @@ Documentation be set before calling this function. -`routine `_ +`routine `_ Undocumented From fbed320e83835b58f52a71c5d979178f54ed4920 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Wed, 10 Jun 2015 18:16:29 +0200 Subject: [PATCH 09/12] Working ninja --- COMPILE_RUN.md | 11 ++++------ scripts/compilation/qp_create_ninja.py | 28 ++++++++++++-------------- src/Hartree_Fock/EZFIO.cfg | 5 +++++ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/COMPILE_RUN.md b/COMPILE_RUN.md index 4f97e72e..9b4263e7 100644 --- a/COMPILE_RUN.md +++ b/COMPILE_RUN.md @@ -12,7 +12,8 @@ The script to create the dependency file (aka `build.ninja`) is * If you only want the binaries (for production workflow) use the flag `--production` in when calling this script. It's quicker * Else if you are a developer and you want to be able to compile specific - modules use: `--development` + modules use: `--development`. It will create for you the `build.ninja` in each + module ## Compilation Flags @@ -23,12 +24,7 @@ used. You can edit these files to modify the compiling options. ## Example to create the Ninja file -`qp_create_ninja.py --production $QP_ROOT/config/ifort.cfg` - -# WARNING - -For now you need to execute this command if you add a `irp.f` or `EZFIO.cfg` -file or modify the `NEED_CHILDREN_MODULE`! +`qp_create_ninja.py create --production $QP_ROOT/config/ifort.cfg` ## Compiling @@ -37,5 +33,6 @@ 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 module directory and run `ninja` to build only this module. +You can type `ninja all` in a module for compiling all the submodule Finally, go in `$QP_ROOT/ocaml` and type `make` diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index e780939c..a7ccbb47 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -247,11 +247,7 @@ def ninja_ezfio_build(l_ezfio_config, l_util): l_ezfio_from_cfg = [i.ez_config.abs for i in l_util.itervalues()] str_ = " ".join(l_ezfio_config + l_ezfio_from_cfg) - - ezfio_make_config = join(QP_ROOT_EZFIO, "make.config") - l_string = ["build {0} {1}: build_ezfio {2}".format(EZFIO_LIB, - ezfio_make_config, - str_), ""] + l_string = ["build {0}: build_ezfio {1}".format(EZFIO_LIB, str_), ""] return l_string @@ -381,8 +377,7 @@ def ninja_irpf90_make_rule(): # c m d # # ~#~#~ # - l_cmd = ["cd $module", "rm -rf IRPF90_temp IRPF90_man" - ] + l_flag + ["irpf90 $include_dir $IRPF90_FLAGS"] + l_cmd = ["cd $module"] + l_flag + ["irpf90 $include_dir $IRPF90_FLAGS"] # ~#~#~#~#~#~ # # s t r i n g # @@ -559,7 +554,7 @@ def ninja_binaries_rule(): # c m d # # ~#~#~ # - l_cmd = ["cd $module/IRPF90_temp", "ninja $out"] + l_cmd = ["cd $module/IRPF90_temp", "ninja $out && touch $out"] # ~#~#~#~#~#~ # # s t r i n g # @@ -653,15 +648,18 @@ def ninja_dot_tree_build(path_module): def create_ninja_module(path_module): path_ninja_root = join(QP_ROOT, "build.ninja") - l_string = [ - "rule update_ninja_common", " command = qp_create_ninja.py update", - "", "rule make_local_binaries", - " command = ninja -f {0} module_{1}".format(path_ninja_root, - path_module.rel), "" - ] + l_string = ["rule update_ninja_common", + " command = qp_create_ninja.py update", ""] + + l_string += ["rule make_local_binaries", + " command = ninja -j 1 -f {0} module_{1}".format( + path_ninja_root, path_module.rel), + " description = Compile only {0}".format(path_module.rel), + ""] l_string += ["rule make_all_binaries", - " command = ninja -f {0}".format(path_ninja_root), ""] + " command = ninja -j 1 -f {0}".format(path_ninja_root), + " description = Compile all the module", ""] l_string += ["build dumy_target: update_ninja_common", "", "build all: make_all_binaries dumy_target", "", diff --git a/src/Hartree_Fock/EZFIO.cfg b/src/Hartree_Fock/EZFIO.cfg index e2b0ea5a..6410df46 100644 --- a/src/Hartree_Fock/EZFIO.cfg +++ b/src/Hartree_Fock/EZFIO.cfg @@ -20,3 +20,8 @@ default: Huckel type: double precision doc: Calculated HF energy interface: output + +[energy_sdfsdf] +type: double precision +doc: Calculated HF energy +interface: output From b99679041e6dfa60be42c10f169bccf3fa59bf29 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 11 Jun 2015 11:58:26 +0200 Subject: [PATCH 10/12] Cleaning compile.py --- configure.py | 475 +++++++++++++++++++++++++ scripts/compilation/qp_create_ninja.py | 126 +++++-- scripts/module/clean_modules.sh | 4 +- setup_environment.py | 424 ---------------------- 4 files changed, 569 insertions(+), 460 deletions(-) create mode 100755 configure.py delete mode 100755 setup_environment.py diff --git a/configure.py b/configure.py new file mode 100755 index 00000000..27d214e6 --- /dev/null +++ b/configure.py @@ -0,0 +1,475 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +"""configure + +Usage: configure (--production | --development) + +Options: + config_file A config file will all the information for the compilation + (Fortran Compiler, FLag, ...) + --production You cannot compile only one module with this flag. + but the compilation will be lighting fast + --development It will create a build.ninja for each directory + who containt a binary, than you can compile then + individualy if you want + +""" + +import subprocess +import os +import sys + +from os.path import join + +if not any(i in ["--production", "--development"] for i in sys.argv): + print __doc__ + sys.exit() +if len(sys.argv) != 3: + print __doc__ + sys.exit() + +# __ _ +# /__ | _ |_ _. | o ._ _|_ _ +# \_| |_ (_) |_) (_| | | | | | (_) +# + +QP_ROOT = os.getcwd() +QP_ROOT_BIN = join(QP_ROOT, "bin") +QP_ROOT_INSTALL = join(QP_ROOT, "install") + +d_dependency = { + "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, "lib", "libz.a")) + +irpf90 = Info( + url='{head}/LCPQ/irpf90/{tail}'.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)) + + +def find_path(bin_, l_installed): + """Use the global variable + * l_installed + * d_info + """ + + try: + locate = l_installed[bin_] + except KeyError: + locate = d_info[bin_].default_path + return locate + + +# _ +# |_ ._ _ _|_ 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 checking(d_dependency): + """ + For each key in d_dependency check if it + it avalabie or not + """ + + def check_python(): + req_version = (2, 6) + cur_version = sys.version_info + + # Check python + if cur_version >= req_version: + return 1 + else: + print "To old version (need >2.5). Abort" + sys.exit(1) + + def check_availabiliy(binary): + """ + If avalabie return the path who can can't find the + binary else return 0 + """ + + 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 get_list_descendant(d_dependency, l_installed, l_needed): + """ + Descendant – a node reachable by repeated proceeding from parent to child. + """ + d_need_genealogy = dict() + + for need in l_needed: + d_need_genealogy[need] = None + for childen in d_dependency[need]: + if childen not in l_installed: + d_need_genealogy[childen] = None + return d_need_genealogy.keys() + + return d_need_genealogy.keys() + print """ + _ +|_) _ o _ +| \ (/_ \/ | (/_ \/\/ + + """ + + print "Checking what you need to install and what is it avalaible" + print "" + l_installed = dict() + l_needed = [] + + # Check all the other + length = max(map(len, d_dependency)) + + for i in d_dependency.keys(): + print "Checking {0:>{1}}...".format(i, length), + + r = check_availabiliy(i) + if r: + print "[ OK ] ( {0} )".format(r.strip()) + l_installed[i] = r.strip() + else: + print "[ FAIL ]" + l_needed.append(i) + print "" + + # Expend the need_stuff for all the genealogy + l_install_descendant = get_list_descendant(d_dependency, l_installed, + l_needed) + + return l_installed, l_install_descendant + + +def installation(l_install_descendant): + """ + Installing all the list + 0 install ninja + 1 create ninja + 2 run ninja + """ + + def create_rule_ninja(): + + l_rules = [ + "rule download", " command = wget ${url} -O ${out} -o /dev/null", + " description = Downloading ${descr}", "" + ] + + l_rules += [ + "rule install", + " command = ./scripts/install_${target}.sh > _build/${target}.log 2>&1", + " description = Installing ${descr}", "" + ] + + l_rules += [ + "rule install_verbose", + " command = ./scripts/install_${target}.sh | tee _build/${target}.log 2>&1", + " description = Installing ${descr}", " pool = console", "" + ] + + return l_rules + + 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) + + print """ +___ + | ._ _ _|_ _. | | _. _|_ o _ ._ +_|_ | | _> |_ (_| | | (_| |_ | (_) | | + +""" + + d_print = { + "install_ninja": "Install ninja...", + "build": "Creating build.ninja...", + "install": "Installing the dependancy through ninja..." + } + + length = max(map(len, d_print.values())) + + def str_info(key): + return "{0:<{1}}".format(d_print[key], length) + + if "ninja" in l_install_descendant: + + print str_info("install_ninja"), + + 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 -"] + + try: + check_output(" ".join(l_cmd), shell=True) + except: + print "[ OK ]" + + l_install_descendant.remove("ninja") + + print str_info("build"), + l_string = create_rule_ninja() + + l_build = [] + + for need in l_install_descendant: + + url = d_info[need].url + extension = splitext(url)[1] + + archive_path = "Downloads/{0}{1}".format(need, extension) + + descr = d_info[need].description + default_path = d_info[need].default_path + + # 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_dependency[need] + if i in l_install_descendant] + str_dependancy = " ".join(l_dependancy) + + rule = "install" if need != "ocaml" else "install_verbose" + + l_build += ["build {0}: {1} {2} {3}".format(default_path, rule, + archive_path, + str_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 " [ OK ] ({0})".format(path) + + print str_info("install"), + print " [ Running ]" + try: + path_ninja = find_path("ninja", l_installed) + subprocess.check_call("cd install ;{0}".format(path_ninja), shell=True) + except: + raise + else: + print r""" + _________ +< Success > + --------- + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || + """ + + +def create_ninja_and_rc(l_installed): + print """ + _ +|_ o ._ _. | o _ _ +| | | | (_| | | /_ (/_ + +""" + + d_print = { + "qp_root": "Creating quantum_package.rc...", + "build": "Creating build.ninja..." + } + + length = max(map(len, d_print.values())) + + def str_info(key): + return "{0:<{1}}".format(d_print[key], length) + + print str_info("qp_root"), + 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) + + l_rc = [ + 'export QP_ROOT={0}'.format(QP_ROOT), + 'export QP_EZFIO={0}'.format(find_path('ezfio', l_installed)), + 'export IRPF90={0}'.format(find_path("irpf90", l_installed)), + 'export NINJA={0}'.format(find_path("ninja", l_installed)), + '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 "[ OK ] ({0})".format(path) + + print str_info("build"), + + command = ['bash', '-c', 'source {0} && env'.format(path)] + + proc = subprocess.Popen(command, stdout=subprocess.PIPE) + + for line in proc.stdout: + (key, _, value) = line.partition("=") + os.environ[key] = value.strip() + + qp_create_ninja = os.path.join(QP_ROOT, "scripts", "compilation", + "qp_create_ninja.py") + + l = [qp_create_ninja, "create"] + sys.argv[1:] + try: + subprocess.check_call(" ".join(l), shell=True) + except: + raise + else: + print "[ OK ]" + + +def recommendation(): + print "Last Step:" + path = join(QP_ROOT, "quantum_package.rc") + print "Now :" + print " source {0}".format(path) + print " ninja" + print " cd ocaml; make " + print "" + print "PS : For more info on compiling the code, read the COMPILE_RUN.md file." + + +if __name__ == '__main__': + + l_installed, l_install_descendant = checking(d_dependency) + + if l_install_descendant: + print "You will need to install:" + for i in l_install_descendant: + print "* {0}".format(i) + + installation(l_install_descendant) + else: + print "Perfect, nothing to install" + create_ninja_and_rc(l_installed) + + recommendation() diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index a7ccbb47..c565845e 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- """ -Usage: qp_create_ninja.py create (--development | --production) CONFIG_FILE +Usage: qp_create_ninja.py create (--development | --production) qp_create_ninja.py update """ @@ -22,6 +22,27 @@ except ImportError: print "source .quantum_package.rc" sys.exit(1) +header = r"""# +# _______ _____ +# __ __ \___ _______ _________ /____ ________ ___ +# _ / / / / / / __ `/_ __ \ __/ / / /_ __ `__ \ +# / /_/ // /_/ // /_/ /_ / / / /_ / /_/ /_ / / / / / +# \___\_\\__,_/ \__,_/ /_/ /_/\__/ \__,_/ /_/ /_/ /_/ +# +# ________ ______ +# ___ __ \_____ _________ /_______ _______ _____ +# __ /_/ / __ `/ ___/_ //_/ __ `/_ __ `/ _ \ +# _ ____// /_/ // /__ _ ,< / /_/ /_ /_/ // __/ +# /_/ \__,_/ \___/ /_/|_| \__,_/ _\__, / \___/ +# /____/ +# +# https://github.com/LCPQ/quantum_package, +# +# Generated automatically by {0}.".format(__file__) +# +# +""" + # __ # /__ | _ |_ _. | _. ._ o _. |_ | _ _ # \_| | (_) |_) (_| | \/ (_| | | (_| |_) | (/_ _> @@ -32,6 +53,7 @@ QP_ROOT_SRC = join(QP_ROOT, 'src') QP_ROOT_EZFIO = join(QP_ROOT, 'install', 'EZFIO') EZFIO_LIB = join(QP_ROOT, "lib", "libezfio.a") +ROOT_BUILD_NINJA = join(QP_ROOT, "config", "build.ninja") # # |\ | _. ._ _ _ _| _|_ ._ | _ @@ -231,8 +253,7 @@ def ninja_ezfio_rule(): l_string = ["rule build_ezfio", " command = {0}".format(" ; ".join(l_cmd)), - " description = Create $out" - ""] + " pool = console", " description = Create $out", ""] return l_string @@ -377,7 +398,7 @@ def ninja_irpf90_make_rule(): # c m d # # ~#~#~ # - l_cmd = ["cd $module"] + l_flag + ["irpf90 $include_dir $IRPF90_FLAGS"] + l_cmd = ["cd $module_abs"] + l_flag + ["irpf90 $include_dir $IRPF90_FLAGS"] # ~#~#~#~#~#~ # # s t r i n g # @@ -386,7 +407,7 @@ def ninja_irpf90_make_rule(): l_string = ["pool irp_pool", " depth = 1", "", "rule build_irpf90.ninja", " command = {0}".format(" ; ".join(l_cmd)), " pool = irp_pool", - " description = Create the IRP_Tree for $module", ""] + " description = Running IRPF90 for $module_rel", ""] return l_string @@ -429,7 +450,8 @@ def ninja_irpf90_make_build(path_module, l_needed_molule, d_irp): l_string = [ "build {0}: build_irpf90.ninja {1}".format(str_creation, str_depend), - " module = {0}".format(path_module.abs), + " module_abs = {0}".format(path_module.abs), + " module_rel = {0}".format(path_module.rel), " SRC = {0}".format(" ".join(l_src)), " OBJ = {0}".format(" ".join(l_obj)), " include_dir = {0}".format(" ".join(l_include_dir)), "" @@ -444,7 +466,7 @@ def ninja_readme_rule(): For not dealted the readme when ninja -t clean and the generator option """ l_string = ["rule build_readme", - " command = cd $module ; update_README.py", + " command = cd $module_abs ; update_README.py", " generator = 1", ""] return l_string @@ -459,7 +481,8 @@ def ninja_readme_build(path_module): l_string = ["build {0}: build_readme {1}".format(path_readme, path_irp_man), - " module = {0}".format(path_module.abs), ""] + " module_abs = {0}".format(path_module.abs), + " module_rel = {0}".format(path_module.rel), ""] return l_string @@ -554,7 +577,7 @@ def ninja_binaries_rule(): # c m d # # ~#~#~ # - l_cmd = ["cd $module/IRPF90_temp", "ninja $out && touch $out"] + l_cmd = ["cd $module_abs/IRPF90_temp", "ninja $out && touch $out"] # ~#~#~#~#~#~ # # s t r i n g # @@ -562,7 +585,9 @@ def ninja_binaries_rule(): l_string = ["rule build_binaries", " command = {0}".format(" ; ".join(l_cmd)), - " description = Create all the binaries from $module", ""] + " pool = console", + " description = Create all the binaries from $module_rel", + ""] return l_string @@ -586,7 +611,8 @@ def ninja_binaries_build(path_module, l_children, d_binaries): l_string = ["build {0}: build_binaries {1} {2}".format(" ".join(l_abs_bin), EZFIO_LIB, ninja_module_path), - " module = {0}".format(path_module.abs), ""] + " module_abs = {0}".format(path_module.abs), + " module_rel = {0}".format(path_module.rel), ""] l_string += ["build module_{0}: phony {1}".format(path_module.rel, " ".join(l_abs_bin)), ""] @@ -619,12 +645,12 @@ def ninja_dot_tree_rule(): # c m d # # ~#~#~ # - l_cmd = ["cd $module", "module_handler.py create_png"] + l_cmd = ["cd $module_abs", "module_handler.py create_png"] l_string = [ "rule build_dot_tree", " command = {0}".format(" ; ".join(l_cmd)), " generator = 1", - " description = Generate Png representtion of the Tree Dependancies of $module", + " description = Generate Png representtion of the Tree Dependencies of $module_rel", "" ] @@ -635,39 +661,73 @@ def ninja_dot_tree_build(path_module): path_tree = join(path_module.abs, "tree_dependency.png") l_string = ["build {0}: build_dot_tree".format(path_tree), - " module = {0}".format(path_module.abs), ""] + " module_abs = {0}".format(path_module.abs), + " module_rel = {0}".format(path_module.rel), ""] return l_string + # # |\/| _ _| | _ # | | (_) (_| |_| | (/_ # +def create_build_ninja_module(path_module): - -def create_ninja_module(path_module): - path_ninja_root = join(QP_ROOT, "build.ninja") - - l_string = ["rule update_ninja_common", + l_string = ["rule update_build_ninja_root", " command = qp_create_ninja.py update", ""] l_string += ["rule make_local_binaries", - " command = ninja -j 1 -f {0} module_{1}".format( - path_ninja_root, path_module.rel), + " command = ninja -f {0} module_{1}".format( + ROOT_BUILD_NINJA, path_module.rel), " pool = console", " description = Compile only {0}".format(path_module.rel), ""] l_string += ["rule make_all_binaries", - " command = ninja -j 1 -f {0}".format(path_ninja_root), - " description = Compile all the module", ""] + " command = ninja -f {0}".format(ROOT_BUILD_NINJA), + " pool = console", " description = Compile all the module", + ""] - l_string += ["build dumy_target: update_ninja_common", "", - "build all: make_all_binaries dumy_target", "", - "build local: make_local_binaries dumy_target", - "default local", ""] + l_string += ["rule make_clean", " command = clean_modules.sh", + " description = Cleaning module {0}".format(path_module.rel), + ""] + + l_string += ["build dummy_target: update_build_ninja_root", "", + "build all: make_all_binaries dummy_target", "", + "build local: make_local_binaries dummy_target", + "default local", "", "build clean: make_clean dummy_target", + ""] path_ninja_cur = join(path_module.abs, "build.ninja") with open(path_ninja_cur, "w") as f: + f.write(header) + f.write("\n".join(l_string)) + + +def create_build_ninja_global(): + + l_string = ["rule update_build_ninja_root", + " command = qp_create_ninja.py update", ""] + + l_string += ["rule make_all_binaries", + " command = ninja -f {0}".format(ROOT_BUILD_NINJA), + " pool = console", " description = Compile all the module", + ""] + + l_string += ["rule make_clean", + " command = cd {0} ; clean_modules.sh *".format(QP_ROOT_SRC), + " description = Cleaning all modules", ""] + + l_string += ["build dummy_target: update_build_ninja_root", + "", + "build all: make_all_binaries dummy_target", + "default all", + "", + "build clean: make_clean", + "", ] + + path_ninja_cur = join(QP_ROOT, "build.ninja") + with open(path_ninja_cur, "w") as f: + f.write(header) f.write("\n".join(l_string)) # @@ -689,12 +749,12 @@ if __name__ == "__main__": elif arguments["create"]: - arguments["CONFIG_FILE"] = os.path.realpath(arguments["CONFIG_FILE"]) + arguments[""] = os.path.realpath(arguments[""]) with open(pickle_path, 'wb') as handle: pickle.dump(arguments, handle) - pwd_config_file = arguments["CONFIG_FILE"] + pwd_config_file = arguments[""] # _ # |_ ._ _. ._ o _. |_ | _ _ @@ -756,19 +816,18 @@ if __name__ == "__main__": if arguments["--production"]: d_binaries = get_dict_binaries(l_module, mode="production") - l_module = d_binaries.keys() elif arguments["--development"]: d_binaries = get_dict_binaries(l_module, mode="development") - l_module = d_binaries.keys() + create_build_ninja_global() for module_to_compile in l_module: if arguments["--development"]: - create_ninja_module(module_to_compile) + create_build_ninja_module(module_to_compile) # ~#~#~#~#~#~#~#~ # # S y m l i n k # @@ -793,5 +852,6 @@ if __name__ == "__main__": l_string += ninja_binaries_build(module_to_compile, l_children, d_binaries) - with open(join(QP_ROOT, "build.ninja"), "w+") as f: + with open(join(QP_ROOT, "config", "build.ninja"), "w+") as f: + f.write(header) f.write("\n".join(l_string)) diff --git a/scripts/module/clean_modules.sh b/scripts/module/clean_modules.sh index c4ec9dc4..4eae11c4 100755 --- a/scripts/module/clean_modules.sh +++ b/scripts/module/clean_modules.sh @@ -13,11 +13,9 @@ source ${QP_ROOT}/scripts/qp_include.sh function do_clean() { rm -rf -- \ - IRPF90_temp IRPF90_man Makefile.depend \ + IRPF90_temp IRPF90_man \ $(module_handler.py print_descendant) include \ ezfio_interface.irp.f irpf90.make irpf90_entities tags $(ls_exe) *.mod - - touch -c EZFIO.cfg *.ezfio_config } if [[ -z $1 ]] diff --git a/setup_environment.py b/setup_environment.py deleted file mode 100755 index de34b676..00000000 --- a/setup_environment.py +++ /dev/null @@ -1,424 +0,0 @@ -#!/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_dependency = { - "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, "lib", "libz.a")) - -irpf90 = Info( - url='{head}/LCPQ/irpf90/{tail}'.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_availabiliy(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) - - -def find_path(bin_): - """Use the global variable - * l_installed - * d_info - """ - - try: - locate = l_installed[bin_] - except KeyError: - locate = d_info[bin_].default_path - return locate - - -def create_rule_ninja(): - - 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 - - -def finalize(): - - print """ - ___ _ - | ._ _|_ _ ._ ._ _ _. _|_ o _ ._ - _|_ | | | (_) | | | | (_| |_ | (_) | | - -""" - path = join(QP_ROOT, "quantum_package.rc") - print "For more info on compiling the code, read the COMPILE_RUN.md file." - print "" - print "You can check {0} and run:".format(path) - print "" - print " source {0}".format(path) - print " qp_create_ninja.py --production $QP_ROOT/config/ifort.cfg" - print " ninja" - print " make -C ocaml" - print "" - sys.exit() - - -def get_list_need_child(l_need): - """ - Descendant – a node reachable by repeated proceeding from parent to child. - """ - d_need_genealogy = dict() - - for need in l_need: - d_need_genealogy[need] = None - for childen in d_dependency[need]: - if childen not in l_installed: - d_need_genealogy[childen] = None - return d_need_genealogy.keys() - - return d_need_genealogy.keys() - - -print """ - _ - / |_ _ _ | o ._ _ - \_ | | (/_ (_ |< | | | (_| - _| -""" - -l_installed = dict() - -# Check all the other -length = max(map(len, d_dependency)) - -for i in d_dependency.keys(): - print "Checking if {0:^{1}} is avalaible...".format(i, length), - - r = check_availabiliy(i) - if r: - print "[ OK ]" - l_installed[i] = r.strip() - else: - print "[ Will compile it ]" - l_need.append(i) - -print """ - __ - (_ ._ _ ._ _ _. ._ - __) |_| | | | | | | (_| | \/ - / -""" - -print "You have already installed :" - -len_bin, len_path = [max(map(len, line)) - for line in zip(*l_installed.iteritems())] - -for bin, path in l_installed.iteritems(): - print "{0:<{2}} : {1:<{3}}".format(bin, path, len_bin, len_path) - -# Expend the need_stuff for all the genealogy -l_install_descendant = get_list_need_child(l_need) - -print """ - ___ - | ._ _ _|_ _. | | _. _|_ o _ ._ - _|_ | | _> |_ (_| | | (_| |_ | (_) | | - -""" - -if l_install_descendant: - print "You need to install:" - pprint.pprint(l_install_descendant) -else: - print "Nothing to do." - finalize() - -need_to_install_ninja = "ninja" in l_install_descendant -l_install_with_ninja = [] -l_install_without_ninja = [] - -for need in l_install_descendant: - if need == "ocaml": - l_install_without_ninja.append(need) - else: - l_install_with_ninja.append(need) - -if need_to_install_ninja: - - 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_install_with_ninja.remove("ninja") - -if l_install_with_ninja: - print """ - # ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # - # C r e a t i n g _ n i n j a # - # ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # - """ - - l_string = create_rule_ninja() - - l_build = [] - - for need in l_install_with_ninja: - - 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_dependency[need] - if i in l_install_descendant] - - 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 {0}".format(path) - - print """ - # ~#~#~#~#~#~#~#~#~ # - # R u n _ n i n j a # - # ~#~#~#~#~#~#~#~#~ # - """ - - if [i for i in l_install_descendant if i not in "ocaml"]: - subprocess.check_call("{0} -C install".format(find_path("ninja")), - shell=True) - - print "Done" - -if "ocaml" in l_install_without_ninja: - - 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"] - - os.system(" ".join(l_cmd)) - - print "Done" - l_install_descendant.remove("ocaml") - -print """ - _. _. ._ _|_ ._ _ ._ _. _ | _. _ _ ._ _ - (_| |_| (_| | | |_ |_| | | | |_) (_| (_ |< (_| (_| (/_ o | (_ - | __ | _| -""" - -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) - -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." -finalize() From d196c14f146e46ad0ee659e25a7dee8a75f2d0bb Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 11 Jun 2015 15:51:03 +0200 Subject: [PATCH 11/12] Maj travis --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2d204aad..43eee06c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,8 @@ before_script: - sudo apt-get install graphviz script: - - ./setup_environment.py + - ./configure.py --production ./config/gfortran.cfg - source ./quantum_package.rc - - qp_create_ninja.py create --production ./config/gfortran.cfg - ninja - cd ocaml ; make ; cd - - cd testing_no_regression ; ./unit_test.py From 723566193b02eaf82ba26aaae6b42e275ff356d7 Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Thu, 11 Jun 2015 16:03:05 +0200 Subject: [PATCH 12/12] Creating ninja global everytime --- configure.py | 2 ++ scripts/compilation/qp_create_ninja.py | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.py b/configure.py index 27d214e6..76410b1a 100755 --- a/configure.py +++ b/configure.py @@ -312,6 +312,8 @@ _|_ | | _> |_ (_| | | (_| |_ | (_) | | try: check_output(" ".join(l_cmd), shell=True) except: + raise + else: print "[ OK ]" l_install_descendant.remove("ninja") diff --git a/scripts/compilation/qp_create_ninja.py b/scripts/compilation/qp_create_ninja.py index c565845e..05cc4be3 100755 --- a/scripts/compilation/qp_create_ninja.py +++ b/scripts/compilation/qp_create_ninja.py @@ -822,7 +822,8 @@ if __name__ == "__main__": d_binaries = get_dict_binaries(l_module, mode="development") l_module = d_binaries.keys() - create_build_ninja_global() + + create_build_ninja_global() for module_to_compile in l_module: