Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env: prevent warning from being emitted on venv creation #420

Merged
merged 4 commits into from Jan 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/build/env.py
Expand Up @@ -92,7 +92,9 @@ def __enter__(self) -> IsolatedEnv:

:return: The isolated build environment
"""
self._path = tempfile.mkdtemp(prefix='build-env-')
# ``realpath`` is used to prevent warning from being emitted that
# the venv location has moved on Windows.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to vague (and potentially misleading because the location does not actually move; the warning is due to a misidentification of the location.

I’d say something like Call realpath so venv does not incorrectly identify equivalent path forms as different locations on Windows with a reference to the b.p.o. issue entry.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expanded the text and linked to the issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback :)

self._path = os.path.realpath(tempfile.mkdtemp(prefix='build-env-'))
try:
# use virtualenv when available (as it's faster than venv)
if _should_use_virtualenv():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_env.py
Expand Up @@ -112,7 +112,7 @@ def test_isolated_env_log(mocker, caplog, package_test_flit):
('INFO', 'Installing packages in isolated environment... (something)'),
]
if sys.version_info >= (3, 8): # stacklevel
assert [(record.lineno) for record in caplog.records] == [105, 102, 193]
assert [(record.lineno) for record in caplog.records] == [105, 104, 195]


@pytest.mark.isolated
Expand Down