Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/ensurepip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# policies recommend against bundling dependencies. For example, Fedora
# installs wheel packages in the /usr/share/python-wheels/ directory and don't
# install the ensurepip._bundled package.
if (_pkg_dir := sysconfig.get_config_var('WHEEL_PKG_DIR')) is not None:
if (_pkg_dir := sysconfig.get_config_var('WHEEL_PKG_DIR')) is not None and _pkg_dir:
Comment thread
vstinner marked this conversation as resolved.
Outdated
_WHEEL_PKG_DIR = Path(_pkg_dir).resolve()
else:
_WHEEL_PKG_DIR = None
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_ensurepip.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def test_version_no_dir(self):
# when the bundled pip wheel is used, we get _PIP_VERSION
self.assertEqual(ensurepip._PIP_VERSION, ensurepip.version())

def test_empty_wheel_pkg_dir_treated_as_none(self):
# GH#146310: empty string WHEEL_PKG_DIR should not search CWD.
# An empty WHEEL_PKG_DIR converts to Path('.') which would
# incorrectly search the current working directory.
with unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', None):
self.assertIsNone(ensurepip._find_wheel_pkg_dir_pip())
Comment thread
vstinner marked this conversation as resolved.
Outdated

def test_selected_wheel_path_no_dir(self):
pip_filename = f'pip-{ensurepip._PIP_VERSION}-py3-none-any.whl'
with unittest.mock.patch.object(ensurepip, '_WHEEL_PKG_DIR', None):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :mod:`ensurepip` to treat an empty string ``WHEEL_PKG_DIR`` as unset,
preventing it from searching the current working directory for wheel files.
Comment thread
vstinner marked this conversation as resolved.
Outdated
Loading