diff --git a/bin/dunepackaging.py b/bin/dunepackaging.py index 80072d8fb15c765035ca8018a9f60fe91be22627..ced05816c83b3f60ef9955cb1e9b74099d6a9352 100755 --- a/bin/dunepackaging.py +++ b/bin/dunepackaging.py @@ -117,6 +117,12 @@ def main(argv): print("Please install the pip package 'scikit-build' to build the source distribution.") sys.exit(2) + # append hash of current git commit to README + 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 @@ -129,6 +135,10 @@ def main(argv): gitreset = ['git', 'reset', 'setup.py', 'pyproject.toml'] subprocess.call(gitreset) + # checkout README.md + gitcheckout = ['git', 'checkout', 'README.md'] + subprocess.call(gitcheckout) + if not onlysdist: # check if we have twine import pkg_resources diff --git a/bin/setup-dunepy.py b/bin/setup-dunepy.py index 4a5de840227222dd853723dff1fd3d166fdc00d8..ea66ea97c8532a66452cea392c8fc820bf70f5e8 100755 --- a/bin/setup-dunepy.py +++ b/bin/setup-dunepy.py @@ -21,7 +21,7 @@ except ImportError: sys.path.append(modsA) if os.path.exists(os.path.join(modsB, "module.py")): from module import build_dune_py_module, get_dune_py_dir, make_dune_py_module, select_modules, resolve_dependencies, resolve_order - from locking import Lock + from locking import Lock, LOCK_EX else: raise @@ -50,9 +50,9 @@ def main(argv): sys.exit(2) elif opt in ("-o", "--opts"): optsfile = arg - elif opt in ("--builddir"): + elif opt in ("--builddir",): builddir = arg - elif opt in ("--module"): + elif opt in ("--module",): masterModule = arg if len(args) > 0: execute = args[0] diff --git a/python/dune/common/module.py b/python/dune/common/module.py index 6418092e310147d8884a438e2436a6b70b6770e0..2f347076b14152719319da8fb20bb50cb59adf56 100644 --- a/python/dune/common/module.py +++ b/python/dune/common/module.py @@ -396,7 +396,21 @@ def build_dune_py_module(dune_py_dir=None, cmake_args=None, build_args=None, bui prefix = {} for name, dir in dirs.items(): if is_installed(dir, name): - prefix[name] = os.path.join(get_prefix(name),'lib','cmake',name) + found = False + # switch prefix to location of name-config.cmake + for l in ['lib','lib32','lib64']: + substr = l + '/cmake' + newpath = dir.replace('lib/dunecontrol', substr) + for _, _, files in os.walk(newpath): + # if name-config.cmake is found + # then this is the correct folder + if name+'-config.cmake' in files: + found = True + prefix[name] = newpath + break + if found: break + assert found + # store new module path else: prefix[name] = default_build_dir(dir, name, builddir) diff --git a/python/dune/create.py b/python/dune/create.py index 0fff9e73db8f75aa47e730ed40dade71fac18956..0357e0e92e8c5d88babbd33e887c10c0e7908906 100644 --- a/python/dune/create.py +++ b/python/dune/create.py @@ -36,7 +36,7 @@ for importer, modname, ispkg in pkgutil.iter_modules(package.__path__, prefix): moduleRegistry = module.registry.items() logMsg = logMsg + modname + " " except AttributeError: - logger.debug('module ' + modname + ' does not provide a registry.') + logger.debug('Module ' + modname + ' does not provide a registry.') continue # combine all registries diff --git a/python/dune/generator/builder.py b/python/dune/generator/builder.py index b96b02e07763bb1d3f876662b3f07a260d84bba8..2cdd2beefb581e6dec9d079f306edcb77cd17406 100644 --- a/python/dune/generator/builder.py +++ b/python/dune/generator/builder.py @@ -32,7 +32,7 @@ class Builder: # create .noconfigure to disable configuration for future calls open(tagfile, 'a').close() else: - logger.debug('using pre configured dune-py module') + logger.debug('Using pre configured dune-py module') comm.barrier() self.build_args = dune.common.module.get_default_build_args() @@ -66,9 +66,8 @@ class Builder: cmake_args += ["--"] + make_args cmake = subprocess.Popen(cmake_args, cwd=self.generated_dir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = cmake.communicate() - logger.debug(buffer_to_str(stdout)) + logger.debug("Compiler output: "+buffer_to_str(stdout)) if cmake.returncode > 0: - logger.error(buffer_to_str(stderr)) raise CompileError(buffer_to_str(stderr)) if self.savedOutput is not None: out = buffer_to_str(stdout) @@ -113,10 +112,16 @@ class Builder: code = str(source) with open(os.path.join(sourceFileName), 'w') as out: out.write(code) - with open(os.path.join(self.generated_dir, "CMakeLists.txt"), 'a') as out: - out.write(line+"\n") - # update build system - self.compile() + if not found: + with open(os.path.join(self.generated_dir, "CMakeLists.txt"), 'a') as out: + out.write(line+"\n") + # update build system + logger.debug("Rebuilding module") + try: + self.compile() + except KeyboardInterrupt: + os.remove(os.path.join(sourceFileName)) + raise elif isString(source) and not source == open(os.path.join(sourceFileName), 'r').read(): logger.info("Compiling " + pythonName + " (updated)") code = str(source) @@ -135,6 +140,7 @@ class Builder: with Lock(os.path.join(self.dune_py_dir, 'lock-module.lock'), flags=LOCK_SH): # lock generated module with Lock(os.path.join(self.dune_py_dir, 'lock-'+moduleName+'.lock'), flags=LOCK_EX): + logger.debug("Now compiling "+moduleName) self.compile(moduleName) ## end if module is not None diff --git a/python/dune/packagemetadata.py b/python/dune/packagemetadata.py index d4799121e1b41842b3147af0860743b29018e8a0..54f7509181d7ef450f9e16ef664568c705f17eb1 100755 --- a/python/dune/packagemetadata.py +++ b/python/dune/packagemetadata.py @@ -382,7 +382,6 @@ def metaData(version=None, dependencyCheck=True): setupParams['cmdclass'] = { 'build_py': DunepyConfigure, - 'sdist': DuneBuildSdist } return data, setupParams