Skip to content

Commit

Permalink
refactor: cleanup from @joerick
Browse files Browse the repository at this point in the history
  • Loading branch information
henryiii committed Jan 31, 2021
1 parent 9ae1272 commit e14d13d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Options
|---|--------|-------------|
| **Build selection** | [`CIBW_PLATFORM`](https://cibuildwheel.readthedocs.io/en/stable/options/#platform) | Override the auto-detected target platform |
| | [`CIBW_BUILD`](https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip) <br> [`CIBW_SKIP`](https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip) | Choose the Python versions to build |
| | [`CIBW_ARCHS`](https://cibuildwheel.readthedocs.io/en/stable/options/#archs) | Control available architectures |
| | [`CIBW_ARCHS`](https://cibuildwheel.readthedocs.io/en/stable/options/#archs) | Change the architectures built on your machine by default |
| | [`CIBW_PROJECT_REQUIRES_PYTHON`](https://cibuildwheel.readthedocs.io/en/stable/options/#requires-python) | Manually set the Python compatibility of your project |
| **Build customization** | [`CIBW_ENVIRONMENT`](https://cibuildwheel.readthedocs.io/en/stable/options/#environment) | Set environment variables needed during the build |
| | [`CIBW_BEFORE_ALL`](https://cibuildwheel.readthedocs.io/en/stable/options/#before-all) | Execute a shell command on the build system before any wheels are built. |
Expand Down
26 changes: 9 additions & 17 deletions cibuildwheel/architecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,16 @@ def all_archs(platform: PlatformName) -> 'Set[Architecture]':
assert_never(platform)

@staticmethod
def bitiness_archs(platform: PlatformName, bitiness: Literal["64", "32"]) -> 'Set[Architecture]':
native_architecture = Architecture(platform_module.machine())

if native_architecture in {Architecture.x86_64, Architecture.aarch64, Architecture.ppc64le, Architecture.s390x, Architecture.AMD64}:
if bitiness == "64":
return {native_architecture}
else:
if native_architecture == Architecture.x86_64 and platform != "macos":
return {Architecture.i686}
elif native_architecture == Architecture.AMD64:
return {Architecture.x86}
else:
return set()
elif native_architecture in {Architecture.i686, Architecture.x86}:
return {native_architecture} if bitiness == "32" else set()
def bitiness_archs(platform: PlatformName, bitiness: Literal['64', '32']) -> 'Set[Architecture]':
archs_32 = {Architecture.i686, Architecture.x86}
auto_archs = Architecture.auto_archs(platform)

if bitiness == '64':
return auto_archs - archs_32
elif bitiness == '32':
return auto_archs & archs_32
else:
# assert_never doesn't work here, oddly, maybe due to set checking above
raise RuntimeError("Cannot be reached")
assert_never(bitiness)


def allowed_architectures_check(
Expand Down
22 changes: 10 additions & 12 deletions docs/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,21 @@ Options:
- macOS: `x86_64` `arm64` `universal2`
- Windows: `AMD64` `x86`
- `auto`: The default archs for your machine - see the table below.
- `auto64`: Just the 64-bit auto archs (will result in an empty set on a 32-bit runner)
- `auto32`: Just the 32-bit auto archs (will result in an empty set on macOS)
- `auto64`: Just the 64-bit auto archs
- `auto32`: Just the 32-bit auto archs
- `native`: the native arch of the build machine - Matches [`platform.machine()`](https://docs.python.org/3/library/platform.html#platform.machine).
- `all` : expands to all the architectures supported on this OS. You may want
to use [CIBW_BUILD](#build-skip) with this option to target specific
architectures via build selectors.

Default: `auto`

| Runner | `native` | `auto`
|---|---|---
| Linux / Intel | `x86_64` | `x86_64` `i686`
| Windows / Intel | `AMD64` | `AMD64` `x86`
| macOS / Intel | `x86_64` | `x86_64`
| macOS / Apple Silicon | `arm64` | `arm64` `universal2`
| Runner | `native` | `auto` | `auto64` | `auto32` |
|---|---|---|---|---|
| Linux / Intel | `x86_64` | `x86_64` `i686` | `x86_64` | `i686` |
| Windows / Intel | `AMD64` | `AMD64` `x86` | `AMD64` | `x86` |
| macOS / Intel | `x86_64` | `x86_64` | `x86_64` | |
| macOS / Apple Silicon | `arm64` | `arm64` `universal2` | `arm64` `universal2`| |

If not listed above, `auto` is the same as `native`.

Expand All @@ -196,6 +196,8 @@ If not listed above, `auto` is the same as `native`.
Platform-specific variants also available:<br/>
`CIBW_ARCHS_MACOS` | `CIBW_ARCHS_WINDOWS` | `CIBW_ARCHS_LINUX`

This option can also be set using the [command-line option](#command-line) `--archs`.

#### Examples

```yaml
Expand All @@ -208,10 +210,6 @@ CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
CIBW_ARCHS_LINUX: "auto aarch64"
```
Platform-specific variants also available:<br/>
`CIBW_ARCHS_MACOS` | `CIBW_ARCHS_WINDOWS` | `CIBW_ARCHS_LINUX`

This option can also be set using the [command-line option](#command-line) `--archs`.
### `CIBW_PROJECT_REQUIRES_PYTHON` {: #requires-python}
> Manually set the Python compatibility of your project
Expand Down

0 comments on commit e14d13d

Please sign in to comment.