Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • jakub.both/dune-common
  • samuel.burbulla/dune-common
  • patrick.jaap/dune-common
  • tobias.leibner/dune-common
  • alexander.mueller/dune-common
  • pipping/dune-common
  • Xinyun.Li/dune-common
  • felix.schindler/dune-common
  • simon.praetorius/dune-common
  • ani.anciaux-sedrakian/dune-common
  • henrik.stolzmann/dune-common
  • matthew.t.collins/dune-common
  • liam.keegan/dune-common
  • felix.mueller/dune-common
  • ansgar/dune-common
  • dominic/dune-common
  • lars.lubkoll/dune-common
  • exadune/dune-common
  • felix.gruber/dune-common
  • govind.sahai/dune-common
  • michael.sghaier/dune-common
  • core/dune-common
  • kilian.weishaupt/dune-common
  • markus.blatt/dune-common
  • joscha.podlesny/dune-common
  • tobias.meyer.andersen/dune-common
  • andreas.thune/dune-common
  • lars.bilke/dune-common
  • daniel.kienle/dune-common
  • lukas.renelt/dune-common
  • smuething/dune-common
  • stephan.hilb/dune-common
  • tkoch/dune-common
  • nils.dreier/dune-common
  • rene.milk/dune-common
  • lasse.hinrichsen/dune-common
  • yunus.sevinchan/dune-common
  • lisa_julia.nebel/dune-common
  • claus-justus.heine/dune-common
  • lorenzo.cerrone/dune-common
  • eduardo.bueno/dune-common
41 results
Show changes
Showing
with 2554 additions and 926 deletions
#! /usr/bin/env python3
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#
# Wrapper around CTest for DUNE
#
# CTest returns with an error status not only when tests failed, but also
# when tests were only skipped. This wrapper checks the log and returns
# successfully if no tests failed; skipped tests do not result in an error.
# This behaviour is needed in a continuous integration environment, when
# building binary packages or in other cases where the testsuite should be
# run automatically.
#
# Moreover, this script also converts the XML test report generated by CTest
# into a JUnit report file that can be consumed by a lot of reporting
# software.
#
# Author: Ansgar Burchardt <Ansgar.Burchardt@tu-dresden.de>
# Author: Steffen Müthing <steffen.muething@iwr.uni-heidelberg.de> (for the JUnit part)
import errno
import glob
import os.path
import shutil
import subprocess
import sys
import xml.etree.ElementTree as et
from pathlib import Path
import os
import re
class CTestParser:
def findCTestOutput(self):
files = glob.glob("Testing/*/Test.xml")
if len(files) != 1:
fn = files.join(", ")
raise Exception("Found multiple CTest output files: {}".format(files.join(", ")))
return files[0]
def printTest(self,test,output=None):
status = test.get("Status")
name = test.find("Name").text
fullName = test.find("FullName").text
if output is not None:
output = test.find("Results").find("Measurement").find("Value").text
print("======================================================================")
print("Name: {}".format(name))
print("FullName: {}".format(fullName))
print("Status: {}".format(status.upper()))
if output:
print("Output:")
for line in output.splitlines():
print(" ", line)
print()
def __init__(self,junitpath=None):
self.inputpath = self.findCTestOutput()
if junitpath is None:
if "CI_PROJECT_DIR" in os.environ:
buildroot = Path(os.environ["CI_PROJECT_DIR"])
# create a slug from the project name
name = os.environ["CI_PROJECT_NAME"].lower()
name = re.sub(r"[^-a-z0-9]","-",name);
junitbasename = "{}-".format(name)
else:
buildroot = Path.cwd()
junitbasename = ""
junitdir = buildroot / "junit"
junitdir.mkdir(parents=True,exist_ok=True)
self.junitpath = junitdir / "{}cmake.xml".format(junitbasename)
else:
self.junitpath = Path(junitpath)
junitdir = junitpath.resolve().parent
junitdir.mkdir(parents=True,exist_ok=True)
self.tests = 0
self.passed = 0
self.failures = 0
self.skipped = 0
self.errors = 0
self.skipped = 0
self.time = 0.0
def createJUnitSkeleton(self):
self.testsuites = et.Element("testsuites")
self.testsuite = et.SubElement(self.testsuites,"testsuite")
self.properties = et.SubElement(self.testsuite,"properties")
def fillJUnitStatistics(self):
self.testsuite.set("name","cmake")
self.testsuite.set("tests",str(self.tests))
self.testsuite.set("disabled","0")
self.testsuite.set("errors",str(self.errors))
self.testsuite.set("failures",str(self.failures))
self.testsuite.set("skipped",str(self.skipped))
self.testsuite.set("time",str(self.time))
def processTest(self,test):
testcase = et.SubElement(self.testsuite,"testcase")
testcase.set("name",test.find("Name").text)
testcase.set("assertions","1")
testcase.set("classname","cmake")
time = test.find("./Results/NamedMeasurement[@name='Execution Time']/Value")
if time is not None:
self.time += float(time.text)
testcase.set("time",time.text)
self.tests += 1
outcome = test.get("Status")
if outcome == "passed":
testcase.set("status","passed")
self.passed += 1
elif outcome == "failed":
self.failures += 1
testcase.set("status","failure")
failure = et.SubElement(testcase,"failure")
failure.set("message","program execution failed")
failure.text = test.find("./Results/Measurement/Value").text
self.printTest(test)
elif outcome == "notrun":
# This does not exit on older CMake versions, so work around that
try:
status = test.find("./Results/NamedMeasurement[@name='Completion Status']/Value").text
if status == "SKIP_RETURN_CODE=77":
self.skipped += 1
et.SubElement(testcase,"skipped")
elif status == "Required Files Missing":
self.errors += 1
error = et.SubElement(testcase,"error")
error.set("message","compilation failed")
error.set("type","compilation error")
self.printTest(test,output="Compilation error")
else:
error = et.SubElement(testcase,"error")
error.set("message","unknown error during test execution")
error.set("type","unknown")
error.text = test.find("./Results/Measurement/Value").text
self.errors += 1
self.printTest(test)
except AttributeError:
output_tag = test.find("./Results/Measurement/Value")
if output_tag is not None:
msg = output_tag.text
if "skipped" in msg:
self.skipped += 1
et.SubElement(testcase,"skipped")
elif "Unable to find required file" in msg:
self.errors += 1
error = et.SubElement(testcase,"error")
error.set("message","compilation failed")
error.set("type","compilation error")
self.printTest(test,output="Compilation error")
else:
error = et.SubElement(testcase,"error")
error.set("message","unknown error during test execution")
error.set("type","unknown")
error.text = msg
self.errors += 1
self.printTest(test)
else:
error = et.SubElement(testcase,"error")
error.set("message","unknown error during test execution")
error.set("type","unknown")
error.text = "no message"
self.errors += 1
self.printTest(test)
output_tag = test.find("./Results/Measurement/Value")
if output_tag is not None:
out = et.SubElement(testcase,"system-out")
out.text = output_tag.text
def process(self):
with open(self.inputpath, "r", encoding="utf-8") as fh:
tree = et.parse(fh)
root = tree.getroot()
self.createJUnitSkeleton()
for test in root.findall(".//Testing/Test"):
self.processTest(test)
self.fillJUnitStatistics()
with self.junitpath.open("wb") as fh:
fh.write(et.tostring(self.testsuites,encoding="utf-8"))
print("JUnit report for CTest results written to {}".format(self.junitpath))
return self.errors + self.failures
def runCTest(argv=[]):
cmd = ["ctest",
"--output-on-failure",
"--dashboard", "ExperimentalTest",
"--no-compress-output",
]
cmd.extend(argv)
subprocess.call(cmd)
def checkDirectory():
if not os.path.exists("CMakeCache.txt"):
raise Exception("ERROR: dune-ctest must be run in a cmake build directory")
def removeCTestOutput():
try:
shutil.rmtree("Testing")
except OSError as e:
if e.errno != errno.ENOENT:
raise
def main():
try:
checkDirectory()
removeCTestOutput()
runCTest(argv=sys.argv[1:])
parser = CTestParser()
errors = parser.process()
status = 0 if errors == 0 else 1
sys.exit(status)
except Exception as e:
print("Internal error: {}".format(e))
sys.exit(127)
if __name__ == "__main__":
main()
#!/bin/sh
# dune-git-whitespace-hook
# DO NOT TOUCH THE PRECEDING LINE
# It is used by dunecontrol to enable automatic updates of the whitespace hook
#
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#
# DUNE pre-commit hook to enforce whitespace policy
# This hook prevents adding lines with trailing whitespace and or tab characters
# in line indentation for certain files (see the TRAILING_WHITESPACE_DEFAULT and
# TAB_IN_INDENT_DEFAULT variables below for the default sets of files that will
# be checked).
# You can tell the hook which files should be inspected by setting the Git
# configuration variables "hooks.whitespace.trailing" and "hooks.whitespace.tabinindent".
# Those variables should contain valid Perl regular expressions. The names of modified
# files will be matched against those regexes.
# git-diff-index needs a valid commit to compare to
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# By default, we disallow trailing whitespace for the following files, but the check for C/C++ and CMake sources
# happens in the tab-in-indent check to avoid confusing users with duplicate error messages
TRAILING_WHITESPACE_DEFAULT='^(dune\.module|README|README\.SVN|COPYING|INSTALL|TODO)$|^[^/]*(\.md|\.pc\.in)$|^doc/.*\.md$'
# By default, we disallow tabs in indents and trailing whitespace in C/C++ and CMake source files
TAB_IN_INDENT_DEFAULT='(^|/)CMakeLists\.txt$|(\.cpp|\.hpp|\.cc|\.hh|\.c|\.h|\.cmake|\.sh|\.py)$'
# Get user preferences
TRAILING_WHITESPACE_FILES=$(git config hooks.whitespace.trailing)
# Set default regex for disallowing trailing whitespace if the user did not set anything.
# We need to check the return value of git-config to distinguish the case
# when the user set an empty value
if [ $? -ne 0 ];
then
TRAILING_WHITESPACE_FILES="$TRAILING_WHITESPACE_DEFAULT"
fi
TAB_IN_INDENT_FILES=$(git config hooks.whitespace.tabinindent)
# Set default regex for disallowing tabs if the user did not set anything.
# We need to check the return value of git-config to distinguish the case
# when the user set an empty value
if [ $? -ne 0 ];
then
TAB_IN_INDENT_FILES="$TAB_IN_INDENT_DEFAULT"
fi
# Unfortunately, we have to mess directly with the repository config file,
# as git won't honor a custom config file specified by GIT_CONFIG
# backup repository-local user setting for core.whitespace
USER_WHITESPACE=$(git config --local --get core.whitespace)
if [ $? -ne 0 ];
then
USER_HAS_CUSTOM_WHITESPACE=0
else
USER_HAS_CUSTOM_WHITESPACE=1
fi
# Figure out how to call xargs to make sure it won't invoke its argument with
# an empty argument list. BSD xargs will not do that by default, while GNU xargs
# needs -r to do the same. So we start by checking whether xargs does the right
# thing without options. Now there could be other obscure versions of xargs out
# there (on clusters etc.) that behave in yet another way, so we try with -r as
# well. If that fails, we throw a big error message at the user.
# In the following line, xargs should not call false, so the return value should be 0.
echo "" | xargs false
if [ $? -ne 0 ]; then
# Let's try with -r
echo "" | xargs -r false
if [ $? -ne 0 ]; then
# Houston, we have a problem
if [ -z "$DUNE_WHITESPACE_IGNORE_XARGS" ]; then
echo "You seem to be lacking a version of xargs that is compatible to either BSD or GNU!" 1>&2
echo "Please file a bug report at http://dune-project.org about this issue with your exact operating system type and version!" 1>&2
echo "You can still use this hook by setting the environment variable DUNE_WHITESPACE_IGNORE_XARGS to 1, but please be aware" 1>&2
echo "that the hook might create false positives." 1>&2
echo "==============================================================" 1>&2
echo "Aborting the commit..." 1>&2
exit 99
else
SILENTXARGS=xargs
fi
else
SILENTXARGS="xargs -r"
fi
else
SILENTXARGS=xargs
fi
fail=0
done=0
do_cleanup()
{
if [ $done -ne 1 ];
then
echo "Error while executing whitespace checking pre-commit hook!" 1>&2
echo "There might still be whitespace errors in your commit!" 1>&2
fi
if [ $USER_HAS_CUSTOM_WHITESPACE -eq 1 ];
then
git config --replace-all core.whitespace "$USER_WHITESPACE"
else
git config --unset core.whitespace
fi
# be nice and let the commit go through if something went wrong along the
# way and we did not record a failure
exit $fail
}
trap do_cleanup EXIT
# set custom value
git config --replace-all core.whitespace trailing-space
if [ -z "$TRAILING_WHITESPACE_FILES" ];
then
git diff-index --check --cached $against --
result=$?
else
export TRAILING_WHITESPACE_FILES
git diff-index --cached --name-only $against \
| perl -ne 'print if /$ENV{TRAILING_WHITESPACE_FILES}/' \
| $SILENTXARGS git diff-index --check --cached $against --
result=$?
fi
if [ $result -ne 0 ];
then
fail=1
fi
git config --replace-all core.whitespace trailing-space,tab-in-indent
if [ -z "$TAB_IN_INDENT_FILES" ];
then
git diff-index --check --cached $against --
result=$?
else
export TAB_IN_INDENT_FILES
git diff-index --cached --name-only $against \
| perl -ne 'print if /$ENV{TAB_IN_INDENT_FILES}/' \
| $SILENTXARGS git diff-index --check --cached $against --
result=$?
fi
if [ $result -ne 0 ];
then
fail=1
fi
done=1
# trap will call the cleanup code
This diff is collapsed.
# -*-sh-*-
###############################################
###
### Configuration
###
# name of the "control" files
CONTROL="dune.module"
###############################################
###
### check for environment variables
###
if test -z $DUNE_CONTROL_PATH; then
DUNE_CONTROL_PATH=.
fi
if test -z $GREP; then
GREP=grep
fi
###############################################
#
# read paramters from a $CONTROL file
#
# paramters:
# $1 file to read
#
parse_control() {
# check file existence
if ! test -f "$1"; then
echo "ERROR: could not read file $1" > /dev/stderr
exit 1
fi
# read parameters from control file
local name="$(echo $($GREP Module: "$1" | cut -d ':' -f2))"
if test "x$name" = "x"; then
echo "ERROR: $CONTROL files $1 does not contain a Module entry" > /dev/stderr
exit 1
fi
local deps="$(echo $($GREP Depends: "$1" | cut -d ':' -f2))"
local sugs="$(echo $($GREP Suggests: "$1" | cut -d ':' -f2))"
local path="$(dirname "$1")"
# create and check variable name from module name
export module=$(fix_variable_name $name)
if ! check_modname "$module"; then
echo "ERROR: $CONTROL files $1 contains an invalid Module entry" > /dev/stderr
exit 1
fi
# avoid multiple definition of the same module
if test "x$(eval echo \$HAVE_$module)" != "x"; then
echo "ERROR: multiple definition of module $name" > /dev/stderr
echo "previous defined in:" > /dev/stderr
echo " $(eval echo \$PATH_$module)/$CONTROL" > /dev/stderr
echo "redefined in:" > /dev/stderr
echo " $path/$CONTROL" > /dev/stderr
exit 1
fi
# set status variables
export HAVE_${module}=yes
export PATH_${module}="$path"
export NAME_${module}="$name"
export DEPS_${module}="$deps"
export SUGS_${module}="$sugs"
}
#
# search for modules in each directory in DUNE_CONTROL_PATH
#
find_modules_in_path() {
# foreach dir in $@
while read dir; do
find_modules $dir
done <<EOF
$(echo $DUNE_CONTROL_PATH | sed -e 's/:/\n/g')
EOF
}
#
# search a directory recursively for $CONTROL files
#
# paramters:
# $1 directory to search for modules
#
find_modules() {
if test -d "$1"; then
local dir="$(cd "$1" && pwd)"
while read m; do
if test "x$m" != "x"; then
export module=""
parse_control "$m"
export MODULES="$MODULES $module"
fi
done <<EOF
$(find "$dir" -name $CONTROL | $GREP -v 'dune-[-_a-zA-Z]/dune\-[-a-zA-Z_]*\-[0-9]\+.[0-9]\+/')
EOF
else
if test -f "$1" &&
test "$(basename $1)" = "$CONTROL"; then
export module=""
parse_control "$1"
export MODULES="$MODULES $module"
else
echo "ERROR: '$1' is neither a directory nor a $CONTROL file" > /dev/stderr
false
fi
fi
}
#
# sort $MODULES according to the dependencies
#
sort_modules() {
for m in "$@"; do
# did we find a module file for this mopdule?
if test "x$(eval echo \$HAVE_$m)" != "x"; then
_sort_module $m
else
echo "ERROR: could not find module $dep" > /dev/stderr
exit 1
fi
done
export MODULES="$SORTEDMODULES"
}
#
# recursive part of sort_modules
# evaluate dependencies of one module
#
# paramters:
# $1 name of the modules
#
_sort_module() {
local module="$1"
shift 1
if ! check_modname $module; then
echo "ERROR: invalid module name $module" > /dev/stderr
exit 1
fi
if test "x$(eval echo \$SORT_DONE_${command}_${module})" != "xyes"; then
# resolve dependencies
for name in $(eval "echo \$DEPS_$module"); do
dep=$(fix_variable_name $name)
if ! check_modname $dep; then
echo "ERROR: invalid module name $dep" > /dev/stderr
exit 1
fi
if test "x$(eval echo \$HAVE_$dep)" != "x"; then
_sort_module $dep
else
# perhaps this module is installed,
# then it should be handled via pkg-config
if ! pkg-config $name; then
echo "ERROR: could not find module $dep" > /dev/stderr
echo " module is also unknown to pkg-config" > /dev/stderr
exit 1
fi
fi
done
# resolve suggestions
for name in $(eval "echo \$SUGS_$module"); do
dep=$(fix_variable_name $name)
if ! check_modname $dep; then
echo "ERROR: invalid module name $dep" > /dev/stderr
exit 1
fi
if test "x$(eval echo \$HAVE_$dep)" != "x"; then
_sort_module $dep
fi
done
# insert this module into the list
export SORT_DONE_${command}_${module}=yes
export SORTEDMODULES="$SORTEDMODULES $module"
fi
}
#
# load the $CONTROL file, skip all control variables
# and run a command
#
# parameters:
# $1 command to execute
# $2 full path of the $CONTROL file
#
eval_control() {
local command="$1"
local file="$2"
shift 2
if test -f "$file"; then
# open subshell
(
set -e
# load functions defined in $file
# if $command is not defined in $file,
# then the default implementation will be executed
eval "$($GREP -v '^[[:alnum:]]\+:' $file)"
# execute $command
$command
) || false
else
echo "ERROR: could not find $file" > /dev/stderr
exit 1
fi
}
#
# fix a value such that it is suitable for a variable name and assign it
#
# parameters:
# $1 name of variable
# $2 value
#
fix_variable_name() {
echo "$@" | tr '-' '_'
}
fix_and_assign() {
local name="$1"
if ! check_modname $name; then
echo "ERROR: error in assignment. $name is not a valid variabel name." > /dev/stderr
fi
shift 1
export $name=$(fix_variable_name $@)
}
#
# make sure the module name fits the naming convention
#
# parameters:
# $1 module name
#
check_modname() {
if sh -c "$ID=huhu" > /dev/null 2>&1; then
return 1
fi
# if ! echo "$1" | $GREP -q '^[a-zA-Z0-9_]\+$'; then
# return 1
# fi
return 0
}
#!/usr/bin/env python3
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
try:
import skbuild
except ImportError:
print("skbuild needed for packaging, run 'pip install scikit-build'")
import sys
sys.exit(0)
import sys, os, io, getopt, re, shutil
import importlib, subprocess
import email.utils
from datetime import date
# make sure that 'metadata' is taken from the current `dune-common` folder
# and not some installed version which might be different from the one I'm
# packaging (by mistake). The path to `packagemetadata.py` needs to be
# added to the python path (to work here) and to the environment so that a
# later call to `python setup.py` also works.
here = os.path.dirname(os.path.abspath(__file__))
mods = os.path.join(here, "..", "python", "dune")
sys.path.append(mods)
pythonpath = mods + ":" + os.environ.get('PYTHONPATH','.')
os.environ['PYTHONPATH'] = pythonpath
try:
from packagemetadata import metaData
except ImportError:
# not calling from within a dune-common source module so use installed
# version after all
from dune.packagemetadata import metaData
def main(argv):
repositories = ["gitlab", "testpypi", "pypi"]
def usage():
return 'usage: dunepackaging.py [--upload <'+"|".join(repositories)+'> | -c | --clean | --version <version> | --onlysdist | --bdist_conda]'
try:
opts, args = getopt.getopt(argv, "hc", ["upload=", "clean", "version=", "onlysdist", "bdist_conda"])
except getopt.GetoptError:
print(usage())
sys.exit(2)
upload = False
repository = "gitlab"
clean = False
version = None
onlysdist = False
bdistconda = False
for opt, arg in opts:
if opt == '-h':
print(usage())
sys.exit(2)
elif opt in ("--upload"):
upload = True
if arg != '':
repository = arg
if repository not in repositories:
print("Specified repository must be one of: " + " ".join(repositories))
sys.exit(2)
elif opt in ("-c", "--clean"):
clean = True
elif opt in ("--version"):
version = arg
elif opt in ("--onlysdist"):
onlysdist = True
elif opt in ("--bdist_conda"):
onlysdist = True
bdistconda = True
# Remove generated files
def removeFiles():
import glob
files = ['MANIFEST', 'dist', '_skbuild', '__pycache__']
print("Remove generated files: " + ", ".join(files))
remove = ['rm', '-rf'] + files
subprocess.call(remove)
# checkout setup.py and pyproject.toml
checkout = ['git', 'checkout', 'setup.py', 'pyproject.toml']
subprocess.call(checkout)
if clean:
removeFiles()
sys.exit(0)
data, cmake_flags = metaData(version, dependencyCheck=False)
if version is None:
version = data.version
# Generate setup.py
print("Generate setup.py")
f = open("setup.py", "w")
f.write("""#
# DO NOT MODIFY THIS FILE!
# This file is autogenerated by the `dunepackaging.py` script and
# only used for the pypi dune packages. This file will not be included in
# the build directory.
#
# See https://www.dune-project.org/dev/adding_python/ for docs on
# Python packaging for Dune modules.
#
""")
f.write("import os, sys\n")
if data.name == 'dune-common':
f.write("here = os.path.dirname(os.path.abspath(__file__))\n")
f.write("mods = os.path.join(here, \"python\", \"dune\")\n")
f.write("sys.path.append(mods)\n\n")
f.write("try:\n")
f.write(" from dune.packagemetadata import metaData\n")
f.write("except ImportError:\n")
f.write(" from packagemetadata import metaData\n")
f.write("from skbuild import setup\n")
f.write("setup(**metaData('"+version+"')[1])\n")
f.close()
# Generate pyproject.toml
print("Generate pyproject.toml")
f = open("pyproject.toml", "w")
f.write("""#
# DO NOT MODIFY THIS FILE!
# This file is autogenerated by the `dunepackaging.py` script and
# only used for the pypi dune packages. This file will not be included in
# the build directory.
#
# See https://www.dune-project.org/dev/adding_python/ for docs on
# Python packaging for Dune modules.
#
# This is uses the `Python-Requires` field in the `dune.modules` file to
# populate the `requires` entry. Additional packages needed for the package
# build should be added in the `dune.modules`. These packages will then also be
# included in the package install from source.
#
""")
requires = data.asPythonRequirementString(data.depends + data.python_requires)
requires = list(set(requires)) # make requirements unique
minimal = ["pip", "setuptools", "wheel", "scikit-build", "cmake>=3.16", "ninja", "requests"]
requires += [r for r in minimal if not any([a.startswith(r) for a in requires])]
requires.sort()
f.write("[build-system]\n")
f.write("requires = "+requires.__str__()+"\n")
f.write("build-backend = 'setuptools.build_meta'\n")
f.close()
# Create source distribution and upload to repository
python = sys.executable
if upload or onlysdist:
print("Remove dist")
remove = ['rm', '-rf', 'dist']
subprocess.call(remove)
# check if we have scikit-build
import importlib
if importlib.util.find_spec("skbuild") is None:
print("Please install the pip package 'scikit-build' to build the source distribution.")
sys.exit(2)
# append hash of current git commit to README
shutil.copy('README.md', 'tmp_README.md')
githash = ['git', 'rev-parse', 'HEAD']
hash = subprocess.check_output(githash, encoding='UTF-8')
with open("README.md", "a") as f:
f.write("\n\ngit-" + hash)
print("Create source distribution")
# make sure setup.py/pyproject.toml are tracked by git so that
# they get added to the package by scikit
gitadd = ['git', 'add', 'setup.py', 'pyproject.toml']
subprocess.call(gitadd)
# run sdist
build = [python, 'setup.py', 'sdist']
subprocess.call(build, stdout=subprocess.DEVNULL)
# undo the above git add
gitreset = ['git', 'reset', 'setup.py', 'pyproject.toml']
subprocess.call(gitreset)
# restore README.md
shutil.move('tmp_README.md', 'README.md')
if not onlysdist:
# check if we have twine
import importlib
if importlib.util.find_spec("twine") is None:
print("Please install the pip package 'twine' to upload the source distribution.")
sys.exit(2)
twine = [python, '-m', 'twine', 'upload']
twine += ['--repository', repository]
twine += ['dist/*']
subprocess.call(twine)
removeFiles()
# create conda package meta.yaml (experimental)
if bdistconda:
import hashlib
remove = ['rm', '-rf', 'dist/'+data.name]
subprocess.call(remove)
mkdir = ['mkdir', 'dist/'+data.name ]
subprocess.call(mkdir)
print("Create bdist_conda (experimental)")
distfile = 'dist/'+data.name+'-'+version+'.tar.gz'
datahash = ''
with open(distfile, "rb") as include:
source = include.read()
datahash = hashlib.sha256( source ).hexdigest()
print("Generate ",'dist/'+data.name+'/meta.yaml')
f = open('dist/'+data.name+'/meta.yaml', "w")
f.write('{% set name = "' + data.name + '" %}\n')
f.write('{% set version = "' + version + '" %}\n')
f.write('{% set hash = "' + datahash + '" %}\n\n')
f.write('package:\n')
f.write(' name: "{{ name|lower }}"\n')
f.write(' version: "{{ version }}"\n\n')
f.write('source:\n')
f.write(' path: ../{{ name }}-{{ version }}/\n')
f.write(' sha256: {{ hash }}\n\n')
f.write('build:\n')
f.write(' number: 1\n')
if 'TMPDIR' in os.environ:
f.write(' script_env:\n')
f.write(' - TMPDIR=' + os.environ['TMPDIR'] +'\n')
f.write(' script: "{{ PYTHON }} -m pip install . --no-deps --ignore-installed -vv "\n\n')
f.write('requirements:\n')
requirements = ['pip', 'python', 'mkl', 'tbb', 'intel-openmp',
'libgcc-ng', 'libstdcxx-ng', 'gmp', 'scikit-build',
'mpi4py', 'matplotlib', 'numpy', 'scipy', 'ufl']
for dep in data.depends:
requirements += [dep[0]]
f.write(' host:\n')
for dep in requirements:
f.write(' - ' + dep + '\n')
f.write('\n')
f.write(' run:\n')
for dep in requirements:
f.write(' - ' + dep + '\n')
f.write('\n')
f.write('test:\n')
f.write(' imports:\n')
f.write(' - ' + data.name.replace('-','.') + '\n\n')
f.write('about:\n')
f.write(' home: '+data.url+'\n')
f.write(' license: GPLv2 with linking exception.\n')
f.write(' license_family: GPL\n')
f.write(' summary: '+data.description+'\n')
f.close()
if __name__ == "__main__":
main(sys.argv[1:])
This diff is collapsed.
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
try:
from dune.common.module import resolve_dependencies, resolve_order, select_modules
except ImportError:
import os
here = os.path.dirname(os.path.abspath(__file__))
mods = os.path.join(os.path.dirname(here), "python", "dune", "common")
if os.path.exists(os.path.join(mods, "module.py")):
import sys
sys.path.append(mods)
from module import resolve_dependencies, resolve_order, select_modules
else:
raise
print("Found Modules:")
print("--------------")
modules, _ = select_modules()
for description in modules.values():
print(repr(description))
print()
print()
print("Resolved Dependencies:")
print("----------------------")
deps = resolve_dependencies(modules)
for mod_name, mod_deps in deps.items():
print(mod_name + ": " + " ".join(mod_deps))
print()
print("Build Order:")
print("------------")
print(" ".join(resolve_order(deps)))
#!/bin/bash
set -e
canonicalname(){
if test $# -ne 1; then
echo Usage: canonicalname path > /dev/stderr
return 1
fi
readlink $1 || echo "$(dirname $1)/$(basename $1)"
}
canonicalpath(){
if test $# -ne 1; then
echo Usage: canonicalpath path > /dev/stderr
return 1
fi
(cd $(dirname $(canonicalname $1)) && pwd)
}
version=0.1
verbose=0
usage()
{
cat <<EOF
Usage: mpi-config [OPTIONS] [LIBRARIES]
Options:
[--mpicc[=COMPILER]]
[--disable-cxx]
[--verbose]
[--version]
[--mpiversion]
[--libs]
[--cflags]
EOF
exit $1
}
if test $# -eq 0 ; then
usage 1 1>&2
fi
while test $# -gt 0 ; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--mpicc=*)
MPICC=$optarg
;;
--version)
echo $version
exit 0
;;
--verbose)
verbose=1
;;
--disable-cxx)
disablecxx=yes
;;
--mpiversion)
tasks="$tasks print_mpiversion"
;;
--cflags)
tasks="$tasks print_cflags"
;;
--libs)
tasks="$tasks print_libs"
;;
*)
usage 1 1>&2
;;
esac
shift
done
if test x$MPICC = x ; then
MPICC=mpicc
fi
#
# LIB
#
# load mpi-config.m4
#
eval "$(
m4 -I$(canonicalpath $0)/../m4/ <<EOF
changequote([, ])
define([AC_DEFUN],[define([\$1],[\$2])])
define([AC_MSG_CHECKING],[
if test $verbose -gt 0; then
echo -n "checking \$@..."
fi
])
define([AC_MSG_RESULT],[
if test $verbose -gt 0; then
echo " \$@"
fi
])
define([AC_MSG_NOTICE],[
if test $verbose -gt 0; then
echo "\$@"
fi
])
define([AC_MSG_ERROR],[
if test $verbose -gt 0; then
echo "Error: \$@"
exit 1
fi
])
include([mpi-config.m4])
MPI_CONFIG_HELPER
EOF
)"
#
# output methods
#
print_mpiversion() {
get_mpiparameters
echo $MPI_VERSION
}
print_cflags() {
get_mpiparameters
if test x$disablecxx = xyes; then
MPI_CPPFLAGS="$MPI_CPPFLAGS $MPI_NOCXXFLAGS"
fi
echo $MPI_CPPFLAGS
}
print_libs() {
get_mpiparameters
echo $MPI_LDFLAGS
}
for task in $tasks; do
eval $task
done
#!/bin/bash
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#
# This script builds a Python package index on gitlab.dune-project.org. Such an
# index is necessary as a drop-in replacement for PyPI in continuous integration,
# when runners operate with restricted network access.
#
# Running this script requires the following prerequisites to be met:
# * Go to Gitlab Profile/Setting/Access Tokens and create a personal API access token with
# at least the `write_registry` and 'api' scope.
# * Export your token with `export TWINE_PASSWORD=<token>`
#
# This script exits upon errors
set -e
# We authenticate with a personal Gitlab API token. You are expected to
# have set TWINE_PASSWORD to your API token when calling this script.
export TWINE_USERNAME=__token__
# Make sure that TWINE_PASSWORD was set
# export TWINE_PASSWORD=...
if [ -z "$TWINE_PASSWORD" ]
then
echo "TWINE_PASSWORD was not set!"
exit 1
fi
# Create a temporary directory as workspace for this script
TMPDIR=$(mktemp -d)
pushd $TMPDIR
python3 -m venv env
source env/bin/activate
python -m pip install pip-download twine
pip-download -d $(pwd)/downloads \
# dune-common \
# dune-geometry \
# dune-grid \
# dune-istl \
# dune-localfunctions \
# dune-alugrid \
# dune-fem \
pyparsing \
mpi4py \
wheel \
setuptools \
jinja2 \
portalocker \
fenics-ufl==2019.1.0 \
matplotlib \
scipy \
pip>=21 \
ninja \
sortedcontainers
# Upload the packages to the index
for filename in downloads/*
do
# NB: The 133 here is the Gitlab project ID of dune-common.
python -m twine upload --verbose --skip-existing --repository-url https://gitlab.dune-project.org/api/v4/projects/133/packages/pypi $filename
done
# Clean up the temporary directory
popd
rm -rf $TMPDIR
#!/bin/sh
# $Id$
# script wrapping a call to wml
#
# if the environment-variable DUNEWEBDIR is set to a checked out
# version of dune-web then wml is called in a way that the real web
# layout is used
if test x"$DUNEWEBDIR" = x ; then
# call wml without tricks
@WML@ $*
fi
# rewrite filenames to absolute pathes
PWD=`pwd`
for OPT in $* ; do
case "$OPT" in
*.wml) ARGS="$ARGS $PWD/$OPT";;
*.html) ARGS="$ARGS $PWD/$OPT";;
*) ARGS="$ARGS $OPT" ;;
esac
done
# check if DUNEWEBDIR seems correct
if test -d "$DUNEWEBDIR" && test -r $DUNEWEBDIR/layout/default.wml ; then
# call wml from within dune-web
# --nocd lets wml use the .wmlrc from dune-web
( cd $DUNEWEBDIR && @WML@ --nocd -DROOT=$BASEDIR $ARGS )
else
# call wml without tricks
@WML@ $*
fi
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
add_subdirectory(modules)
add_subdirectory(scripts)
add_subdirectory(test)
\ No newline at end of file
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
# Defines the functions to use BLAS/Lapack
#
# .. cmake_function:: add_dune_blas_lapack_flags
#
# .. cmake_param:: targets
# :positional:
# :single:
# :required:
#
# A list of targets to use BLAS/Lapack with.
#
include_guard(GLOBAL)
include(FeatureSummary)
set_package_properties("BLAS" PROPERTIES
DESCRIPTION "fast linear algebra routines")
set_package_properties("LAPACK" PROPERTIES
DESCRIPTION "fast linear algebra routines")
# register HAVE_BLAS and HAVE_LAPACK for config.h
set(HAVE_BLAS ${BLAS_FOUND})
set(HAVE_LAPACK ${LAPACK_FOUND})
# register Lapack library as dune package
if(HAVE_LAPACK)
dune_register_package_flags(LIBRARIES "${LAPACK_LIBRARIES}")
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES ${LAPACK_LIBRARIES})
check_function_exists("dsyev_" LAPACK_NEEDS_UNDERLINE)
cmake_pop_check_state()
elseif(HAVE_BLAS)
dune_register_package_flags(LIBRARIES "${BLAS_LIBRARIES}")
endif()
# add function to link against the BLAS/Lapack library
function(add_dune_blas_lapack_flags _targets)
foreach(_target ${_targets})
if(LAPACK_FOUND)
target_link_libraries(${_target} PUBLIC ${LAPACK_LIBRARIES})
elseif(BLAS_FOUND)
target_link_libraries(${_target} PUBLIC ${BLAS_LIBRARIES})
endif()
endforeach(_target)
endfunction(add_dune_blas_lapack_flags)
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
# Defines the functions to use GMP
#
# .. cmake_function:: add_dune_gmp_flags
#
# .. cmake_param:: targets
# :positional:
# :single:
# :required:
#
# A list of targets to use GMP with.
#
include_guard(GLOBAL)
# set HAVE_GMP for the config.h file
set(HAVE_GMP ${GMP_FOUND})
# register all GMP related flags
if(GMP_FOUND)
dune_register_package_flags(
LIBRARIES GMP::gmpxx
COMPILE_DEFINITIONS "HAVE_GMP=1"
)
endif()
# add function to link against the GMP library
function(add_dune_gmp_flags _targets)
if(GMP_FOUND)
foreach(_target ${_targets})
target_link_libraries(${_target} PUBLIC GMP::gmpxx)
target_compile_definitions(${_target} PUBLIC HAVE_GMP=1)
endforeach(_target ${_targets})
endif(GMP_FOUND)
endfunction(add_dune_gmp_flags)
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
# Defines the functions to use METIS
#
# .. cmake_function:: add_dune_metis_flags
#
# .. cmake_param:: targets
# :positional:
# :single:
# :required:
#
# A list of targets to use METIS with.
#
include_guard(GLOBAL)
# register HAVE_METIS for config.h
set(HAVE_METIS ${METIS_FOUND})
set(METIS_COMPILE_DEFINITIONS)
if(HAVE_METIS)
list(APPEND METIS_COMPILE_DEFINITIONS "HAVE_METIS=1")
endif()
if(HAVE_SCOTCH_METIS)
list(APPEND METIS_COMPILE_DEFINITIONS "HAVE_SCOTCH_METIS=1")
endif()
# register METIS library as dune package
if(METIS_FOUND)
dune_register_package_flags(LIBRARIES METIS::METIS
COMPILE_DEFINITIONS ${METIS_COMPILE_DEFINITIONS})
endif()
# Add function to link targets against METIS library
function(add_dune_metis_flags _targets)
if(METIS_FOUND)
foreach(_target ${_targets})
target_link_libraries(${_target} PUBLIC METIS::METIS)
target_compile_definitions(${_target} PUBLIC ${METIS_COMPILE_DEFINITIONS})
endforeach(_target)
endif()
endfunction(add_dune_metis_flags _targets)
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
# The DUNE way to compile MPI applications is to use the CXX
# compiler with MPI flags usually used for C. CXX bindings
# are deactivated to prevent ABI problems.
#
# .. cmake_function:: add_dune_mpi_flags
#
# .. cmake_param:: targets
# :single:
# :required:
# :positional:
#
# The target list to add the MPI flags to.
#
include_guard(GLOBAL)
# text for feature summary
set_package_properties("MPI" PROPERTIES
DESCRIPTION "Message Passing Interface library"
PURPOSE "Parallel programming on multiple processors")
if(MPI_C_FOUND)
set(HAVE_MPI ${MPI_C_FOUND})
dune_register_package_flags(
COMPILE_DEFINITIONS
"HAVE_MPI=1;MPICH_SKIP_MPICXX=1;OMPI_SKIP_MPICXX=1;MPI_NO_CPPBIND=1;MPIPP_H;_MPICC_H"
LIBRARIES
MPI::MPI_C)
endif()
# adds MPI flags to the targets
function(add_dune_mpi_flags)
cmake_parse_arguments(ADD_MPI "SOURCE_ONLY;OBJECT" "" "" ${ARGN}) # ignored
set(targets ${ADD_MPI_UNPARSED_ARGUMENTS})
if(MPI_C_FOUND)
foreach(target ${targets})
target_link_libraries(${target} PUBLIC MPI::MPI_C)
target_compile_definitions(${target} PUBLIC
HAVE_MPI=1 MPICH_SKIP_MPICXX=1 OMPI_SKIP_MPICXX=1 MPI_NO_CPPBIND=1 MPIPP_H _MPICC_H)
endforeach(target)
endif()
endfunction(add_dune_mpi_flags)
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
# Defines the functions to use PTScotch
#
# .. cmake_function:: add_dune_ptscotch_flags
#
# .. cmake_param:: targets
# :positional:
# :single:
# :required:
#
# A list of targets to use PTScotch with.
#
include_guard(GLOBAL)
# set HAVE_PTSCOTCH for config.h
set(HAVE_PTSCOTCH ${PTScotch_FOUND})
# register all PTScotch related flags
if(PTScotch_SCOTCH_FOUND)
dune_register_package_flags(LIBRARIES PTScotch::Scotch
COMPILE_DEFINITIONS "HAVE_SCOTCH=1")
endif()
if(PTScotch_PTSCOTCH_FOUND)
dune_register_package_flags(LIBRARIES PTScotch::PTScotch
COMPILE_DEFINITIONS "HAVE_PTSCOTCH=1")
endif()
function(add_dune_ptscotch_flags _targets)
if(PTScotch_SCOTCH_FOUND)
foreach(_target ${_targets})
target_link_libraries(${_target} PUBLIC PTScotch::Scotch)
target_compile_definitions(${_target} PUBLIC HAVE_SCOTCH=1)
endforeach(_target ${_targets})
endif()
if(PTScotch_PTSCOTCH_FOUND)
foreach(_target ${_targets})
target_link_libraries(${_target} PUBLIC PTScotch::PTScotch)
target_compile_definitions(${_target} PUBLIC HAVE_PTSCOTCH=1)
endforeach(_target ${_targets})
endif()
endfunction(add_dune_ptscotch_flags)
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
# Defines the functions to use ParMETIS
#
# .. cmake_function:: add_dune_parmetis_flags
#
# .. cmake_param:: targets
# :positional:
# :single:
# :required:
#
# A list of targets to use ParMETIS with.
#
include_guard(GLOBAL)
# set HAVE_PARMETIS for config.h
set(HAVE_PARMETIS ${ParMETIS_FOUND})
set(PARMETIS_COMPILE_DEFINITIONS)
if(HAVE_PARMETIS)
list(APPEND PARMETIS_COMPILE_DEFINITIONS "HAVE_PARMETIS=1")
endif()
if(HAVE_SCOTCH_METIS)
list(APPEND PARMETIS_COMPILE_DEFINITIONS "HAVE_PTSCOTCH_PARMETIS=1")
endif()
# register all ParMETIS related flags
if(ParMETIS_FOUND)
dune_register_package_flags(LIBRARIES ParMETIS::ParMETIS
COMPILE_DEFINITIONS ${PARMETIS_COMPILE_DEFINITIONS})
endif()
# add function to link against the ParMETIS library
function(add_dune_parmetis_flags _targets)
if(ParMETIS_FOUND)
add_dune_metis_flags(${_targets})
add_dune_mpi_flags(${_targets})
foreach(_target ${_targets})
target_link_libraries(${_target} PUBLIC ParMETIS::ParMETIS)
target_compile_definitions(${_target} PUBLIC ${PARMETIS_COMPILE_DEFINITIONS})
endforeach(_target)
endif()
endfunction(add_dune_parmetis_flags)
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
# Defines the functions to use QuadMath
#
# .. cmake_function:: add_dune_quadmath_flags
#
# .. cmake_param:: targets
# :positional:
# :single:
# :required:
#
# A list of targets to use QuadMath with.
#
include_guard(GLOBAL)
# set HAVE_QUADMATH for config.h
set(HAVE_QUADMATH ${QuadMath_FOUND})
# register the QuadMath imported target
if(QuadMath_FOUND)
dune_register_package_flags(
LIBRARIES QuadMath::QuadMath
COMPILE_DEFINITIONS "HAVE_QUADMATH=1"
)
endif()
# add function to link against QuadMath::QuadMath
function(add_dune_quadmath_flags _targets)
if(QuadMath_FOUND)
foreach(_target ${_targets})
target_link_libraries(${_target} PUBLIC QuadMath::QuadMath)
target_compile_definitions(${_target} PUBLIC HAVE_QUADMATH=1)
endforeach(_target ${_targets})
endif()
endfunction(add_dune_quadmath_flags)
This diff is collapsed.
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
# Defines the functions to use TBB
#
# .. cmake_function:: add_dune_tbb_flags
#
# .. cmake_param:: targets
# :positional:
# :single:
# :required:
#
# A list of targets to use TBB with.
#
include_guard(GLOBAL)
# set variable for config.h
set(HAVE_TBB ${TBB_FOUND})
# perform DUNE-specific setup tasks
if (TBB_FOUND)
dune_register_package_flags(
LIBRARIES TBB::tbb
)
endif()
# function for adding TBB flags to a list of targets
function(add_dune_tbb_flags _targets)
if(TBB_FOUND)
foreach(_target ${_targets})
target_link_libraries(${_target} PUBLIC TBB::tbb)
endforeach(_target)
endif()
endfunction(add_dune_tbb_flags)