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

fix(charm_builder): force-install pip #1892

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions charmcraft/charm_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def _install_dependencies(self, staging_venv_dir: pathlib.Path):
[
pip_cmd,
"install",
"--force-reinstall",
f"pip@{KNOWN_GOOD_PIP_URL}",
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_charm_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ def test_build_dependencies_virtualenv(

assert mock.mock_calls == [
call(["python3", "-m", "venv", str(tmp_path / const.STAGING_VENV_DIRNAME)]),
call([pip_cmd, "install", f"pip@{KNOWN_GOOD_PIP_URL}"]),
call([pip_cmd, "install", "--force-reinstall", f"pip@{KNOWN_GOOD_PIP_URL}"]),
*extra_pip_calls,
]

Expand Down Expand Up @@ -771,7 +771,7 @@ def test_build_dependencies_virtualenv_multiple(tmp_path, assert_output):
pip_cmd = str(charm_builder._find_venv_bin(tmp_path / const.STAGING_VENV_DIRNAME, "pip"))
assert mock.mock_calls == [
call(["python3", "-m", "venv", str(tmp_path / const.STAGING_VENV_DIRNAME)]),
call([pip_cmd, "install", f"pip@{KNOWN_GOOD_PIP_URL}"]),
call([pip_cmd, "install", "--force-reinstall", f"pip@{KNOWN_GOOD_PIP_URL}"]),
call(
[
pip_cmd,
Expand Down
9 changes: 8 additions & 1 deletion tests/unit/utils/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,14 @@ def test_get_pip_command(

@pytest.mark.parametrize(
("pip_cmd", "stdout", "expected"),
[("pip", "pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)\n", (22, 0, 2))],
[
("pip", "pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)\n", (22, 0, 2)),
(
"venv/bin/pip",
"pip 20.0.2 from /root/venv/lib/python3.8/site-packages/pip (python 3.8)",
(20, 0, 2),
),
],
)
def test_get_pip_version_success(
fake_process,
Expand Down
Loading