Skip to content

Commit

Permalink
chore: use StrEnum from Python 3.11
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Feb 12, 2025
1 parent e450e86 commit 9a44319
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:
hooks:
- id: mypy
name: mypy 3.11 on cibuildwheel/
exclude: ^cibuildwheel/resources/.*py|bin/generate_schema.py$
exclude: ^cibuildwheel/resources/.*py$
args: ["--python-version=3.11"]
additional_dependencies: &mypy-dependencies
- bracex
Expand Down
39 changes: 14 additions & 25 deletions cibuildwheel/architecture.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from __future__ import annotations

import functools
import platform as platform_module
import re
import shutil
import subprocess
import sys
from collections.abc import Set
from enum import Enum
from enum import StrEnum, auto
from typing import Final, Literal, assert_never

from .typing import PlatformName
Expand Down Expand Up @@ -39,38 +38,28 @@ def _check_aarch32_el0() -> bool:
return check.returncode == 0 and check.stdout.startswith("armv")


@functools.total_ordering
class Architecture(Enum):
value: str

class Architecture(StrEnum):
# mac/linux archs
x86_64 = "x86_64"
x86_64 = auto()

# linux archs
i686 = "i686"
aarch64 = "aarch64"
ppc64le = "ppc64le"
s390x = "s390x"
armv7l = "armv7l"
i686 = auto()
aarch64 = auto()
ppc64le = auto()
s390x = auto()
armv7l = auto()

# mac archs
universal2 = "universal2"
arm64 = "arm64"
universal2 = auto()
arm64 = auto()

# windows archs
x86 = "x86"
AMD64 = "AMD64"
ARM64 = "ARM64"
x86 = auto()
AMD64 = auto()
ARM64 = auto()

# WebAssembly
wasm32 = "wasm32"

# Allow this to be sorted
def __lt__(self, other: Architecture) -> bool:
return self.value < other.value

def __str__(self) -> str:
return self.name
wasm32 = auto()

@staticmethod
def parse_config(config: str, platform: PlatformName) -> set[Architecture]:
Expand Down

0 comments on commit 9a44319

Please sign in to comment.