Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix arm support #482

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions okonomiyaki/platforms/epd_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
_ARCHBITS_TO_ARCH = {
"32": ArchitectureKind.x86.name,
"64": _X86_64_LEGACY_SPEC,
ArchitectureKind.x86: ArchitectureKind.x86.name,
ArchitectureKind.x86_64: _X86_64_LEGACY_SPEC,
}

# Historically supported platform names for EDP
Expand Down Expand Up @@ -175,10 +173,11 @@ def from_string(cls, s, runtime_version=None):
d = m.groupdict()
platform_name = d["os"]
arch_bits = d["arch"]
if arch_bits not in _ARCHBITS_TO_ARCH:
try:
arch_name = _ARCHBITS_TO_ARCH[arch_bits]
except KeyError:
arch = machine = Arch.from_name(arch_bits)
else:
arch_name = _ARCHBITS_TO_ARCH[arch_bits]
arch = machine = Arch.from_name(arch_name)
os, name, family, release = _epd_name_and_python_to_quadruplet(
platform_name, runtime_version, arch)
Expand Down Expand Up @@ -385,7 +384,7 @@ def applies(platform_string, to='current'):

def _parse_component(component):
component = component.strip()
parts = component.split("-")
parts = component.split("-", 1)
if len(parts) == 1:
if parts[0] in VALID_PLATFORMS_FILTER:
return parts[0], None
Expand All @@ -395,13 +394,13 @@ def _parse_component(component):
raise ValueError(
"Invalid filter string: '{}'".format(component))
elif len(parts) == 2:
check = (
parts[0] not in VALID_PLATFORMS_FILTER
or parts[1] not in _ARCHBITS_TO_ARCH)
if check:
raise ValueError(
"Invalid filter string: '{}'".format(component))
return parts[0], parts[1]
try:
arch_name = _ARCHBITS_TO_ARCH[parts[1]]
except KeyError:
arch = machine = Arch.from_name(parts[1])
else:
arch = machine = Arch.from_name(arch_name)
return parts[0], arch
else:
raise ValueError(
"Invalid filter string: '{}'".format(component))
Expand All @@ -416,20 +415,19 @@ def _are_compatible(short_left, short_right):
if to == 'current':
full = EPDPlatform.from_running_system()
to_platform = full.platform_name
to_arch_bits = full.arch_bits
to_arch = full.arch
elif '-' in to:
full = EPDPlatform.from_epd_string(to)
to_platform = full.platform_name
to_arch_bits = full.arch_bits
to_arch = full.arch
else:
if not (to in PLATFORM_NAMES or to == 'rh'):
raise ValueError("Invalid 'to' argument: {0!r}".format(to))
to_platform = to
to_arch_bits = None
to_arch = None
else:
to_platform = to.platform_name
to_arch_bits = to.arch_bits

to_arch = to.arch
conditions = []

platform_string = platform_string.strip()
Expand All @@ -441,12 +439,12 @@ def _are_compatible(short_left, short_right):

platform_strings = [s for s in platform_string.split(",")]
for platform_string in platform_strings:
short, bits = _parse_component(platform_string)
short, arch = _parse_component(platform_string)
if _are_compatible(short, to_platform):
if bits is None:
if arch is None:
conditions.append(True)
else:
conditions.append(bits == to_arch_bits or to_arch_bits is None)
conditions.append(arch == to_arch or to_arch is None)
else:
conditions.append(False)

Expand Down
Loading