Python: Add create-extractor-pack.sh for Python#21683
Conversation
This allows us to build and test the extractor (for actual QL extraction -- not just the extractor unit tests) entirely from within the `github/codeql` repo, just as we do with Ruby. All that's needed is a `--search-path` argument that points to the repo root.
There was a problem hiding this comment.
Pull request overview
Adds a repository-local script to build a Python extractor pack from source so extraction and QL tests can be run from within github/codeql using --search-path (mirroring the Ruby workflow).
Changes:
- Introduce
python/scripts/create-extractor-pack.shto buildtsg-python, generatepython3src.zip, and assemblepython/extractor-pack. - Package Python extractor tools/scripts, dbscheme files, and downgrades into the generated extractor pack.
Show a summary per file
| File | Description |
|---|---|
| python/scripts/create-extractor-pack.sh | New script to build and assemble a local Python extractor pack for use via --search-path. |
Copilot's findings
Comments suppressed due to low confidence (1)
python/scripts/create-extractor-pack.sh:34
make_zips.pyalready writesextractor/python3src.zipin the source directory before copying it to the provided output dir, so copying it back from$tmpdiris redundant. Consider dropping thiscpand just use the zip generated inextractor/(keeping the temp output dir only to avoid SameFileError inshutil.copy).
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
(cd extractor && python3 make_zips.py "$tmpdir")
cp "$tmpdir/python3src.zip" extractor/python3src.zip
- Files reviewed: 1/1 changed files
- Comments generated: 1
| # Generate python3src.zip from the Python extractor source. | ||
| # make_zips.py creates the zip in the source directory and then copies it to the | ||
| # given output directory. We use a temporary directory to avoid a same-file copy | ||
| # error, then move the zip back. |
There was a problem hiding this comment.
The comment says the zip is moved back, but the script actually copies it. Please update the comment to match the behavior (or switch to mv if that’s the intent).
This issue also appears on line 31 of the same file.
| # error, then move the zip back. | |
| # error, then copy the zip back. |
jketema
left a comment
There was a problem hiding this comment.
This looks sensible.
Not enough to block merging this, but I would expect this to hold for some of the other extractors that live in this repo too. So, I wonder whether there's a more generic approach where we move some of our internal code over to this repo cc @github/code-scanning-engine-quality
This allows us to build and test the extractor (for actual QL extraction -- not just the extractor unit tests) entirely from within the
github/codeqlrepo, just as we do with Ruby. All that's needed is a--search-pathargument that points to the repo root.