Skip to content

Commit

Permalink
Prevent Poetry from trying to read system keyrings
Browse files Browse the repository at this point in the history
Prevent Poetry from trying to read system keyrings and failing
(specifically reading Windows keyring from an SSH session fails
with "A specified logon session does not exist.")
  • Loading branch information
elprans committed Oct 21, 2024
1 parent d51319f commit 23a84b3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion metapkg/tools/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Any,
)

import os
import pathlib
import subprocess

Expand Down Expand Up @@ -79,7 +80,19 @@ def update_repo(
# Origin URL has changed, perform a full clone.
clean_checkout = True

GitBackend.clone(repo_url, revision=ref, clean=clean_checkout)
old_keyring_backend = os.environ.get("PYTHON_KEYRING_BACKEND")
try:
# Prevent Poetry from trying to read system keyrings and failing
# (specifically reading Windows keyring from an SSH session fails
# with "A specified logon session does not exist.")
os.environ["PYTHON_KEYRING_BACKEND"] = "keyring.backends.null.Keyring"
GitBackend.clone(repo_url, revision=ref, clean=clean_checkout)
finally:
if old_keyring_backend is None:
os.environ.pop("PYTHON_KEYRING_BACKEND")
else:
os.environ["PYTHON_KEYRING_BACKEND"] = old_keyring_backend

repo_dir = repodir(repo_url)
repo = Git(repo_dir)
args: tuple[str | pathlib.Path, ...]
Expand Down

0 comments on commit 23a84b3

Please sign in to comment.