From 127b4d230df081a96ead8aa48b29c62adc50caa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=B6rl?= Date: Fri, 1 Sep 2023 10:01:28 +0200 Subject: [PATCH] allow to define eqasim commit via configuration (#196) --- matsim/runtime/eqasim.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/matsim/runtime/eqasim.py b/matsim/runtime/eqasim.py index 207a8f21..a8c44d1d 100644 --- a/matsim/runtime/eqasim.py +++ b/matsim/runtime/eqasim.py @@ -11,7 +11,8 @@ def configure(context): context.stage("matsim.runtime.maven") context.config("eqasim_version", "1.3.1") - context.config("eqasim_branch", "upstream") + context.config("eqasim_tag", None) + context.config("eqasim_commit", "de0009a") context.config("eqasim_repository", "https://github.com/eqasim-org/eqasim-java.git") context.config("eqasim_path", "") @@ -34,14 +35,21 @@ def execute(context): # Clone repository and checkout version git.run(context, [ "clone", context.config("eqasim_repository"), - "--branch", context.config("eqasim_branch"), - "--single-branch", "eqasim-java", - "--depth", "1" + "--filter=tree:0", "eqasim-java" ]) + # Select the configured commit or tag + commit = context.config("eqasim_commit") + tag = context.config("eqasim_tag") + checkout = commit if commit is not None else tag + assert checkout is not None + + git.run(context, [ + "checkout", checkout + ], cwd = "{}/eqasim-java".format(context.path())) + # Build eqasim maven.run(context, ["-Pstandalone", "--projects", "ile_de_france", "--also-make", "package", "-DskipTests=true"], cwd = "%s/eqasim-java" % context.path()) - jar_path = "%s/eqasim-java/ile_de_france/target/ile_de_france-%s.jar" % (context.path(), version) # Special case: We provide the jar directly. This is mainly used for # creating input to unit tests of the eqasim-java package. @@ -60,5 +68,12 @@ def validate(context): if not os.path.exists(path): raise RuntimeError("Cannot find eqasim at: %s" % path) + + if context.config("eqasim_tag") is None: + if context.config("eqasim_commit") is None: + raise RuntimeError("Either eqasim commit or tag must be defined") + + if (context.config("eqasim_tag") is None) == (context.config("eqasim_commit") is None): + raise RuntimeError("Eqasim commit and tag must not be defined at the same time") return os.path.getmtime(path)