Python: Add create-extractor-pack.sh for Python#21683
Open
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.
Contributor
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.
Suggested change
| # error, then move the zip back. | |
| # error, then copy the zip back. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.