From e91efaa92effb73d240b6b9766fe7eb391b69d90 Mon Sep 17 00:00:00 2001 From: Rasmus Lerchedahl Petersen Date: Thu, 11 Apr 2024 16:02:49 +0200 Subject: [PATCH] python: do not extract stdlib by default --- .../cli-integration-test/extract-stdlib/test.sh | 4 ++-- python/extractor/semmle/cmdline.py | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/python/extractor/cli-integration-test/extract-stdlib/test.sh b/python/extractor/cli-integration-test/extract-stdlib/test.sh index 6a61becd25c..937cf08ce43 100755 --- a/python/extractor/cli-integration-test/extract-stdlib/test.sh +++ b/python/extractor/cli-integration-test/extract-stdlib/test.sh @@ -13,10 +13,10 @@ rm -rf dbs mkdir dbs -CODEQL_EXTRACTOR_PYTHON_DONT_EXTRACT_STDLIB=True $CODEQL database create dbs/without-stdlib --language python --source-root repo_dir/ +$CODEQL database create dbs/without-stdlib --language python --source-root repo_dir/ $CODEQL query run --database dbs/without-stdlib query.ql > query.without-stdlib.actual diff query.without-stdlib.expected query.without-stdlib.actual -LGTM_INDEX_EXCLUDE="/usr/lib/**" $CODEQL database create dbs/with-stdlib --language python --source-root repo_dir/ +LGTM_INDEX_EXCLUDE="/usr/lib/**" CODEQL_EXTRACTOR_PYTHON_EXTRACT_STDLIB=True $CODEQL database create dbs/with-stdlib --language python --source-root repo_dir/ $CODEQL query run --database dbs/with-stdlib query.ql > query.with-stdlib.actual diff query.with-stdlib.expected query.with-stdlib.actual diff --git a/python/extractor/semmle/cmdline.py b/python/extractor/semmle/cmdline.py index 9c2ff4a3274..79f974279bc 100644 --- a/python/extractor/semmle/cmdline.py +++ b/python/extractor/semmle/cmdline.py @@ -102,8 +102,10 @@ def make_parser(): config_options.add_option("--colorize", dest="colorize", default=False, action="store_true", help = """Colorize the logging output.""") - config_options.add_option("--dont-extract-stdlib", dest="extract_stdlib", default=True, action="store_false", - help="Do not extract the standard library.") + config_options.add_option("--dont-extract-stdlib", dest="extract_stdlib", action="store_false", + help="This flag is deprecated; not extracting the standard library is now the default.") + config_options.add_option("--extract-stdlib", dest="extract_stdlib", default=False, action="store_true", + help="Extract the standard library.") parser.add_option_group(config_options) @@ -226,8 +228,16 @@ def parse(command_line): if 'CODEQL_EXTRACTOR_PYTHON_DONT_EXTRACT_STDLIB' in os.environ: options.extract_stdlib = False + print ("Warning: CODEQL_EXTRACTOR_PYTHON_DONT_EXTRACT_STDLIB is deprecated; the default is now to not extract the standard library.") + + if 'CODEQL_EXTRACTOR_PYTHON_EXTRACT_STDLIB' in os.environ: + options.extract_stdlib = True options.prune = True + + if options.extract_stdlib: + print ("Warning: The analysis will extract the standard library. This behavior is deprecated and will be removed in a future release. We expect it to be gone in CLI version 2.20.0.") + return options, args def split_and_flatten(options_list, div):