Skip to content

Commit 212b200

Browse files
authored
build(deps): use craft-application 2.0.0 (#1596)
1 parent c6e5d54 commit 212b200

File tree

13 files changed

+50
-32
lines changed

13 files changed

+50
-32
lines changed

charmcraft/application/commands/lifecycle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"""craft-application based lifecycle commands."""
1717
from __future__ import annotations
1818

19-
import os
2019
import pathlib
20+
import sys
2121
import textwrap
2222
from typing import TYPE_CHECKING, cast
2323

@@ -168,9 +168,9 @@ def run_managed(self, parsed_args: argparse.Namespace) -> bool:
168168
"""
169169
project_dir = pathlib.Path(getattr(parsed_args, "project_dir", "."))
170170
charmcraft_yaml = utils.load_yaml(project_dir / "charmcraft.yaml")
171-
# Always use a runner on non-posix platforms.
171+
# Always use a runner on non-Linux platforms.
172172
# Craft-parts is not designed to work on non-posix platforms, and most
173173
# notably here, the bundle plugin doesn't work on Windows.
174-
if os.name == "posix" and charmcraft_yaml and charmcraft_yaml.get("type") == "bundle":
174+
if sys.platform == "linux" and charmcraft_yaml and charmcraft_yaml.get("type") == "bundle":
175175
return False
176176
return super().run_managed(parsed_args)

charmcraft/application/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,11 @@ def _extra_yaml_transform(
101101

102102
return yaml_data
103103

104-
def _configure_services(self, platform: str | None, build_for: str | None) -> None:
105-
super()._configure_services(platform, build_for)
104+
def _configure_services(self, provider_name: str | None) -> None:
105+
super()._configure_services(provider_name)
106106
self.services.set_kwargs(
107107
"package",
108108
project_dir=self.project_dir,
109-
platform=platform,
110109
build_plan=self._build_plan,
111110
)
112111

charmcraft/services/package.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,11 @@ def __init__(
6262
services: CharmcraftServiceFactory,
6363
*,
6464
project_dir: pathlib.Path,
65-
platform: str | None,
6665
build_plan: list[craft_application.models.BuildInfo],
6766
) -> None:
6867
super().__init__(app, services, project=cast(craft_application.models.Project, project))
6968
self.project_dir = project_dir.resolve(strict=True)
70-
self._platform = platform
69+
self._platform = build_plan[0].platform
7170
self._build_plan = build_plan
7271

7372
def pack(self, prime_dir: pathlib.Path, dest: pathlib.Path) -> list[pathlib.Path]:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "charmcraft"
33
description = "The main tool to build, upload, and develop in general the Juju charms."
44
dynamic = ["version", "readme"]
55
dependencies = [
6-
"craft-application @ git+https://github.com/canonical/craft-application@main",
6+
"craft-application~=2.0",
77
"craft-cli>=2.3.0",
88
"craft-parts>=1.18",
99
"craft-providers>=1.23.0",

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ certifi==2024.2.2
33
cffi==1.16.0
44
charset-normalizer==3.3.2
55
coverage==7.4.2
6-
craft-application @ git+https://github.com/canonical/craft-application@main
6+
craft-application==2.0.0
77
craft-archives==1.1.3
88
craft-cli==2.5.1
99
craft-grammar==1.1.2

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ attrs==23.2.0
22
certifi==2024.2.2
33
cffi==1.16.0
44
charset-normalizer==3.3.2
5-
craft-application @ git+https://github.com/canonical/craft-application@main
5+
craft-application==2.0.0
66
craft-archives==1.1.3
77
craft-cli==2.5.1
88
craft-grammar==1.1.2

tests/conftest.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020-2023 Canonical Ltd.
1+
# Copyright 2020-2024 Canonical Ltd.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -30,11 +30,12 @@
3030
import pytest
3131
import responses as responses_module
3232
import yaml
33+
from craft_application import models
3334
from craft_parts import callbacks, plugins
34-
from craft_providers import Executor, Provider
35+
from craft_providers import Executor, Provider, bases
3536

3637
import charmcraft.parts
37-
from charmcraft import const, deprecations, instrum, parts, services
38+
from charmcraft import const, deprecations, instrum, parts, services, utils
3839
from charmcraft.application.main import APP_METADATA
3940
from charmcraft.bases import get_host_as_base
4041
from charmcraft.models import charmcraft as config_module
@@ -71,6 +72,19 @@ def service_factory(
7172
return factory
7273

7374

75+
@pytest.fixture()
76+
def default_build_plan():
77+
arch = utils.get_host_architecture()
78+
return [
79+
models.BuildInfo(
80+
base=bases.BaseName("ubuntu", "22.04"),
81+
build_on=arch,
82+
build_for=arch,
83+
platform="distro-1-test64",
84+
)
85+
]
86+
87+
7488
@pytest.fixture()
7589
def fake_project_dir(fs) -> pathlib.Path:
7690
project_dir = pathlib.Path("/root/project")

tests/integration/commands/test_pack.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727

2828
@pytest.mark.xfail(
29-
sys.platform == "win32", reason="https://github.com/canonical/charmcraft/issues/1552"
29+
sys.platform != "linux", reason="https://github.com/canonical/charmcraft/issues/1552"
3030
)
3131
@pytest.mark.parametrize(
3232
"bundle_yaml",
@@ -35,15 +35,16 @@
3535
"name: my-bundle",
3636
],
3737
)
38-
def test_build_basic_bundle(monkeypatch, app, new_path, bundle_yaml):
38+
def test_build_basic_bundle(monkeypatch, capsys, app, new_path, bundle_yaml):
3939
(new_path / "charmcraft.yaml").write_text("type: bundle")
4040
(new_path / "bundle.yaml").write_text(bundle_yaml)
4141

4242
monkeypatch.setenv("CRAFT_DEBUG", "1")
4343
monkeypatch.setattr("sys.argv", ["charmcraft", "pack"])
4444

4545
app.configure({})
46-
app.run()
46+
if app.run() != 0:
47+
raise ValueError(capsys.readouterr())
4748

4849
with zipfile.ZipFile("bundle.zip") as bundle_zip:
4950
actual_bundle_yaml = bundle_zip.read("bundle.yaml").decode()

tests/integration/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def service_factory():
3434
def app(monkeypatch, service_factory):
3535
monkeypatch.setenv("CRAFT_DEBUG", "1")
3636
app = application.Charmcraft(app=application.APP_METADATA, services=service_factory)
37-
app._configure_services(None, None)
37+
app._configure_services(None)
3838
commands.fill_command_groups(app)
3939

4040
return app

tests/integration/services/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def service_factory(fs, fake_path, simple_charm) -> services.CharmcraftServiceFa
2929

3030
app = Charmcraft(app=APP_METADATA, services=factory)
3131

32-
app._configure_services(platform=None, build_for=None)
32+
app._configure_services(provider_name=None)
3333

3434
factory.project = simple_charm
3535

0 commit comments

Comments
 (0)