Skip to content

Commit

Permalink
Fix incompatibility with cibuildwheel for 32-bit Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Jun 5, 2022
1 parent 5174504 commit 841b2db
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions maturin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"""

import os
import platform
import shlex
import shutil
import subprocess
import sys
import struct
from subprocess import SubprocessError
from typing import Dict

Expand All @@ -34,6 +36,15 @@ def get_maturin_pep517_args():
return args


def _additional_pep517_args():
# Support building for 32-bit Python on x64 Windows
if platform.system().lower() == "windows" and platform.machine().lower() == "amd64":
pointer_width = struct.calcsize("P") * 8
if pointer_width == 32:
return ["--target", "i686-pc-windows-msvc"]
return []


# noinspection PyUnusedLocal
def _build_wheel(
wheel_directory, config_settings=None, metadata_directory=None, editable=False
Expand All @@ -49,8 +60,10 @@ def _build_wheel(
"--compatibility",
"off",
]
command.extend(_additional_pep517_args())
if editable:
command.append("--editable")

pep517_args = get_maturin_pep517_args()
if pep517_args:
command.extend(pep517_args)
Expand Down Expand Up @@ -151,6 +164,7 @@ def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
"--interpreter",
sys.executable,
]
command.extend(_additional_pep517_args())
pep517_args = get_maturin_pep517_args()
if pep517_args:
command.extend(pep517_args)
Expand Down

0 comments on commit 841b2db

Please sign in to comment.