Skip to content

Commit 6ce38be

Browse files
authored
Merge pull request #16112 from github/tausbn/python-various-extractor-fixups
Python: Various extractor fixups
2 parents bd1de17 + ef9f99b commit 6ce38be

File tree

6 files changed

+11
-720
lines changed

6 files changed

+11
-720
lines changed

python/extractor/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ py_binary(
55
srcs = [
66
"make_zips.py",
77
"python_tracer.py",
8-
"unparse.py",
98
],
109
data = [
1110
"LICENSE-PSF.md",

python/extractor/licenses.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
| `tsg-python/tree-sitter-python` | Y | MIT | Used in `tsg-python` to parse Python files |
77
| `tsg-python` | Y | MIT / Apache | This is our own creation, so are free to choose what license it is covered by. |
88
| `tree-sitter-graph` | N | MIT / Apache | Used in `tsg-python` to execute files written in the `tree-sitter-graph` language. |
9-
| `unparse.py` | Y | PSF | Copied and adapted from `Tools/unparse.py` from the `cpython` source code, with attribution. |
109
| `imp.py` | Y | PSF | Copied and adapted from `Lib/imp.py` from the `cpython` source code, with attribution. |
1110
| `semmle/data/*.trap` | Y | PSF | These files were derived from the C source code of the `cpython` project, and are used in our modelling of built-in objects. No attribution, currently. |
1211
| `semmle/thrift/parse.py` | Y | Apache | Includes a grammar based on https://github.com/apache/thrift/blob/master/doc/specs/idl.md, with comment stating this attribution. |

python/extractor/make_zips.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import compileall
99

1010
from python_tracer import getzipfilename
11-
from unparse import strip_comments_and_docstrings
1211

1312
# TO DO -- Add options to set destination directory and source directory
1413

@@ -84,9 +83,7 @@ def write_source(zipped, root, name, extensions=[".py"]):
8483
if ext not in extensions:
8584
continue
8685
path = os.path.join(dirpath, name)
87-
temp = strip_comments_and_docstrings(path)
88-
zipped.write(temp, os.path.relpath(path, root))
89-
os.remove(temp)
86+
zipped.write(path, os.path.relpath(path, root))
9087

9188
def main():
9289
parser = optparse.OptionParser(usage = "usage: %prog [install-dir]")

python/extractor/tsg-python/Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ authors = ["Taus Brock-Nannestad <[email protected]>"]
77
edition = "2018"
88

99
# When changing/updating these, the `Cargo.Bazel.lock` file has to be regenerated.
10-
# Check out the documentation at https://bazelbuild.github.io/rules_rust/crate_universe.html#repinning--updating-dependencies
11-
# for how to do so. The bazel repository for the tsg-python project is called `py_deps`,
12-
# and instead of calling `bazel sync`, `./build --bazel sync` should be used instead, to always use the correct bazel version.
10+
# Run `CARGO_BAZEL_REPIN=true CARGO_BAZEL_REPIN_ONLY=py_deps ./build --bazel sync --only=py_deps`
11+
# in the `semmle-code` repository to do so.
12+
# For more information, check out the documentation at
13+
# https://bazelbuild.github.io/rules_rust/crate_universe.html#repinning--updating-dependencies
14+
# In the future, the hope is to move this handling of the dependencies entirely into the `codeql` repository,
15+
# but that depends on `rules_rust` being fully compatible with bzlmod, which they aren't yet
16+
# (c.f. https://github.com/bazelbuild/rules_rust/issues/2452).
17+
# Warning: The process takes >5min on my M1 mac, so do wait for a while.
1318
[dependencies]
1419
anyhow = "1.0"
1520
regex = "1"

python/extractor/tsg-python/tsp/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ package(default_visibility = ["//visibility:public"])
77
# This will run the build script from the root of the workspace, and
88
# collect the outputs.
99
cargo_build_script(
10-
name = "tsg-build",
10+
name = "tsp-build",
1111
srcs = ["bindings/rust/build.rs"],
1212
data = glob([
1313
"src/**",
@@ -32,7 +32,7 @@ rust_library(
3232
proc_macro_deps = all_crate_deps(
3333
proc_macro = True,
3434
),
35-
deps = [":tsg-build"] + all_crate_deps(
35+
deps = [":tsp-build"] + all_crate_deps(
3636
normal = True,
3737
),
3838
)

0 commit comments

Comments
 (0)