diff --git a/scripts/ezfio_interface/ei_handler.py b/scripts/ezfio_interface/ei_handler.py index 6e832aa8..8b28f41f 100755 --- a/scripts/ezfio_interface/ei_handler.py +++ b/scripts/ezfio_interface/ei_handler.py @@ -5,13 +5,14 @@ Welcom the ei_handler. We will create all the ezfio related stuff from a EZFIO.cfg file. Usage: - ei_handler.py [--path] [--irpf90] [--ezfio_config] [--ocaml] [--ezfio_default] [--global] + ei_handler.py [--recursif] [--irpf90] [--ezfio_config] [--ocaml] [--ezfio_default] + ei_handler.py ocaml_global By default all the option are executed. Options: -h --help - --path The path of the `EZFIO.cfg`, by default will look in the ${pwd} + --recursif Folow the dependancy of the module --irpf90 Create the `ezfio_interface.irpf90` which contains all the providers needed (aka all with the `interface: input` parameter) @@ -23,7 +24,7 @@ Options: --ezfio_default Create the `${module_lower}_ezfio_interface_default` in `${QPACKAGE_ROOT}/data/ezfio_defaults` needed by the ocaml - --global Create all the stuff who need all the EZFIO.cfg + ocaml_global Create the qp_edit Format specification : [provider_name] | the name of the provider in irp.f90 @@ -62,9 +63,12 @@ import ConfigParser from collections import defaultdict from collections import namedtuple - from cache import cache + +from os import listdir +from os.path import isdir, join, exists, islink + Type = namedtuple('Type', 'fancy ocaml fortran') @@ -632,9 +636,6 @@ def get_l_module_lower(): # L _ f o l d e r # # ~#~#~#~#~#~#~#~ # - from os import listdir - from os.path import isdir, join, exists - l_folder = [f for f in listdir(mypath) if isdir(join(mypath, f))] # ~#~#~#~#~#~#~#~#~#~#~#~#~#~ # @@ -738,42 +739,10 @@ def save_ocaml_qp_edit(str_ocaml_qp_edit): f.write(str_ocaml_qp_edit) -if __name__ == "__main__": - arguments = docopt(__doc__) - # ___ - # | ._ o _|_ - # _|_ | | | |_ - # +def code_generation(arguments, dict_ezfio_cfg, m): - if not arguments["--global"]: - if not arguments["--path"]: - config_file_path = "EZFIO.cfg" - if "EZFIO.cfg" not in os.listdir(os.getcwd()): - sys.exit(0) - else: - config_file_path = arguments["path"] - - # Get the full path - config_file_path = os.path.expanduser(config_file_path) - config_file_path = os.path.expandvars(config_file_path) - config_file_path = os.path.abspath(config_file_path) - - # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # - # G e t _ m o d u l e _ d i r # - # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # - - path_dirname = os.path.dirname(config_file_path) - module = [i for i in path_dirname.split("/") if i][-1] - module_lower = module.lower() - - # Because we only authorise this right now! - ezfio_dir = module_lower - dict_ezfio_cfg = get_dict_config_file(config_file_path, ezfio_dir) - - # _ - # / _ _| _ _ _ ._ _ ._ _. _|_ o _ ._ - # \_ (_) (_| (/_ (_| (/_ | | (/_ | (_| |_ | (_) | | - # _| + module_lower = m.lower + path_dirname = m.path.replace("/EZFIO.cfg", "") # ~#~#~#~#~#~#~#~#~#~ # # W h a t _ t o _ d o # @@ -822,11 +791,61 @@ if __name__ == "__main__": str_ezfio_default = create_ezfio_default(dict_ezfio_cfg) save_ezfio_default(module_lower, str_ezfio_default) - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - # e z f i o _ d e f a u l t # - # ~#~#~#~#~#~#~#~#~#~#~#~#~ # - if do_all: +if __name__ == "__main__": + arguments = docopt(__doc__) + # ___ + # | ._ o _|_ + # _|_ | | | |_ + # + + if arguments["ocaml_global"]: str_ocaml_qp_edit, str_ocaml_input_auto = create_ocaml_input_global() save_ocaml_input_auto(str_ocaml_input_auto) save_ocaml_qp_edit(str_ocaml_qp_edit) + sys.exit(0) + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # G e t _ m o d u l e _ d i r # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + + path_dirname = os.getcwd() + root_module = [i for i in path_dirname.split("/") if i][-1] + + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + # G e t _ l _ d i c t _ e z f i o _ c f g # + # ~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~#~# # + + if arguments["--recursif"]: + def true_link(f): + return islink(join(path_dirname, f)) + + l_symlink = [f for f in listdir(path_dirname) if true_link(f)] + else: + l_symlink = [] + + l_module = [root_module] + l_symlink + + def check_ezfio(f): + return exists() + + qpackage_root_src = join(os.environ['QPACKAGE_ROOT'], "src") + + l_module_with_ezfio = [] + + Module = namedtuple('Module', 'path lower') + + for f in l_module: + path = join(qpackage_root_src, f, "EZFIO.cfg") + if exists(path): + l_module_with_ezfio.append(Module(path, f.lower())) + + l_dict_ezfio_cfg = [(get_dict_config_file(m.path, m.lower), m) for m in l_module_with_ezfio] + + # _ + # / _ _| _ _ _ ._ _ ._ _. _|_ o _ ._ + # \_ (_) (_| (/_ (_| (/_ | | (/_ | (_| |_ | (_) | | + # _| + + for (dict_ezfio_cfg, m) in l_dict_ezfio_cfg: + code_generation(arguments, dict_ezfio_cfg, m) diff --git a/scripts/ezfio_interface/prepare_ezfio.sh b/scripts/ezfio_interface/prepare_ezfio.sh index 96ba3cdc..7c4b6c2f 100755 --- a/scripts/ezfio_interface/prepare_ezfio.sh +++ b/scripts/ezfio_interface/prepare_ezfio.sh @@ -9,7 +9,7 @@ echo "=-=-=-=-=-=-=-=-=-=-=-" for dir in ${QPACKAGE_ROOT}/src/*/ do cd $dir || exit -1 - ${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py + ${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py --ezfio_config --ezfio_default done # For old-style directories. Will be removed some day... diff --git a/scripts/module/build_modules.sh b/scripts/module/build_modules.sh index 92238b99..86909f7e 100755 --- a/scripts/module/build_modules.sh +++ b/scripts/module/build_modules.sh @@ -18,15 +18,6 @@ do cd ${MODULE} echo ${MODULE} - # Update Makefile.depend - ${QPACKAGE_ROOT}/scripts/module/check_module.sh - - # Update EZFIO interface (create the irp.f90 and the ocaml) - ${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py --irpf90 --ocaml - - # Create symlink - ${QPACKAGE_ROOT}/scripts/module/module_handler.py create_symlick - if [[ $# -eq 1 ]] then env make -j ${NPROC} all @@ -40,14 +31,6 @@ Build failed for module $MODULE " fi fi - # Create gitignore - ${QPACKAGE_ROOT}/scripts/module/create_gitignore.sh - - # Create png - ${QPACKAGE_ROOT}/scripts/module/module_handler.py create_png - - # Create png - ${QPACKAGE_ROOT}/scripts/module/update_README.py cd ${OLDPWD} done diff --git a/scripts/module/module_handler.py b/scripts/module/module_handler.py index 60b4b82b..fa02d407 100755 --- a/scripts/module/module_handler.py +++ b/scripts/module/module_handler.py @@ -9,7 +9,7 @@ of a NEEDED_CHILDREN_MODULES file Usage: module_handler.py print_genealogy [] module_handler.py save_makefile_depend - module_handler.py create_symlick [] + module_handler.py create_symlink [] module_handler.py create_png [] Options: @@ -249,7 +249,7 @@ if __name__ == '__main__': get_list_depend(l_all_needed_molule) - if arguments['create_symlick']: + if arguments['create_symlink']: src = os.getcwd() for link_name in module_genealogy(path) + ["include"]: diff --git a/scripts/module/update_README.py b/scripts/module/update_README.py index 0bec525e..34e9ddf1 100755 --- a/scripts/module/update_README.py +++ b/scripts/module/update_README.py @@ -17,7 +17,7 @@ import subprocess header = """ .. Do not edit this section. It was auto-generated from the -.. NEEDED_MODULES file. +.. update_README.py. """ @@ -74,7 +74,7 @@ def update_assumptions(data): def update_needed(data): - """Read the NEEDED_MODULES file, and replace the data with it. + """Read the NEEDED_CHILDREN_MODULES file, and replace the data with it. Create the links to the GitHub pages.""" file = open('NEEDED_CHILDREN_MODULES', 'r') diff --git a/scripts/qp_include.sh b/scripts/qp_include.sh index 9303fe50..9146215f 100644 --- a/scripts/qp_include.sh +++ b/scripts/qp_include.sh @@ -24,11 +24,16 @@ function check_current_dir_is_src() function check_current_dir_is_module() { - if [[ "$(dirname $PWD)" == "${QPACKAGE_ROOT}/src" ]] + # 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 [[ "${PWD##${QPACKAGE_ROOT}/src/}" != "$PWD" ]] then return 0 else - echo "Current directory should be \$QPACKAGE_ROOT/src" + echo "You are not in a submodule" exit -1 fi } diff --git a/src/Hartree_Fock/README.rst b/src/Hartree_Fock/README.rst index 70544122..0dc22710 100644 --- a/src/Hartree_Fock/README.rst +++ b/src/Hartree_Fock/README.rst @@ -8,7 +8,7 @@ Needed Modules ============== .. Do not edit this section. It was auto-generated from the -.. NEEDED_MODULES file. +.. update_README.py. .. image:: tree_dependancy.png @@ -19,7 +19,7 @@ Documentation ============= .. Do not edit this section. It was auto-generated from the -.. NEEDED_MODULES file. +.. update_README.py. `ao_bi_elec_integral_alpha `_ Alpha Fock matrix in AO basis set diff --git a/src/Makefile.common b/src/Makefile.common index 466181ea..049ea5b6 100644 --- a/src/Makefile.common +++ b/src/Makefile.common @@ -1,17 +1,5 @@ -.PHONY: default silent - -ifneq ($(IN_MAKE),1) - -default: - @$(MAKE) -C $(QPACKAGE_ROOT)/src $$(basename $(PWD)) - -veryclean: - clean_modules.sh - -clean: - IN_MAKE=1 make clean - -else # Called by scripts/build_module.sh +.PHONY: default +.SECONDARY: symlink ezfio_interface default: all .gitignore @@ -21,9 +9,6 @@ include $(QPACKAGE_ROOT)/src/Makefile.config # Create the NEEDED_CHILDREN_MODULES variable, needed for IRPF90 NEEDED_CHILDREN_MODULES=$(shell module_handler.py print_genealogy) -# Check and update dependencies -include Makefile.depend - # Define the Makefile common variables EZFIO_DIR=$(QPACKAGE_ROOT)/EZFIO EZFIO=$(EZFIO_DIR)/lib/libezfio_irp.a @@ -36,21 +21,47 @@ LIB+=$(EZFIO) $(MKL) IRPF90+=$(patsubst %, -I %, $(INCLUDE_DIRS)) $(IRPF90_FLAGS) # Update Makefile.depend -Makefile.depend: $(wildcart */Makefile) +Makefile.depend: $(wildcard */Makefile) ${QPACKAGE_ROOT}/scripts/module/module_handler.py save_makefile_depend -irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard *.inc.f) Makefile.depend Makefile $(EZFIO) NEEDED_CHILDREN_MODULES $(wildcard *.py) - - $(IRPF90) - - update_README.py +# Check and update dependencies +include Makefile.depend + +# Create symlink +symlink: $(wildcard $(QPACKAGE_ROOT)/src/*/NEEDED_CHILDREN_MODULES) + ${QPACKAGE_ROOT}/scripts/module/module_handler.py create_symlink + +# Define the EZFIO rules +$(EZFIO): $(wildcard $(QPACKAGE_ROOT)/src/*/*.ezfio_config) $(wildcard $(QPACKAGE_ROOT)/src/*/EZFIO.cfg) + $(QPACKAGE_ROOT)/scripts/ezfio_interface/prepare_ezfio.sh + cd $(EZFIO_DIR);\ + export FC="$(FC)" ; export FCFLAGS="$(FCFLAGS)" ; export IRPF90="$(IRPF90)" ;\ + $(MAKE) ;\ + $(MAKE) Python + +# Update EZFIO interface (create the irp.f90 and the ocaml) +ezfio_interface: symlink $(wildcard $(QPACKAGE_ROOT)/src/*/EZFIO.cfg) + ${QPACKAGE_ROOT}/scripts/ezfio_interface/ei_handler.py --irpf90 --ocaml --recursif + +irpf90.make: $(filter-out IRPF90_temp/%, $(wildcard */*.irp.f)) $(wildcard *.irp.f) $(wildcard .inc.f) Makefile.depend Makefile $(EZFIO) $(wildcard *.py) symlink ezfio_interface + $(IRPF90) include irpf90.make -endif +# Need NEEDED_CHILDREN_MODULES and IRPMAN +README.rst: NEEDED_CHILDREN_MODULES irpf90.make + ${QPACKAGE_ROOT}/scripts/module/update_README.py -.gitignore: - $(QPACKAGE_ROOT)/scripts/create/create_gitignore.sh +tree_dependancy.png: NEEDED_CHILDREN_MODULES + ${QPACKAGE_ROOT}/scripts/module/module_handler.py create_png -# Frequent typos -clena: clean -veryclena: veryclean -vercylean: veryclean +#Need all the executable +.gitignore: irpf90.make + ${QPACKAGE_ROOT}/scripts/module/create_gitignore.sh + +# +# +# # Frequent typos +# clena: clean +# veryclena: roger +# vercylean: roger