Skip to content

Commit 44ef9d9

Browse files
authoredDec 6, 2022
Merge pull request #1419 from github/rasmuswl/poetry-no-local-venv
python-setup: Don't allow Poetry to make venv in project
2 parents 1e8d3b8 + 3b0a2f6 commit 44ef9d9

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [UNRELEASED]
44

55
- Add a step that tries to upload a SARIF file for the workflow run when that workflow run fails. This will help better surface failed code scanning workflow runs. [#1393](https://github.com/github/codeql-action/pull/1393)
6+
- Python automatic dependency installation will no longer consider dependecy code installed in venv as user-written, for projects using Poetry that specify `virtualenvs.in-project = true` in their `poetry.toml`. [#1419](https://github.com/github/codeql-action/pull/1419).
67

78
## 2.1.35 - 01 Dec 2022
89

‎python-setup/auto_install_packages.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,17 @@ def _check_output(command, extra_env={}):
3333

3434
def install_packages_with_poetry():
3535

36-
# To handle poetry 1.2, which started to use keyring interaction MUCH more, we need
37-
# add a workaround. See
38-
# https://github.com/python-poetry/poetry/issues/2692#issuecomment-1235683370
39-
extra_poetry_env = {"PYTHON_KEYRING_BACKEND": "keyring.backends.null.Keyring"}
36+
extra_poetry_env = {
37+
# To handle poetry 1.2, which started to use keyring interaction MUCH more, we need
38+
# add a workaround. See
39+
# https://github.com/python-poetry/poetry/issues/2692#issuecomment-1235683370
40+
"PYTHON_KEYRING_BACKEND": "keyring.backends.null.Keyring",
41+
# Projects that specify `virtualenvs.in-project = true` in their poetry.toml
42+
# would get the venv created inside the repo directory, which would cause CodeQL
43+
# to consider it as user-written code. We don't want this to happen. see
44+
# https://python-poetry.org/docs/configuration/#virtualenvsin-project
45+
"POETRY_VIRTUALENVS_IN_PROJECT": "False",
46+
}
4047

4148
command = [sys.executable, '-m', 'poetry']
4249
if sys.platform.startswith('win32'):
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[virtualenvs]
2+
in-project = true

0 commit comments

Comments
 (0)
Please sign in to comment.