GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — BLD,BUG: quadmath required where available [f2py] by HaoZeke · Pull Request #25073 · numpy/numpy

Conversation

@HaoZeke

@HaoZeke HaoZeke commented Nov 5, 2023

Copy link
Copy Markdown
Member

Closes gh-25000.

There's a longer explanation in the issue comment but essentially, for the most common toolchain (gfortran from rtools and standard python), quadmath needs to be declared as an explicit dependency.

Also updates the documentation with supported compiler toolchains.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@HaoZeke HaoZeke added the component: numpy.f2py label Nov 5, 2023
@github-actions github-actions Bot added the 36 - Build Build related PR label Nov 5, 2023
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Nov 6, 2023
@mattip

mattip commented Nov 7, 2023

Copy link
Copy Markdown
Member

Is this code tested? Maybe we should be moving the f2py test builds to meson

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@HaoZeke

HaoZeke commented Nov 7, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Is this code tested? Maybe we should be moving the f2py test builds to meson

It should be tested with meson on the 3.12 builds AFAIK EDIT: I can't remember making changes to the testsuite to work with meson-f2py so it is likely skipped right now, will fix the tests this week(end).

mattip reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@HaoZeke HaoZeke mentioned this pull request Nov 11, 2023
TST: Use meson for testing f2py #25111
Merged
7 tasks done
HaoZeke and others added 3 commits November 12, 2023 01:09
@HaoZeke
BLD,BUG: quadmath required where available [f2py]
a68ada7
Closes numpygh-25000
@HaoZeke
DOC: Add a pointer to the SciPy fortran doc
ff8c34f
@HaoZeke @rgommers
DOC: Adapt comment on supported toolchains
929f239
Co-authored-by: rgommers <[email protected]>
@HaoZeke
HaoZeke force-pushed the winF2PYquadmath branch from 1e5ccb8 to 929f239 Compare November 12, 2023 01:09
@HaoZeke

HaoZeke commented Nov 12, 2023

Copy link
Copy Markdown
Member Author

Is this code tested? Maybe we should be moving the f2py test builds to meson

It should be tested with meson on the 3.12 builds AFAIK EDIT: I can't remember making changes to the testsuite to work with meson-f2py so it is likely skipped right now, will fix the tests this week(end).

@mattip a small update, this PR is "sort of" tested in #25111. "sort of" because since #9673 back in 2017 none of the (compiled) F2PY tests are actually run on Windows. However I did test them manually, with a compatible toolchain, something which is hard to guarantee on the CI without distutils anyway. I think, since @jmrohwer also confirmed this is required on Windows it should go in (along with #25114) so we can merge #25111 and restore the pre-meson status quo.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mattip

mattip commented Nov 12, 2023

Copy link
Copy Markdown
Member

I don't understand. We should be testing this. #9673 is a still-open issue. We have the rtools toolchain on windows with a fortran compiler specifically for tests.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@HaoZeke

HaoZeke commented Nov 12, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

I don't understand. We should be testing this. #9673 is a still-open issue. We have the rtools toolchain on windows with a fortran compiler specifically for tests.

There are two problems here, firstly that (as noted) the F2PY tests have long been skipping all compiled Fortran module tests, git blame shows that this has been around for 6 years now. So Windows (with or without rtools) is not being tested for the compiled f2py modules in NumPy. This was true even before the meson transition.

^--- This in itself isn't really an issue, I believe #9673 should probably be defunct with meson anyway, but there's a larger issue.

Compiler detection

Offloading the build step to meson means the only control knobs are environment variables. Currently:

  • f2py, we call meson via subprocess.run when -c is requested

So what needs to happen is that we would need to propagate CLI arguments as environment variables through to all the subprocess.run calls (asv does this). This would be pretty much what was being done before with distutils, and forces us to keep adapting to the environment variables accepted by meson. The current expectation is that users will generate the binding code and customize the build command.

Now even assuming we should modify the frontend to pass environment variables over to meson there's another problem, that of compiler detection. meson doesn't explictly have a Python API, so that means that to figure out what compiler is present on the CI, we'd need to parse the output of meson setup and track that state throughout the code. This is essentially distutils but with meson inside.

To me, it seems like it would dampen much of the benefits we gained (offloading the build complexity, not tracking compilers etc.) from the switch to meson for adding tests on a platform which wasn't really tested to begin with. Also pinging @rgommers for thoughts regarding the meson part.

CI Testing

This doesn't mean it is impossible to test on CI, just that the current interface is too rigid for it, and that the code shouldn't be bent out of shape just to satisfy the unit testing requirement.

Instead, I believe the solution is to have a new CI job, where (some) f2py tests should be tested the way users would use them, i.e. by generating the meson build directory with the skeleton template and then running meson within with the right environment variables.

Perhaps this should be moved to an issue of its own?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mattip mattip mentioned this pull request Nov 13, 2023
CI, TST: have a f2py-specific CI run and properly skip f2py tests elsewhere #25134
Open
@mattip

mattip commented Nov 13, 2023

Copy link
Copy Markdown
Member

that of compiler detection. meson doesn't explictly have a Python API, so that means that to figure out what compiler is present

We know what compiler is present on CI, we don't have to guess.

a new CI job, where (some) f2py tests should be tested the way users would use them, i.e. by generating the meson build directory with the skeleton template and then running meson within with the right environment variables.

I opened #25134

HaoZeke reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mattip
mattip merged commit 58cbbe0 into numpy:main Nov 13, 2023
@mattip

mattip commented Nov 13, 2023

Copy link
Copy Markdown
Member

Thanks @HaoZeke

HaoZeke reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rgommers

rgommers commented Nov 13, 2023

Copy link
Copy Markdown
Member

Offloading the build step to meson means the only control knobs are environment variables.

Not quite, you can supply a machine file to point at any binary: https://mesonbuild.com/Machine-files.html#binaries. This is for example what meson-python does to select the Python interpreter to use, it passes it via --native-file.

HaoZeke reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jmrohwer

jmrohwer commented Nov 15, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

@HaoZeke I see that this has been merged and #25000 has been closed. So not sure what the right place is to mention this.

However, for f2py -c to work properly on Windows, the built binaries need to be moved to the build root as well (currently only *.so files are searched and moved).

The following patch fixes it:

diff --git a/numpy/f2py/_backends/_meson.py b/numpy/f2py/_backends/_meson.py
index 3176a5e08..14f9ace2b 100644
--- a/numpy/f2py/_backends/_meson.py
+++ b/numpy/f2py/_backends/_meson.py
@@ -7,6 +7,7 @@
 
 from ._backend import Backend
 from string import Template
+from itertools import chain
 
 import warnings
 
@@ -84,6 +85,7 @@ def __init__(self, *args, **kwargs):
     def _move_exec_to_root(self, build_dir: Path):
         walk_dir = Path(build_dir) / self.meson_build_dir
         path_objects = walk_dir.glob(f"{self.modulename}*.so")
+        path_objects = chain(path_objects, walk_dir.glob(f"{self.modulename}*.pyd"))
         for path_object in path_objects:
             shutil.move(path_object, Path.cwd())

Should I open a new bug report or a pull request (seems silly for 2 lines of code)?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@HaoZeke

HaoZeke commented Nov 15, 2023

Copy link
Copy Markdown
Member Author

@HaoZeke I see that this has been merged and #25000 has been closed. So not sure what the right place is to mention this.

However, for f2py -c to work properly on Windows, the built binaries need to be moved to the build root as well (currently only *.so files are searched and moved).

The following patch fixes it:

diff --git a/numpy/f2py/_backends/_meson.py b/numpy/f2py/_backends/_meson.py
index 3176a5e08..14f9ace2b 100644
--- a/numpy/f2py/_backends/_meson.py
+++ b/numpy/f2py/_backends/_meson.py
@@ -7,6 +7,7 @@
 
 from ._backend import Backend
 from string import Template
+from itertools import chain
 
 import warnings
 
@@ -84,6 +85,7 @@ def __init__(self, *args, **kwargs):
     def _move_exec_to_root(self, build_dir: Path):
         walk_dir = Path(build_dir) / self.meson_build_dir
         path_objects = walk_dir.glob(f"{self.modulename}*.so")
+        path_objects = chain(path_objects, walk_dir.glob(f"{self.modulename}*.pyd"))
         for path_object in path_objects:
             shutil.move(path_object, Path.cwd())

Should I open a new bug report or a pull request (seems silly for 2 lines of code)?

Actually a pull request would be great (we never have any patches committed to master) :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@HaoZeke
HaoZeke deleted the winF2PYquadmath branch November 16, 2023 01:30
This was referenced Nov 16, 2023
BUG: Fix moving compiled executable to root with f2py -c on Windows #25160
Merged
Proposed release 1.1.2 PySCeS/pysces#93
Merged
@charris charris mentioned this pull request Nov 19, 2023
BLD,BUG: quadmath required where available [f2py] #25189
Merged
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Nov 19, 2023
@charris charris mentioned this pull request Nov 21, 2023
BUG: Fix moving compiled executable to root with f2py -c on Windows #25218
Merged
@HaoZeke HaoZeke mentioned this pull request Dec 19, 2023
TST: Use meson for testing f2py #25427
Closed
7 tasks done
@HaoZeke
HaoZeke restored the winF2PYquadmath branch June 15, 2024 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

36 - Build Build related PR component: numpy.f2py

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

BUG: f2py -c does not work on Windows with meson (Python 3.12)

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@HaoZeke @mattip @rgommers @jmrohwer @charris
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.