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

"spin build" errors on windows #240

Closed
ngoldbaum opened this issue Oct 15, 2024 · 11 comments · Fixed by #241
Closed

"spin build" errors on windows #240

ngoldbaum opened this issue Oct 15, 2024 · 11 comments · Fixed by #241

Comments

@ngoldbaum
Copy link
Contributor

When I try to use spin to build numpy on windows, I get:

meson.build:1:0: ERROR: prefix balue '/usr' must be an absolute path

It looks like this is hard-coded in the build command. I've never had an issue with it before so no idea why it's problematic now.

@ngoldbaum
Copy link
Contributor Author

It looks like deleting the hard-coded prefix lets me get past the error.

@stefanv
Copy link
Member

stefanv commented Oct 15, 2024

Is this a bug in spin then?

I've been trying to get numpy onto 0.12 but I guess you've seen that Matti had concerns about the test modifications.

@ngoldbaum
Copy link
Contributor Author

Is this a bug in spin then?

Well, I was able to build numpy with spin after making this change to spin:

diff --git a/spin/cmds/meson.py b/spin/cmds/meson.py
index 366cd60..b2d8149 100644
--- a/spin/cmds/meson.py
+++ b/spin/cmds/meson.py
@@ -266,7 +266,7 @@ def build(meson_args, jobs=None, clean=False, verbose=False>
     if gcov:
         meson_args = meson_args + ["-Db_coverage=true"]

-    setup_cmd = _meson_cli() + ["setup", build_dir, "--prefix=/usr"] + meson_a>
+    setup_cmd = _meson_cli() + ["setup", build_dir] + meson_args

     if clean:
         print(f"Removing `{build_dir}`")

I have no idea why the --prefix=/usr is necessary so following the principle of Chesterton's fence, I didn't want to put in a PR to do something about it without knowing more.

I haven't been following the issues with spin in NumPy's CI, this was all just to test a NumPy PR on my Windows PC.

@stefanv
Copy link
Member

stefanv commented Oct 15, 2024

The Windows tests for spin run in bash, I think. Which environment do you use?

@ngoldbaum
Copy link
Contributor Author

This is using powershell via windows terminal.

@stefanv
Copy link
Member

stefanv commented Oct 15, 2024

Ah, OK, that's wild west territory for us. Maybe I can get a subset of tests to run on that platform. This is what you've been using all along, without any difficulty?

@ngoldbaum
Copy link
Contributor Author

Yes, it should be possible to build numpy using powershell. I'm not sure when the last time I tried was, it may predate switching to spin.

@ngoldbaum
Copy link
Contributor Author

I just hit this again in CI, trying to update the numpy tests on windows to install python with uv instead of setup-python. For whatever reason, this setup hits the same error:

https://github.com/ngoldbaum/numpy/actions/runs/11373312391/job/31639601441#step:10:25

You never explained earlier - is there any particular reason why --prefix=/usr is hard-coded like that? What would break if I deleted it?

@ngoldbaum
Copy link
Contributor Author

Ah, there's this note in the meson docs:

prefix defaults to C:/ on Windows, and /usr/local otherwise. You should always override this value.

So clearly --prefix=/usr is a bad default on windows.

@rgommers
Copy link
Contributor

I don't see a problem with using C:/ on Windows and /usr on other platforms. The path is still going to be reproducible, and it has the upside of actually existing.

Note that to actually have a uniform install path within the source tree, the recommended way is to use meson install --destdir (see https://mesonbuild.com/Installing.html#destdir-support).

@ngoldbaum
Copy link
Contributor Author

ngoldbaum commented Oct 17, 2024

The other thing that annoys me about how it's currently set up is there's no way to override the default. If you try to manually pass --prefix spin doesn't notice that and happily passes two --prefix arguments to meson, which meson complains about.

So, I think the solution is probably to use C:\ on windows, /usr on unix-ish platforms, and also only pass in a --prefix if the user didn't explicitly pass it.

I'll try to do that later today.

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.

3 participants