diff --git a/etc/build.props b/etc/build.props --- a/etc/build.props +++ b/etc/build.props @@ -1,16 +1,17 @@ title = AFP/Tools module = $AFP_BASE/tools/lib/classes/afp_tools.jar requirements = \ env:ISABELLE_SCALA_JAR sources = \ tools/admin/afp_build_hugo.scala \ tools/admin/afp_build_python.scala \ tools/migration/afp_migrate_metadata.scala \ tools/afp_build_site.scala \ tools/afp_check_roots.scala \ tools/afp_dependencies.scala \ tools/afp_tool.scala \ tools/metadata.scala \ + tools/python.scala \ tools/toml.scala \ tools/utils.scala services = afp.Tools diff --git a/tools/python.scala b/tools/python.scala new file mode 100644 --- /dev/null +++ b/tools/python.scala @@ -0,0 +1,21 @@ +package afp + + +import isabelle._ + + +object Python +{ + val python_home = Isabelle_System.getenv("ISABELLE_PYTHON") + + val python_path = (Path.explode("$AFP_BASE") + Path.make(List("admin", "sitegen-lib"))).absolute + + def run(command: String): Process_Result = + { + val exec = + Path.explode(proper_string(python_home).getOrElse("No python component found")) + + Path.make(List("bin", "python3")) + Isabelle_System.bash(exec.implode + " -c '" + command + "'", + env = Isabelle_System.settings(List("PYTHONPATH" -> python_path.implode))) + } +}