-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Pex emitting warnings about its Pip PEX venv. (#1351)
Previously we'd see: ``` rm -rf ~/.pex $ pex pex -cpex -opex.pex /home/jsirois/.venv/pex/lib/python3.9/site-packages/pex/tools/commands/venv.py:141: PEXWarning: Encountered collision building venv at /home/jsirois/.pex/venvs/short/4bd8ddd4 from /home/jsirois/.pex/pip.pex/46820cb5af0dcf9295a4e7f30184cc0e9fa063dc: 1. /home/jsirois/.pex/venvs/7fbdc9731d96d42f0de338b2dfbc6bbed1c938e7/832e95f85413646e8b7b056ab4e60414f83d7397.01034f69a38943809913ffdfd28dd5bf/lib/python3.9/site-packages/constraints.txt was provided by: /home/jsirois/.pex/pip.pex/46820cb5af0dcf9295a4e7f30184cc0e9fa063dc/.deps/setuptools/constraints.txt /home/jsirois/.pex/pip.pex/46820cb5af0dcf9295a4e7f30184cc0e9fa063dc/.deps/wheel/constraints.txt pex_warnings.warn(message) ```
- Loading branch information
Showing
4 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import absolute_import | ||
|
||
import os | ||
import warnings | ||
|
||
from pex.interpreter import PythonInterpreter | ||
from pex.pip import Pip | ||
from pex.typing import TYPE_CHECKING | ||
from pex.variables import ENV | ||
|
||
if TYPE_CHECKING: | ||
from typing import Any | ||
|
||
|
||
def test_no_duplicate_constraints_pex_warnings(tmpdir): | ||
# type: (Any) -> None | ||
pex_root = os.path.join(str(tmpdir), "pex_root") | ||
pip_root = os.path.join(str(tmpdir), "pip_root") | ||
interpreter = PythonInterpreter.get() | ||
platform = interpreter.platform | ||
|
||
with ENV.patch(PEX_ROOT=pex_root), warnings.catch_warnings(record=True) as events: | ||
pip = Pip.create(path=pip_root, interpreter=interpreter) | ||
|
||
pip.spawn_debug( | ||
platform=platform.platform, impl=platform.impl, version=platform.version, abi=platform.abi | ||
).wait() | ||
|
||
assert 0 == len([event for event in events if "constraints.txt" in str(event)]), ( | ||
"Expected no duplicate constraints warnings to be emitted when creating a Pip venv but " | ||
"found\n{}".format("\n".join(map(str, events))) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters