Skip to content

Commit

Permalink
feat: upgrade minimum pip version (#1716)
Browse files Browse the repository at this point in the history
  • Loading branch information
lengau authored Jul 10, 2024
1 parent 775a0fc commit def89c5
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
13 changes: 10 additions & 3 deletions charmcraft/charm_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@
validate_strict_dependencies,
)

MINIMUM_PIP_VERSION = (23, 0)
KNOWN_GOOD_PIP_URL = "https://files.pythonhosted.org/packages/ba/19/e63fb4e0d20e48bd2167bb7e857abc0e21679e24805ba921a224df8977c0/pip-23.2.1.tar.gz"
MINIMUM_PIP_VERSION = (24, 1)
KNOWN_GOOD_PIP_URL = "https://files.pythonhosted.org/packages/c0/d0/9641dc7b05877874c6418f8034ddefc809495e65caa14d38c7551cd114bb/pip-24.1.1.tar.gz"
KNOWN_GOOD_PIP_HASH = "sha256:5aa64f65e1952733ee0a9a9b1f52496ebdb3f3077cc46f80a16d983b58d1180a"


def relativise(src, dst):
Expand Down Expand Up @@ -237,7 +238,13 @@ def _install_dependencies(self, staging_venv_dir):
# common charm dependencies (e.g. ops). Resolve this by updating to a
# known working version of pip.
if get_pip_version(pip_cmd) < MINIMUM_PIP_VERSION:
_process_run([pip_cmd, "install", f"pip@{KNOWN_GOOD_PIP_URL}"])
_process_run(
[
pip_cmd,
"install",
f"pip@{KNOWN_GOOD_PIP_URL}",
]
)

with instrum.Timer("Installing all dependencies"):
if self.strict_dependencies:
Expand Down
40 changes: 35 additions & 5 deletions tests/test_charm_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,13 @@ def test_build_dependencies_virtualenv_simple(tmp_path, assert_output):

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",
f"pip@{KNOWN_GOOD_PIP_URL}",
]
),
call([pip_cmd, "install", f"--requirement={reqs_file}"]),
]

Expand Down Expand Up @@ -649,7 +655,13 @@ 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",
f"pip@{KNOWN_GOOD_PIP_URL}",
]
),
call(
[
pip_cmd,
Expand Down Expand Up @@ -712,7 +724,13 @@ def test_build_dependencies_virtualenv_packages(tmp_path, assert_output):

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",
f"pip@{KNOWN_GOOD_PIP_URL}",
]
),
call([pip_cmd, "install", "--no-binary=pkg1,pkg2", "pkg1", "pkg2"]),
]

Expand Down Expand Up @@ -747,7 +765,13 @@ def test_build_dependencies_virtualenv_binary_packages(tmp_path, assert_output):

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",
f"pip@{KNOWN_GOOD_PIP_URL}",
]
),
call([pip_cmd, "install", "pkg1", "pkg2"]),
]

Expand Down Expand Up @@ -788,7 +812,13 @@ def test_build_dependencies_virtualenv_all(tmp_path, assert_output):

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",
f"pip@{KNOWN_GOOD_PIP_URL}",
]
),
call(
[
pip_cmd,
Expand Down

0 comments on commit def89c5

Please sign in to comment.