Skip to content

Commit 016aeda

Browse files
committed
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.
1 parent cdc879e commit 016aeda

File tree

9 files changed

+75
-0
lines changed

9 files changed

+75
-0
lines changed

python/tools/BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("@semmle_code//:dist.bzl", "pack_zip")
2+
3+
pack_zip(
4+
name = "tools",
5+
srcs = glob(["**/*"]),
6+
excludes = [
7+
"BUILD.bazel",
8+
] + glob(["recorded-call-graph-metrics/**"]),
9+
prefix = "tools",
10+
visibility = ["//visibility:public"],
11+
)

python/tools/autobuild.cmd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@echo off
2+
3+
rem Legacy environment variables for the autobuild infrastructure.
4+
set LGTM_SRC=%CD%
5+
set LGTM_WORKSPACE=%CODEQL_EXTRACTOR_PYTHON_SCRATCH_DIR%
6+
7+
type NUL && python "%CODEQL_EXTRACTOR_PYTHON_ROOT%\tools\index.py"
8+
exit /b %ERRORLEVEL%

python/tools/autobuild.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
# Legacy environment variables for the autobuild infrastructure.
6+
LGTM_SRC="$(pwd)"
7+
LGTM_WORKSPACE="$CODEQL_EXTRACTOR_PYTHON_SCRATCH_DIR"
8+
export LGTM_SRC
9+
export LGTM_WORKSPACE
10+
11+
if which python3 >/dev/null; then
12+
exec python3 "$CODEQL_EXTRACTOR_PYTHON_ROOT/tools/index.py"
13+
elif which python >/dev/null; then
14+
exec python "$CODEQL_EXTRACTOR_PYTHON_ROOT/tools/index.py"
15+
else
16+
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."
17+
exit 1
18+
fi

python/tools/lgtm-scripts/index.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
py "%CODEQL_EXTRACTOR_PYTHON_ROOT%\tools\index.py"

python/tools/lgtm-scripts/index.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#! /bin/bash
2+
3+
set -eu
4+
5+
python "${CODEQL_EXTRACTOR_PYTHON_ROOT}/tools/index.py"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
py "%CODEQL_EXTRACTOR_PYTHON_ROOT%\tools\setup.py" || EXIT /B 0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#! /bin/bash
2+
3+
set -eu
4+
5+
python "${CODEQL_EXTRACTOR_PYTHON_ROOT}/tools/setup.py" || true

python/tools/pre-finalize.cmd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@echo off
2+
3+
type NUL && "%CODEQL_DIST%\codeql" database index-files ^
4+
--include-extension=.yaml ^
5+
--include-extension=.yml ^
6+
--size-limit=5m ^
7+
--language yaml ^
8+
-- ^
9+
"%CODEQL_EXTRACTOR_PYTHON_WIP_DATABASE%"
10+
11+
exit /b %ERRORLEVEL%

python/tools/pre-finalize.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
"$CODEQL_DIST/codeql" database index-files \
6+
--include-extension=.yaml \
7+
--include-extension=.yml \
8+
--size-limit=5m \
9+
--language yaml \
10+
-- \
11+
"$CODEQL_EXTRACTOR_PYTHON_WIP_DATABASE"

0 commit comments

Comments
 (0)