Skip to content

Build wheels for Windows 32-bit (i.e., ziglang-0.X.Y-py3-none-win32.whl) #18

Closed
@agriyakhetarpal

Description

@agriyakhetarpal

Description

Hi! I see on https://ziglang.org/download/ that since versions v0.10.0 and later the Zig programming language has had 32-bit binaries, and it now regularly publishes binaries for development versions of v0.13.0 at the time of writing; I wonder if it would be possible to build 32-bit Windows wheels based on those binaries and ship them with PyPI as well.

Proposed implementation

I see that make_wheels.py is used to build wheels instead of the traditional setup.py format, and no source distributions are distributed, as described in #2 – that makes sense.

I think this should be done by:

  1. adding an x86-windows key-value pair to the ZIG_PYTHON_PLATFORMS constant, and
  2. the platform tag for the wheel should then be mapped to win32 – which is the value of sysconfig.get_platform(), mostly, but it can be better extracted from wheel.bdist.wheel.get_tag in these lines:

    zig-pypi/make_wheels.py

    Lines 130 to 135 in 33c05bb

    return write_wheel(out_dir,
    name='ziglang',
    version=version,
    tag=f'py3-none-{platform}',
    metadata={
    'Summary': 'Zig is a general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.',
  3. and then these lines

    zig-pypi/make_wheels.py

    Lines 152 to 165 in 33c05bb

    def fetch_zig_version_info():
    with urllib.request.urlopen(ZIG_VERSION_INFO_URL) as request:
    return json.loads(request.read())
    def fetch_and_write_ziglang_wheels(
    outdir='dist/', zig_version='master', wheel_version_suffix='', platforms=tuple()
    ):
    Path(outdir).mkdir(exist_ok=True)
    if not platforms:
    platforms = list(ZIG_PYTHON_PLATFORMS)
    zig_versions_info = fetch_zig_version_info()
    can then download this extra platform with urllib and package the binary up into an extra wheel without ABI tags as usual.

The command-line argument parser can then work as usual, just with a new available option.

Additional context

I would be happy to implement the changes myself here – they look quite minimal, and would be happy to get a chance to contribute :) I have decided to open an issue first to gauge thoughts from maintainers and core developers.

I'm using zig cc as a build-time dependency for my Python package for cross-compiling uses, where the absence of a 32-bit Windows wheel would break building off of the source distribution (since a source distribution isn't planned or worth any use for Zig and just wheels are uploaded). I can very well remove that breakage with a conditional dependency specifier in the form of something like

[build-system]
requires = [
  "setuptools>=64",
  "wheel==0.42.0",
  "ziglang==0.11.0; platform_machine != 'x86' and platform_system == 'Windows'",
  ]
build-backend = "setuptools.build_meta"

to restrict it for just this platform and architecture (while keeping it for others), but since PyPI's Zig isn't being built from source, I thought I should really propose the addition here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions