From cb49eedd8dc584d91aa43c3e511c2c07c8d5d506 Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Tue, 15 Aug 2023 18:24:20 -0300 Subject: [PATCH 1/4] requirements: update craft-parts to 1.23.1 Craft Parts 1.23.1 addresses issues related to version being set twice during rebuilds. Signed-off-by: Claudio Matsuoka --- docs/requirements.txt | 2 +- requirements-devel.txt | 2 +- requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 8d7e7eaf05..c83e2f4894 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -4,7 +4,7 @@ click==8.1.3 craft-archives==1.1.0 craft-cli==2.0.0 craft-grammar==1.1.1 -craft-parts==1.22.0 +craft-parts==1.23.1 craft-providers==1.13.0 craft-store==2.4.0 Deprecated==1.2.13 diff --git a/requirements-devel.txt b/requirements-devel.txt index c25c80eb5d..9aa24354f1 100644 --- a/requirements-devel.txt +++ b/requirements-devel.txt @@ -14,7 +14,7 @@ coverage==7.2.5 craft-archives==1.1.3 craft-cli==2.0.0 craft-grammar==1.1.1 -craft-parts==1.21.1 +craft-parts==1.23.1 craft-providers==1.13.0 craft-store==2.4.0 cryptography==41.0.3 diff --git a/requirements.txt b/requirements.txt index 7335675b4a..4aa077f5db 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ click==8.1.3 craft-archives==1.1.3 craft-cli==2.0.0 craft-grammar==1.1.1 -craft-parts==1.21.1 +craft-parts==1.23.1 craft-providers==1.13.0 craft-store==2.4.0 cryptography==41.0.3 From d5f9b892c3343a0c139e40999e2102d29d55bbbe Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Wed, 16 Aug 2023 16:12:32 -0300 Subject: [PATCH 2/4] plugins: update python plugin test Signed-off-by: Claudio Matsuoka --- tests/unit/parts/plugins/test_python_plugin.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/unit/parts/plugins/test_python_plugin.py b/tests/unit/parts/plugins/test_python_plugin.py index e44a511ba8..242777264e 100644 --- a/tests/unit/parts/plugins/test_python_plugin.py +++ b/tests/unit/parts/plugins/test_python_plugin.py @@ -75,10 +75,16 @@ def test_get_build_commands(plugin, new_dir): set +e install_dir="{new_dir}/parts/my-part/install/usr/bin" stage_dir="{new_dir}/stage/usr/bin" - payload_python=$(find "$install_dir" "$stage_dir" -type f -executable -name "python3.*" -print -quit 2>/dev/null) + + # look for the right Python version - if the venv was created with python3.10, + # look for python3.10 + basename=$(basename $(readlink -f ${{PARTS_PYTHON_VENV_INTERP_PATH}})) + echo Looking for a Python interpreter called \\"${{basename}}\\" in the payload... + payload_python=$(find "$install_dir" "$stage_dir" -type f -executable -name "${{basename}}" -print -quit 2>/dev/null) if [ -n "$payload_python" ]; then # We found a provisioned interpreter, use it. + echo Found interpreter in payload: \\"${{payload_python}}\\" installed_python="${{payload_python##{new_dir}/parts/my-part/install}}" if [ "$installed_python" = "$payload_python" ]; then # Found a staged interpreter. @@ -89,6 +95,7 @@ def test_get_build_commands(plugin, new_dir): fi else # Otherwise use what _get_system_python_interpreter() told us. + echo "Python interpreter not found in payload." symlink_target="/usr/bin/python3.10" fi From ab554f76611568e042e3e8a40a8954b7c6e3ee52 Mon Sep 17 00:00:00 2001 From: Tiago Nobrega Date: Tue, 22 Aug 2023 14:37:55 -0300 Subject: [PATCH 3/4] requirements: bump some craft libs These are updates to use the new "streaming brief" feature from craft-cli, but the feature itself is not enabled by this commit. --- requirements-devel.txt | 6 +++--- requirements.txt | 6 +++--- snapcraft/commands/lint.py | 6 +++--- tests/unit/conftest.py | 11 +++++++++++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/requirements-devel.txt b/requirements-devel.txt index 9aa24354f1..c578b987a1 100644 --- a/requirements-devel.txt +++ b/requirements-devel.txt @@ -12,10 +12,10 @@ codespell==2.2.4 colorama==0.4.6 coverage==7.2.5 craft-archives==1.1.3 -craft-cli==2.0.0 +craft-cli==2.1.0 craft-grammar==1.1.1 -craft-parts==1.23.1 -craft-providers==1.13.0 +craft-parts==1.24.0 +craft-providers==1.15.0 craft-store==2.4.0 cryptography==41.0.3 Deprecated==1.2.13 diff --git a/requirements.txt b/requirements.txt index 4aa077f5db..e31d2a7a55 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,10 +6,10 @@ chardet==5.1.0 charset-normalizer==3.1.0 click==8.1.3 craft-archives==1.1.3 -craft-cli==2.0.0 +craft-cli==2.1.0 craft-grammar==1.1.1 -craft-parts==1.23.1 -craft-providers==1.13.0 +craft-parts==1.24.0 +craft-providers==1.15.0 craft-store==2.4.0 cryptography==41.0.3 Deprecated==1.2.13 diff --git a/snapcraft/commands/lint.py b/snapcraft/commands/lint.py index f5dd41fc98..0fd62e6a91 100644 --- a/snapcraft/commands/lint.py +++ b/snapcraft/commands/lint.py @@ -23,7 +23,7 @@ import tempfile import textwrap from contextlib import contextmanager -from pathlib import Path +from pathlib import Path, PurePosixPath from typing import Iterator, Optional from craft_cli import BaseCommand, emit @@ -309,7 +309,7 @@ def _install_snap( is_dangerous = not bool(assert_file) if assert_file: - ack_command = snap_cmd.formulate_ack_command(assert_file) + ack_command = snap_cmd.formulate_ack_command(PurePosixPath(assert_file)) emit.progress( f"Installing assertion file with {shlex.join(ack_command)!r}." ) @@ -327,7 +327,7 @@ def _install_snap( install_command = snap_cmd.formulate_local_install_command( classic=bool(snap_metadata.confinement == "classic"), dangerous=is_dangerous, - snap_path=snap_file, + snap_path=PurePosixPath(snap_file), ) if snap_metadata.grade == "devel": install_command.append("--devmode") diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 76dcff35b6..82a615cd2e 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -25,6 +25,7 @@ import yaml from craft_providers import Executor, Provider from craft_providers.base import Base +from overrides import override from pymacaroons import Caveat, Macaroon from snapcraft.extensions import extension, register, unregister @@ -326,6 +327,16 @@ def fake_provider(mock_instance): class FakeProvider(Provider): """Fake provider.""" + @property + @override + def name(self) -> str: + return "fake" + + @property + @override + def install_recommendation(self) -> str: + return "uninstallable" + def clean_project_environments(self, *, instance_name: str): pass From e1491d1da1d9b5cd145de27a29280107222d19d9 Mon Sep 17 00:00:00 2001 From: Tiago Nobrega Date: Tue, 22 Aug 2023 14:38:40 -0300 Subject: [PATCH 4/4] cli: enable "streaming brief" mode Fixes #4317 --- snapcraft/cli.py | 1 + snapcraft/parts/lifecycle.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/snapcraft/cli.py b/snapcraft/cli.py index 94d22caf6a..2ca423e63f 100644 --- a/snapcraft/cli.py +++ b/snapcraft/cli.py @@ -201,6 +201,7 @@ def get_dispatcher() -> craft_cli.Dispatcher: appname="snapcraft", greeting=f"Starting Snapcraft {__version__}", log_filepath=log_filepath, + streaming_brief=True, ) return craft_cli.Dispatcher( diff --git a/snapcraft/parts/lifecycle.py b/snapcraft/parts/lifecycle.py index 6fb3ceb3c6..fe4d1758d9 100644 --- a/snapcraft/parts/lifecycle.py +++ b/snapcraft/parts/lifecycle.py @@ -377,7 +377,7 @@ def _run_lifecycle_and_pack( version=process_version(project.version), target_arch=project.get_build_for(), ) - emit.message(f"Created snap package {snap_filename}") + emit.progress(f"Created snap package {snap_filename}", permanent=True) def _generate_metadata(