10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-06-02 11:25:26 +02:00

Included many changes

This commit is contained in:
Anthony Scemama 2018-11-16 12:39:30 +01:00
parent dbb35f47a9
commit 9b2318a5ce
37 changed files with 60 additions and 460 deletions

1
config/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.cfg

1
data/.gitignore vendored
View File

@ -1 +1,2 @@
executables
ezfio_defaults

2
include/.gitignore vendored
View File

@ -0,0 +1,2 @@
zmq.h
zmq_utils.h

11
install/.gitignore vendored
View File

@ -1,11 +0,0 @@
config/qp_create_ninja.pickle
Downloads
_build
docopt
emsl
EZFIO
irpf90
resultsFile
zlib
build.ninja
p_graphviz

View File

View File

@ -1,14 +0,0 @@
#!/bin/bash -x
# This script should be included
BUILD=_build/${TARGET}
rm -rf -- ${BUILD}
mkdir ${BUILD} || exit 1
if [[ -f Downloads/${TARGET}.tar.gz ]] ; then
tar -zxf Downloads/${TARGET}.tar.gz --strip-components=1 --directory=${BUILD} || exit 1
elif [[ -f Downloads/${TARGET}.tar.bz2 ]] ; then
tar -jxf Downloads/${TARGET}.tar.bz2 --strip-components=1 --directory=${BUILD} || exit 1
fi
_install || exit 1
rm -rf -- ${BUILD} _build/${TARGET}.log
exit 0

View File

@ -1,25 +0,0 @@
#!/bin/bash
# This script should be included
# pro:
#
# solid way to compare fancy version strings:
# support any length of sub-parts (ie: 1.3alpha.2.dev2 > 1.1 ?)
# support alpha-betical sort (ie: 1.alpha < 1.beta2)
# support big size version (ie: 1.10003939209329320932 > 1.2039209378273789273 ?)
# can easily be modified to support n arguments. (leaved as an exercise ;) )
# usually very usefull with 3 arguments: (ie: 1.2 < my_version < 2.7 )
# cons:
#
# uses a lot of various calls to different programs. So it's not that efficient.
# uses a pretty recent version of sort and it might not be available on your system. (check with man sort)
function version_gt() { test "$(echo "$@" | tr " " "\n" | sort -V | tail -n 1)" == "$1"; }
irp_cur_version=`irpf90 -v`
irp_need_version=1.6.7
if version_gt $irp_cur_version $irp_need_version; then
echo "OK"
fi
echo "FAIL"

View File

@ -1,33 +0,0 @@
#!/usr/bin/env python
import urllib
import sys
__author__ = "Anthony Scemama"
__date__ = "Mon Apr 7 15:30:29 CEST 2014"
"""Fetches a file from a given URL.
syntax : %s <URL> <local_filename>"""%(sys.argv[0])
# Check command line
if len(sys.argv) < 3:
print """
usage:
%s <URL> <local_filename>"""%(sys.argv[0])
URL = sys.argv[1]
filename = sys.argv[2]
webpage = urllib.urlopen(URL)
data = webpage.read()
if "404 - Not Found" in data:
print "Error in URL"
sys.exit(1)
file = open(filename,'w')
file.write(data)
file.close()

View File

@ -1,13 +0,0 @@
#!/bin/bash -x
TARGET=bats
function _install()
{
cp -R ${BUILD} . || exit 1
cd ../bin
ln -s ../install/${TARGET}/libexec/bats . || return 1
cd -
}
source scripts/build.sh

View File

@ -1,13 +0,0 @@
#!/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
}
source scripts/build.sh

View File

@ -1,10 +0,0 @@
#!/bin/bash -x
TARGET=docopt
function _install()
{
cp -R ${BUILD} . || exit 1
}
source scripts/build.sh

View File

@ -1,10 +0,0 @@
#!/bin/bash -x
TARGET=emsl
function _install()
{
cp -R ${BUILD} . || exit 1
}
source scripts/build.sh

View File

@ -1,16 +0,0 @@
#!/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

View File

@ -1,22 +0,0 @@
#!/bin/bash -x
TARGET=f77zmq
function _install()
{
cd ..
QP_ROOT=$PWD
cd -
set -e
set -u
export ZMQ_H="${QP_ROOT}"/include/zmq.h
cd "${BUILD}"
make -j 8 || exit 1
mv libf77zmq.a "${QP_ROOT}"/lib || exit 1
mv libf77zmq.so "${QP_ROOT}"/lib || exit 1
cp f77_zmq_free.h "${QP_ROOT}"/src/ZMQ/f77_zmq.h
cd -
return 0
}
source scripts/build.sh

View File

@ -1,17 +0,0 @@
#!/bin/bash -x
TARGET=gmp
function _install()
{
rm -rf -- ${TARGET}
mkdir ${TARGET} || exit 1
cd ..
QP_ROOT=$PWD
cd -
cd ${BUILD}
./configure --prefix=$QP_ROOT && make -j 8 || exit 1
make install || exit 1
}
source scripts/build.sh

View File

@ -1,32 +0,0 @@
#!/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
cat << EOF > ../bin/irpf90 || return 1
#!/bin/bash
exec \${QP_ROOT}/install/irpf90/bin/irpf90 \$@
EOF
cat << EOF > ../bin/irpman || return 1
#!/bin/bash
exec \${QP_ROOT}/install/irpf90/bin/irpman \$@
EOF
chmod +x ../bin/irpf90 ../bin/irpman || return 1
return 0
}
source scripts/build.sh

View File

@ -1,10 +0,0 @@
#!/bin/bash -x
git clone https://github.com/Reference-LAPACK/lapack-release.git || echo "Clone failed"
cd lapack-release
cp make.inc.example make.inc
make -j 8
mv librefblas.a liblapack.a libtmglib.a $QP_ROOT/lib

View File

@ -1,14 +0,0 @@
#!/bin/bash -x
TARGET=m4
function _install()
{
cd ..
QP_ROOT=$PWD
cd -
cd ${BUILD}
./configure --prefix=$QP_ROOT && make || exit 1
}
source scripts/build.sh

View File

@ -1,14 +0,0 @@
#!/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

View File

@ -1,83 +0,0 @@
#!/bin/bash
cd ..
QP_ROOT=$PWD
cd -
# Normal installation
PACKAGES="core cryptokit ocamlfind sexplib zmq ppx_sexp_conv ppx_deriving"
# Needed for ZeroMQ
#export C_INCLUDE_PATH="${QP_ROOT}"/include:"${C_INCLUDE_PATH}"
#export LIBRARY_PATH="${QP_ROOT}"/lib:"${LIBRARY_PATH}"
#export LDFLAGS="-L$QP_ROOT/lib"
#export LD_LIBRARY_PATH="${QP_ROOT}"/lib:"${LD_LIBRARY_PATH}"
# return 0 if program version is equal or greater than check version
check_version () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
i=$(gcc -dumpversion)
check_version 4.6 $i
if [[ $? == 1 ]]
then
echo "GCC version $(gcc -dumpversion) too old. GCC >= 4.6 required."
rm ${QP_ROOT}/bin/opam
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/ 4.07.0 || 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:${QP_ROOT}/include:${C_INCLUDE_PATH}
source ${HOME}/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true
NCPUs=$(cat /proc/cpuinfo | grep -i MHz | wc -l)
${QP_ROOT}/bin/opam install -j ${NCPUs} stdint.0.4.2 -y || exit 1
echo ${PACKAGES} | xargs ${QP_ROOT}/bin/opam install -j ${NCPUs} -y || exit 1
rm -f ../_build/ocaml.log

View File

@ -1,10 +0,0 @@
#!/bin/bash -x
TARGET=p_graphviz
function _install()
{
cp -R ${BUILD} . || exit 1
}
source scripts/build.sh

View File

@ -1,19 +0,0 @@
#!/bin/bash -x
TARGET=patch
function _install()
{
mkdir ${TARGET}
cd ..
QP_ROOT=$PWD
cd -
cd ${BUILD}
./configure --prefix=${QP_ROOT} && 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

View File

@ -1,11 +0,0 @@
#!/bin/bash -x
TARGET=resultsFile
function _install()
{
cp -R ${BUILD} . || exit 1
}
source scripts/build.sh

View File

@ -1,22 +0,0 @@
#!/bin/bash -x
TARGET=zeromq
function _install()
{
cd ..
QP_ROOT=$PWD
cd -
set -e
set -u
ORIG=$(pwd)
cd "${BUILD}"
./autogen.sh
./configure --prefix=$QP_ROOT --without-libsodium --disable-libunwind || exit 1
make -j 8 || exit 1
make install || exit 1
cd ${ORIG}
return 0
}
source scripts/build.sh

View File

@ -1,18 +0,0 @@
#!/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
./configure --prefix=$QP_ROOT && make || exit 1
make install || exit 1
}
source scripts/build.sh

View File

@ -67,8 +67,8 @@ qp_run.native: $(MLFILES) $(MLIFILES) executables
$(OCAMLBUILD) $*.native -use-ocamlfind $(PKGS)
ln -s $*.native $*
ezfio.ml: ${QP_ROOT}/install/EZFIO/Ocaml/ezfio.ml
cp ${QP_ROOT}/install/EZFIO/Ocaml/ezfio.ml .
ezfio.ml: ${QP_ROOT}/external/ezfio/Ocaml/ezfio.ml
cp ${QP_ROOT}/external/ezfio/Ocaml/ezfio.ml .
qptypes_generator.byte: qptypes_generator.ml
$(OCAMLBUILD) qptypes_generator.byte -use-ocamlfind
@ -79,8 +79,8 @@ Qptypes.ml: qptypes_generator.byte
git:
./create_git_sha1.sh
${QP_ROOT}/install/EZFIO/Ocaml/ezfio.ml:
$(NINJA) -C ${QP_ROOT}/install/EZFIO
${QP_EZFIO}/Ocaml/ezfio.ml:
$(NINJA) -C ${QP_EZFIO}
Input_auto_generated.ml qp_edit.ml: $(filter-out Input_auto_generated.ml, $(wildcard Input_*.ml))
ei_handler.py ocaml_global

3
scripts/.gitignore vendored
View File

@ -1,3 +1,4 @@
*.pyc
*.pyo
docopt.py
docopt.py
resultsFile/

View File

@ -1,8 +1,8 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Usage: qp_create_ninja.py create <config_file> (--development | --production)
qp_create_ninja.py update
Usage: qp_create_ninja create <config_file> (--development | --production)
qp_create_ninja update
"""
@ -37,7 +37,7 @@ from qp_path import QP_ROOT, QP_SRC, QP_EZFIO
LIB = "" # join(QP_ROOT, "lib", "rdtsc.o")
EZFIO_LIB = join(QP_ROOT, "lib", "libezfio_irp.a")
ZMQ_LIB = join(QP_ROOT, "lib", "libf77zmq.a") + " " + join(QP_ROOT, "lib", "libzmq.a") + " -lstdc++ -lrt"
ZMQ_LIB = join(QP_ROOT, "lib", "libf77zmq.a") + " " + join(QP_ROOT, "lib", "libzmq.a") + " -lstdc++ -lrt -ldl"
ROOT_BUILD_NINJA = join(QP_ROOT, "config", "build.ninja")
header = r"""#
@ -264,7 +264,7 @@ def ninja_ezfio_rule():
l_flag = ["export {0}='${0}'".format(flag)
for flag in ["FC", "FCFLAGS", "IRPF90"]]
install_lib_ezfio = join(QP_ROOT, 'install', 'EZFIO', "lib", "libezfio_irp.a")
install_lib_ezfio = join(QP_EZFIO, "lib", "libezfio_irp.a")
l_cmd = ["cd {0}".format(QP_EZFIO)] + l_flag
l_cmd += ["rm -f make.config ; ninja && rm -f {1} ; ln -sf {0} {1}".format(install_lib_ezfio, EZFIO_LIB)]
@ -654,9 +654,8 @@ def ninja_module_build(path_module, d_binaries):
path_readme = os.path.join(path_module.abs, "README.rst")
l_string = ["build module_{0}: phony {1} {2}".format(path_module.rel,
" ".join(l_abs_bin),
path_readme), ""]
l_string = ["build module_{0}: phony {1}".format(path_module.rel,
" ".join(l_abs_bin)) ]
return l_string
@ -690,13 +689,20 @@ def save_subninja_file(path_module):
" description = Cleaning module {0}".format(path_module.rel),
""]
l_string += ["rule executables",
" command = make -C {0} executables .gitignore qp_edit.native qp_run.native".format(join(QP_ROOT,"ocaml")),
" description = Updating OCaml executables",
""]
l_string += ["build dummy_target: update_build_ninja_root", "",
"build all: make_all_binaries dummy_target", "",
"build local: make_local_binaries dummy_target", "",
"build executables: executables local 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))
@ -736,6 +742,7 @@ def create_build_ninja_global():
"", ]
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))
@ -833,7 +840,7 @@ if __name__ == "__main__":
if module not in d_binaries:
l_msg = ["{0} is a root module but does not contain a main file.",
"- Create it in {0}",
"- Or delete {0} `qp_module.py uninstall {0}`",
"- Or delete {0} `qp_module uninstall {0}`",
"- Or install a module that needs {0} with a main "]
print "\n".join(l_msg).format(module.rel)

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import os
import os, sys
import ConfigParser
@ -16,6 +16,10 @@ def get_compilation_option(pwd_cfg, flag_name):
"""
Return the flag compilation of a compile.cfg located in pwd_cfg
"""
if not os.path.isfile(pwd_cfg):
print "Configuration file %s not found"%(pwd_cfg)
sys.exit(1)
config = ConfigParser.ConfigParser()
config.read(pwd_cfg)

View File

@ -160,7 +160,7 @@ def get_type_dict():
# Untouch
b = r.find('let untouched = "')
e = r.find('"', b)
e = r.find('let parse_input', b)
l_un = [i for i in r[b:e].splitlines() if i.strip().startswith("module")]

View File

@ -23,11 +23,12 @@ from functools import reduce
try:
QP_ROOT = os.environ["QP_ROOT"]
QP_EZFIO = os.environ["QP_EZFIO"]
except:
print "Error: QP_ROOT environment variable not found."
sys.exit(1)
else:
sys.path = [ QP_ROOT + "/install/EZFIO/Python",
sys.path = [ QP_EZFIO + "/Python",
QP_ROOT + "/install/resultsFile",
QP_ROOT + "/install",
QP_ROOT + "/scripts"] + sys.path

View File

@ -234,7 +234,7 @@ if __name__ == '__main__':
for module in l_module:
if not is_module(module):
print "{0} is not a valide module. Abort".format(module)
print "{0} is not a valid module. Abort".format(module)
print "No NEED in it"
sys.exit(1)

View File

@ -2,11 +2,11 @@
# -*- coding: utf-8 -*-
"""
Usage:
qp_module.py create -n <name> [<children_modules>...]
qp_module.py download -n <name> [<path_folder>...]
qp_module.py install <name>...
qp_module.py list (--installed | --available-local)
qp_module.py uninstall <name>
qp_module create -n <name> [<children_modules>...]
qp_module download -n <name> [<path_folder>...]
qp_module install <name>...
qp_module list (--installed | --available-local)
qp_module uninstall <name>
Options:
list: List all the modules available
create: Create a new module
@ -59,32 +59,32 @@ def save_new_module(path, l_child):
f.write("""
implicit none
BEGIN_DOC
! TODO
! TODO : Put the documentation of the program here
END_DOC
print *, 'Hello world'
end
""")
def main(arguments):
if arguments["list"]:
if arguments["--installed"]:
l_repository = [QP_SRC]
elif arguments["--available-local"]:
l_repository = [QP_PLUGINS]
m_instance = ModuleHandler(l_repository)
for module in sorted(m_instance.l_module):
print "* {0}".format(module)
elif arguments["create"]:
m_instance = ModuleHandler([QP_SRC])
l_children = arguments["<children_modules>"]
name = arguments["<name>"][0]
if arguments in ["list_installed", "list_plugins"]:
if arguments["list_installed"]:
l_repository = [QP_SRC]
elif arguments["list_plugins"]:
l_repository = [QP_PLUGINS]
m_instance = ModuleHandler(l_repository)
for module in sorted(m_instance.l_module):
print "* {0}".format(module)
if arguments["create"]:
m_instance = ModuleHandler([QP_SRC])
l_children = arguments["<needed_modules>"]
name = arguments["<name>"][0]
path = os.path.join(QP_PLUGINS, name)
print "Created module:"
@ -172,7 +172,7 @@ def main(arguments):
print "Your src directory is broken. Please remove %s" % des
raise
try:
subprocess.check_call(["qp_create_ninja.py", "update"])
subprocess.check_call(["qp_create_ninja", "update"])
except:
raise

View File

@ -12,5 +12,5 @@ except:
else:
QP_SRC = os.path.join(QP_ROOT, "src")
QP_PLUGINS = os.path.join(QP_ROOT, "plugins")
QP_EZFIO = os.path.join(QP_ROOT, "install", "EZFIO")
QP_EZFIO = os.environ["QP_EZFIO"]
QP_OCAML = os.path.join(QP_ROOT, "ocaml")