Skip to content

Commit

Permalink
charm_build: install binary packages with no special options
Browse files Browse the repository at this point in the history
Option `--prefer-binary` is only available in pip 20.x and bionic
installs 9.x. Options are to update pip to a newer version and keep
using `--prefer-binary`; change the option to `--only-binary` (in
this case installation of packages only available in source form
or depending on packages only available in source form would fail); or
not specify any option related to binary installation (which would
result in installation from source if tha latest version of a package
is only available in source form, which is a possible situation but
likely to be a corner case). This commit implements the third
solution.

Signed-off-by: Claudio Matsuoka <[email protected]>
  • Loading branch information
cmatsuoka committed Nov 3, 2021
1 parent f263485 commit 21eb612
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions charmcraft/charm_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ def handle_dependencies(self):
_process_run([pip_cmd, "--version"])

if self.binary_python_packages:
# install binary python packages
cmd = [pip_cmd, "install", "--upgrade", "--prefer-binary"] # base command
# install python packages, allowing binary packages
cmd = [pip_cmd, "install", "--upgrade"] # base command
for pkg in self.binary_python_packages:
cmd.append(pkg) # the python package to install
_process_run(cmd)
Expand Down
4 changes: 2 additions & 2 deletions charmcraft/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class CharmPlugin(plugins.Plugin):
- ``charm-binary-python-packages``
(list of strings)
A list of python packages to install from PyPI before installing
requirements. Binary packages are preferred, but they may also be
installed from sources if a package is only available in source format.
requirements. Binary packages are allowed, but they may also be
installed from sources if a package is only available in source form.
- ``charm-python-packages``
(list of strings)
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 @@ -730,7 +730,7 @@ def test_build_dependencies_virtualenv_binary_packages(tmp_path):
assert mock.mock_calls == [
call(["python3", "-m", "venv", str(tmp_path / STAGING_VENV_DIRNAME)]),
call([pip_cmd, "--version"]),
call([pip_cmd, "install", "--upgrade", "--prefer-binary", "pkg1", "pkg2"]),
call([pip_cmd, "install", "--upgrade", "pkg1", "pkg2"]),
]

site_packages_dir = charm_builder._find_venv_site_packages(pathlib.Path(STAGING_VENV_DIRNAME))
Expand Down Expand Up @@ -762,7 +762,7 @@ def test_build_dependencies_virtualenv_all(tmp_path):
assert mock.mock_calls == [
call(["python3", "-m", "venv", str(tmp_path / STAGING_VENV_DIRNAME)]),
call([pip_cmd, "--version"]),
call([pip_cmd, "install", "--upgrade", "--prefer-binary", "pkg1", "pkg2"]),
call([pip_cmd, "install", "--upgrade", "pkg1", "pkg2"]),
call([pip_cmd, "install", "--upgrade", "--no-binary", ":all:", "pkg3", "pkg4"]),
call(
[
Expand Down

0 comments on commit 21eb612

Please sign in to comment.