Skip to content
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

maint: add CI jobs to build and test a Windows wheel #26

Merged
merged 1 commit into from
Dec 11, 2022

Conversation

oscarbenjamin
Copy link
Collaborator

This adds a script to build a wheel on Windows amd64 using mingw-w64 under msys2 based on the recipe discussed in #1. Another CI job will test the installed wheel.

The resulting wheel is broken because of at least #10 if not other problems as well. With this though it should at least in principle be possible to see in CI whether or not the module works on Windows.

I haven't integrated this with the other build scripts yet although mostly this leverages the existing bin/build_dependencies_unix.sh script. Currently this changes setup.py which it probably shouldn't so I should come up with a better solution for that before this is merged (presumably someone is depending on that Windows specific code in the setup.py). I don't think it's worth trying to integrate building Windows wheels with the other cibuildwheel setup until at least it is possible to build a working wheel on Windows.

Both setup.py, distutils and numpy.distutils are deprecated and numpy.distutils will apparently be removed in Python 3.12. A better fix for the build system would be to use build as a frontend:
https://pypa-build.readthedocs.io/en/latest/
Then the backend would be something like meson-python or cmake I guess:
https://labs.quansight.org/blog/2021/07/moving-scipy-to-meson
If eventually a future build system will be used it's probably better to leave setup.py alone so that it can continue to work for anyone who is still using it.

Once I've reverted the changes to setup.py I suggest:

  1. Merge this so that Windows is tested in CI.
  2. Fix Windows support #10 and any other issues until there is a working Windows wheel in CI.
  3. Make it so that CI can produce a suite of wheels and integrate the Windows wheels into the cibuildwheel setup.
  4. Only think about future build systems at the point where CI can at least build and test wheels for the major platforms so that any changes are testable.

@oscarbenjamin
Copy link
Collaborator Author

I've rebased this on top of #28

# Make the wheel relocatable
delvewheel repair dist/python_flint-0.3.0-cp310-cp310-win_amd64.whl \
--add-path .local/bin:.local/lib/ \
'--no-mangle=libflint-17.dll;libarb-2.dll;libgmp-10.dll;libmpfr-6.dll;libgcc_s_seh-1.dll'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not mangling common DLLs like libgcc_s_seh-1.dll is going to cause conflicts with other libraries using the same DLL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm not entirely sure how to make it happen though. The suggestion is to use strip but I don't know exactly which file should be stripped. If it's the generated .pyd that needs to be stripped then that's awkward to arrange for because it gets generated inside distutils and comes out the other end buried inside a wheel.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used strip and removed the --no-mangle argument here and it seems to work.

setup.py Outdated
@@ -9,7 +9,7 @@
from distutils.sysconfig import get_config_vars

if sys.platform == 'win32':
libraries = ["arb", "flint", "mpir", "mpfr", "pthreads"]
libraries = ["arb", "flint", "mpfr", "gmp"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be configurable? It depends on if we use MinGW or MSVC toolchains

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'll peg this to an environment variable for now. Longer term I think we want a build system that doesn't use setup.py or distutils at all and that probably means that exactly how it would be configured would be quite different.

@oscarbenjamin
Copy link
Collaborator Author

So the Windows job runs fine, builds a wheel and then passes all tests.

The failing tests are 32 bit Linux and I think are some other problem with the CI arrangement maybe.

@oscarbenjamin oscarbenjamin force-pushed the pr_windows_ci branch 2 times, most recently from d2bd567 to 70b3fde Compare December 7, 2022 12:16
@oscarbenjamin
Copy link
Collaborator Author

Okay, that was a long slog!

With this PR we now have Windows wheels built and tested in CI along with Linux and OSX wheels. I knew it would be hard to get Windows working which is why I've put this off for almost two years. It's working now in CI and I've also tested downloading the wheels and using them locally. Hopefully that means that no one needs to actually use Windows directly any more!

The most significant remaining item is OSX on ARM but that's much less of an issue than Windows 64-bit.

I'm going to merge this now and then do two things:

  1. Take a look at making OSX universal2 wheels. If it's not hard then add those.
  2. Increase test coverage for existing features (wip: add coverage testing #29).

After those are done I think it's time for a new release of python-flint with binary wheels on PyPI.

@oscarbenjamin oscarbenjamin merged commit 029ec02 into flintlib:master Dec 11, 2022
@oscarbenjamin oscarbenjamin deleted the pr_windows_ci branch December 11, 2022 20:09
@fredrik-johansson
Copy link
Collaborator

That's awesome! Thanks!

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 this pull request may close these issues.

Windows support
3 participants