8000 BLD: mingw-w64 build fixes by lazka · Pull Request #24968 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BLD: mingw-w64 build fixes #24968

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

Merged
merged 2 commits into from
Nov 5, 2023
Merged

Conversation

lazka
Copy link
Contributor
@lazka lazka commented Oct 20, 2023

Two commits to make the build with mingw-w64 work. Note that this is using mingw-w64 Python, which is not officially supported by upstream CPython. I hope the changes here are small/clear enough to still be considered.

  • BLD: Skip MSVC compatibility when building against mingw-w64 Python
  • BLD: Fix mingw detection when building with Clang

See the commit messages for details

@github-actions github-actions bot added the 36 - Build Build related PR label Oct 20, 2023
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Oct 20, 2023
@charris
Copy link
Member
charris commented Oct 20, 2023

Hmm, seems reasonable to me.

Copy link
Member
@rgommers rgommers left a comment

Choose a reason for hiding this comment

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

Thanks @lazka. Yes, we're happy to support Mingw-built Python, that seems like a worthwhile thing and I never really understand the problem CPython devs had with accepting patches.

A few comments on these changes.

lazka added 2 commits November 3, 2023 20:49
In MSYS2 we build numpy like Linux distros, so we prefer dynamic
linking and it needs to be ABI compatible with all other packages.
numpy by default statically links ucrt and changes the ABI to match
MSVC, which makes it incompatible with other packages.

To differentiate the two use cases detect if we are building against
a mingww-64 Python build, and if we are skip all the special adjustments.

Note that mingw-w64 is not officially supported by upstream CPython.
mingw-w64 nowadays is also available in combination with Clang,
for example https://github.com/mstorsjo/llvm-mingw or MSYS2
provide Clang builds using mingw-w64.

Instead of testing for GCC check that __MINGW32__ is defined.
@lazka lazka force-pushed the mingw-python-build-fixes branch from 862fd82 to 9123d43 Compare November 3, 2023 19:56
@lazka
Copy link
Contributor Author
lazka commented Nov 3, 2023

@lazka lazka marked this pull request as ready for review November 3, 2023 20:00
@mattip mattip merged commit 29cbb1f into numpy:main Nov 5, 2023
@mattip
Copy link
Member
mattip commented Nov 5, 2023

Thanks @lazka

@rgommers rgommers added this to the 2.0.0 release milestone Nov 5, 2023
@lazka
Copy link
Contributor Author
lazka commented Nov 5, 2023

Thanks!

$ python3 -m venv _venvnumpy
$ source _venvnumpy/bin/activate
$ pip install git+https://github.com/numpy/numpy
Collecting git+https://github.com/numpy/numpy
  Cloning https://github.com/numpy/numpy to c:/msys64/tmp/pip-req-build-fnyfgf0b
  Running command git clone --filter=blob:none --quiet https://github.com/numpy/numpy C:/msys64/tmp/pip-req-build-fnyfgf0b
  Resolved https://github.com/numpy/numpy to commit 29cbb1f0a7f339dc350ecf3fc81de9e9c570f6db
  Running command git submodule update --init --recursive -q
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: numpy
  Building wheel for numpy (pyproject.toml) ... done
  Created wheel for numpy: filename=numpy-2.0.0.dev0-cp311-cp311-mingw_x86_64_clang.whl size=7316554 sha256=d993e6729218e1aecb5fcfe84a33e999456a7dc53c73606780e2e2ee98ddb0a2
  Stored in directory: C:/msys64/tmp/pip-ephem-wheel-cache-n4_gvqoz/wheels/61/82/88/254b39bf4fea16d2cf792805b8284966388b27bdfe9533da7c
Successfully built numpy
Installing collected packages: numpy
Successfully installed numpy-2.0.0.dev0

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: python3.exe -m pip install --upgrade pip
$ python3 -c "import numpy; print(numpy)"
<frozen importlib._bootstrap>:241: Warning: Numpy built with MINGW-W64 on Windows 64 bits is experimental, and only available for
testing. You are advised not to use it for production.

CRASHES ARE TO BE EXPECTED - PLEASE REPORT THEM TO NUMPY DEVELOPERS
<module 'numpy' from 'C:/msys64/home/user/_venvnumpy/lib/python3.11/site-packages/numpy/__init__.py'>

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Nov 6, 2023
charris added a commit that referenced this pull request Nov 6, 2023
Backports of #24969, #24979, #24968, #25068.

* apply 24969.diff

* apply 24979.diff

* apply 24968.diff

* TST: skip flaky test in test_histogram

---------

Co-authored-by: mattip <matti.picus@gmail.com>
charris added a commit to charris/numpy that referenced this pull request Nov 11, 2023
Backports of numpy#24969, numpy#24979, numpy#24968, numpy#25068.

* apply 24969.diff

* apply 24979.diff

* apply 24968.diff

* TST: skip flaky test in test_histogram

---------

Co-authored-by: mattip <matti.picus@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
36 - Build Build related PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0