From 016aedab0aba50e6a7007e537de7f2a10e3b0d11 Mon Sep 17 00:00:00 2001 From: Taus Date: Thu, 7 Mar 2024 13:33:58 +0000 Subject: [PATCH] Python: Move Python language pack tooling to external repo This is essentially the contents of `language-packs/python/tools` with some minor modifications to account for the changed location. Of note: we explicitly exclude the `recorded-call-graph-metrics` director that was already present in `python/tools`. When we revisit this directory for some cleanup (e.g. to get rid of the `lgtm` references), we'll probably want to switch to an explicit list of sources to include. --- python/tools/BUILD.bazel | 11 +++++++++++ python/tools/autobuild.cmd | 8 ++++++++ python/tools/autobuild.sh | 18 ++++++++++++++++++ python/tools/lgtm-scripts/index.cmd | 3 +++ python/tools/lgtm-scripts/index.sh | 5 +++++ python/tools/lgtm-scripts/python_setup.cmd | 3 +++ python/tools/lgtm-scripts/python_setup.sh | 5 +++++ python/tools/pre-finalize.cmd | 11 +++++++++++ python/tools/pre-finalize.sh | 11 +++++++++++ 9 files changed, 75 insertions(+) create mode 100644 python/tools/BUILD.bazel create mode 100644 python/tools/autobuild.cmd create mode 100755 python/tools/autobuild.sh create mode 100644 python/tools/lgtm-scripts/index.cmd create mode 100755 python/tools/lgtm-scripts/index.sh create mode 100644 python/tools/lgtm-scripts/python_setup.cmd create mode 100755 python/tools/lgtm-scripts/python_setup.sh create mode 100644 python/tools/pre-finalize.cmd create mode 100755 python/tools/pre-finalize.sh diff --git a/python/tools/BUILD.bazel b/python/tools/BUILD.bazel new file mode 100644 index 00000000000..81762c150fb --- /dev/null +++ b/python/tools/BUILD.bazel @@ -0,0 +1,11 @@ +load("@semmle_code//:dist.bzl", "pack_zip") + +pack_zip( + name = "tools", + srcs = glob(["**/*"]), + excludes = [ + "BUILD.bazel", + ] + glob(["recorded-call-graph-metrics/**"]), + prefix = "tools", + visibility = ["//visibility:public"], +) diff --git a/python/tools/autobuild.cmd b/python/tools/autobuild.cmd new file mode 100644 index 00000000000..051d119f9ec --- /dev/null +++ b/python/tools/autobuild.cmd @@ -0,0 +1,8 @@ +@echo off + +rem Legacy environment variables for the autobuild infrastructure. +set LGTM_SRC=%CD% +set LGTM_WORKSPACE=%CODEQL_EXTRACTOR_PYTHON_SCRATCH_DIR% + +type NUL && python "%CODEQL_EXTRACTOR_PYTHON_ROOT%\tools\index.py" +exit /b %ERRORLEVEL% diff --git a/python/tools/autobuild.sh b/python/tools/autobuild.sh new file mode 100755 index 00000000000..88134d120fd --- /dev/null +++ b/python/tools/autobuild.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -eu + +# Legacy environment variables for the autobuild infrastructure. +LGTM_SRC="$(pwd)" +LGTM_WORKSPACE="$CODEQL_EXTRACTOR_PYTHON_SCRATCH_DIR" +export LGTM_SRC +export LGTM_WORKSPACE + +if which python3 >/dev/null; then + exec python3 "$CODEQL_EXTRACTOR_PYTHON_ROOT/tools/index.py" +elif which python >/dev/null; then + exec python "$CODEQL_EXTRACTOR_PYTHON_ROOT/tools/index.py" +else + echo "ERROR: Could not find a valid Python distribution. It should be available when running 'which python' or 'which python3' in your shell. Python 2 is no longer supported." + exit 1 +fi diff --git a/python/tools/lgtm-scripts/index.cmd b/python/tools/lgtm-scripts/index.cmd new file mode 100644 index 00000000000..254f4472262 --- /dev/null +++ b/python/tools/lgtm-scripts/index.cmd @@ -0,0 +1,3 @@ +@echo off + +py "%CODEQL_EXTRACTOR_PYTHON_ROOT%\tools\index.py" diff --git a/python/tools/lgtm-scripts/index.sh b/python/tools/lgtm-scripts/index.sh new file mode 100755 index 00000000000..f57637260b0 --- /dev/null +++ b/python/tools/lgtm-scripts/index.sh @@ -0,0 +1,5 @@ +#! /bin/bash + +set -eu + +python "${CODEQL_EXTRACTOR_PYTHON_ROOT}/tools/index.py" diff --git a/python/tools/lgtm-scripts/python_setup.cmd b/python/tools/lgtm-scripts/python_setup.cmd new file mode 100644 index 00000000000..0abc4c21dcf --- /dev/null +++ b/python/tools/lgtm-scripts/python_setup.cmd @@ -0,0 +1,3 @@ +@echo off + +py "%CODEQL_EXTRACTOR_PYTHON_ROOT%\tools\setup.py" || EXIT /B 0 diff --git a/python/tools/lgtm-scripts/python_setup.sh b/python/tools/lgtm-scripts/python_setup.sh new file mode 100755 index 00000000000..9e398d11bd3 --- /dev/null +++ b/python/tools/lgtm-scripts/python_setup.sh @@ -0,0 +1,5 @@ +#! /bin/bash + +set -eu + +python "${CODEQL_EXTRACTOR_PYTHON_ROOT}/tools/setup.py" || true diff --git a/python/tools/pre-finalize.cmd b/python/tools/pre-finalize.cmd new file mode 100644 index 00000000000..07454671062 --- /dev/null +++ b/python/tools/pre-finalize.cmd @@ -0,0 +1,11 @@ +@echo off + +type NUL && "%CODEQL_DIST%\codeql" database index-files ^ + --include-extension=.yaml ^ + --include-extension=.yml ^ + --size-limit=5m ^ + --language yaml ^ + -- ^ + "%CODEQL_EXTRACTOR_PYTHON_WIP_DATABASE%" + +exit /b %ERRORLEVEL% diff --git a/python/tools/pre-finalize.sh b/python/tools/pre-finalize.sh new file mode 100755 index 00000000000..9fe5200a38f --- /dev/null +++ b/python/tools/pre-finalize.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -eu + +"$CODEQL_DIST/codeql" database index-files \ + --include-extension=.yaml \ + --include-extension=.yml \ + --size-limit=5m \ + --language yaml \ + -- \ + "$CODEQL_EXTRACTOR_PYTHON_WIP_DATABASE"