Skip to content

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

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

Closed
agriyakhetarpal opened this issue Apr 24, 2024 · 6 comments

Comments

@agriyakhetarpal
Copy link
Contributor

agriyakhetarpal commented Apr 24, 2024

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.

@agriyakhetarpal
Copy link
Contributor Author

Ah, I see that there have been issues with Zig on i386 before :) based on #8 and ziglang/zig#537. I still think providing a binary through PyPI would be useful even if the release is not offering top-tier support for users, considering that the Downloads page has it.

@whitequark
Copy link
Collaborator

I still think providing a binary through PyPI would be useful even if the release is not offering top-tier support for users, considering that the Downloads page has it.

Sure--happy to merge a PR!

@whitequark
Copy link
Collaborator

I built 32-bit wheels, can you please confirm that these wheels work well? https://mega.nz/file/MlwliBoL#FtiKyeygLHczynTRKPpvexm-ET1clP-g4hHrIqaqZgY

@whitequark
Copy link
Collaborator

I didn't test them on Windows but on a 32-bit wineprefix they work fine.

@agriyakhetarpal
Copy link
Contributor Author

I think so, too. I don't have easy access to a Windows build :) thanks for the merge!

@whitequark
Copy link
Collaborator

I've uploaded both 0.11.0 and 0.12.0 win32 wheels to PyPI.

https://pypi.org/project/ziglang/0.12.0/
https://pypi.org/project/ziglang/0.11.0/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants