Skip to content

Commit

Permalink
chore: get arch translations from craft-platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
lengau committed Jul 24, 2024
1 parent e0312ee commit df21007
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 18 deletions.
4 changes: 3 additions & 1 deletion charmcraft/application/commands/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from operator import attrgetter
from typing import TYPE_CHECKING, Any

import craft_platforms
import yaml
from craft_application import util
from craft_cli import ArgumentParsingError, emit
Expand Down Expand Up @@ -2009,7 +2010,8 @@ def run(self, parsed_args: argparse.Namespace) -> int:
)

image_arch = [
utils.ARCH_TRANSLATIONS.get(arch, arch) for arch in image_metadata.architectures
craft_platforms.DebianArchitecture.from_machine(arch).value
for arch in image_metadata.architectures
]
bases = [{"name": "all", "channel": "all", "architectures": image_arch}]

Expand Down
2 changes: 0 additions & 2 deletions charmcraft/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
humanize_list,
)
from charmcraft.utils.platform import (
ARCH_TRANSLATIONS,
OSPlatform,
get_os_platform,
validate_architectures,
Expand Down Expand Up @@ -77,7 +76,6 @@
"get_lib_info",
"get_libs_from_tree",
"collect_charmlib_pydeps",
"ARCH_TRANSLATIONS",
"OSPlatform",
"get_os_platform",
"validate_architectures",
Expand Down
15 changes: 1 addition & 14 deletions charmcraft/utils/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,7 @@ class OSPlatform:
machine: str


# translations from what the platform module informs to the term deb and
# snaps actually use
ARCH_TRANSLATIONS = {
"aarch64": "arm64",
"armv7l": "armhf",
"i686": "i386",
"ppc": "powerpc",
"ppc64le": "ppc64el",
"x86_64": "amd64",
"AMD64": "amd64", # Windows support
}


def get_os_platform(filepath=pathlib.Path("/etc/os-release")):
def get_os_platform(filepath: pathlib.Path = pathlib.Path("/etc/os-release")) -> OSPlatform:
"""Determine a system/release combo for an OS using /etc/os-release if available."""
system = platform.system()
release = platform.release()
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dependencies = [
"craft-application~=3.0",
"craft-cli>=2.3.0",
"craft-parts>=1.18",
"craft-platforms~=0.1",
"craft-providers>=1.23.0",
"craft-store>=2.4",
"distro>=1.3.0",
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ craft-archives==1.2.0
craft-cli==2.6.0
craft-grammar==1.2.0
craft-parts==1.33.0
craft-platforms==0.1.1
craft-providers==1.24.1
craft-store==2.6.2
cryptography==42.0.8
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ craft-archives==1.2.0
craft-cli==2.6.0
craft-grammar==1.2.0
craft-parts==1.33.0
craft-platforms==0.1.1
craft-providers==1.24.1
craft-store==2.6.2
cryptography==42.0.8
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from craft_providers import Executor, Provider, bases

import charmcraft.parts
from charmcraft import const, deprecations, instrum, parts, services, store, utils
from charmcraft import const, deprecations, instrum, parts, services, store
from charmcraft.application.main import APP_METADATA
from charmcraft.bases import get_host_as_base
from charmcraft.models import charmcraft as config_module
Expand Down

0 comments on commit df21007

Please sign in to comment.