Skip to content

Commit

Permalink
fix(plugins/poetry): set --no-binary=:all: by param
Browse files Browse the repository at this point in the history
This moves the environment variable configuration to use a parameter.
This is needed because pip does not load environment variables in a
deterministic order, but the order of these parameters matters.

Requires canonical/craft-parts#940

Fixes #2025

CRAFT-3794
  • Loading branch information
lengau committed Dec 16, 2024
1 parent 7615a1c commit 28880d8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion charmcraft/parts/plugins/_poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"""Charmcraft-specific poetry plugin."""

import pathlib
import shlex
from pathlib import Path

from craft_parts.plugins import poetry_plugin
Expand Down Expand Up @@ -55,10 +56,11 @@ def _get_pip_install_commands(self, requirements_path: pathlib.Path) -> list[str
:returns: A list of strings forming the install script.
"""
pip = self._get_pip()
pip_extra_args = shlex.join(self._options.poetry_pip_extra_args)
return [
# These steps need to be separate because poetry export defaults to including
# hashes, which don't work with installing from a directory.
f"{pip} install --no-deps '--requirement={requirements_path}'",
f"{pip} install --no-deps --no-binary=:all: {pip_extra_args} '--requirement={requirements_path}'",
# Check that the virtualenv is consistent.
f"{pip} check",
]
Expand Down
4 changes: 3 additions & 1 deletion charmcraft/parts/plugins/_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ class PythonPlugin(python_plugin.PythonPlugin):

@override
def get_build_environment(self) -> dict[str, str]:
return utils.extend_python_build_environment(super().get_build_environment())
return {
"PIP_NO_BINARY": ":all:",
} | utils.extend_python_build_environment(super().get_build_environment())

@override
def _get_venv_directory(self) -> Path:
Expand Down
1 change: 0 additions & 1 deletion charmcraft/utils/parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def extend_python_build_environment(environment: dict[str, str]) -> dict[str, st
:returns: the environment dictionary with charmcraft-specific additions.
"""
return environment | {
"PIP_NO_BINARY": ":all:", # Build from source
"PARTS_PYTHON_VENV_ARGS": "--without-pip",
}

Expand Down

0 comments on commit 28880d8

Please sign in to comment.