Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BLD, TST: refactor test to use meson not setup.py, improve spin test -m ... #24153

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 7 commits into from
Jul 14, 2023

Conversation

mattip
Copy link
Member

@mattip mattip commented Jul 10, 2023

This PR has two parts:

  • Add spin test -m full which will run the full test suite
  • Refactor random/tests/test_extending.py to use meson

Marking as draft to also refactor numpy.testing.extbuild to use meson as well.

@github-actions github-actions bot added the 36 - Build Build related PR label Jul 10, 2023
@mattip mattip marked this pull request as draft July 10, 2023 10:39
@mattip
Copy link
Member Author

mattip commented Jul 11, 2023

Hmm. meson can be installed by pip, but what do we do about ninja? It is a hard requirement to run meson. I guess we should skip the build-a-module tests if ninja is not installed.

Edit: nvrmind: ninja can be pip installed too!

@mattip mattip force-pushed the cpp-random branch 2 times, most recently from c74cfaa to b15a55f Compare July 12, 2023 08:29
@mattip
Copy link
Member Author

mattip commented Jul 12, 2023

Any ideas how to avoid pip installing a package in a requirements file on pyodide? This works (will skip installing ninja) on ubuntu

ninja ; sys_platform != "linux"

but this seems to not work on pyodide

ninja ; sys_platform != "emscripten"

even though the sys.platform is emscripten

@rgommers
Copy link
Member

I think ninja should be packaged in Pyodide, and until that happens I'd just skip the tests for IS_WASM. Cc @hoodmane for visibility/opinion.

@mattip
Copy link
Member Author

mattip commented Jul 13, 2023

The relevant tests are skipped. The problem is that pip install -r test_requirements.txt is failing on pyodide (before testing begins), since ninja cannot be installed. I could remove it from test_requirements.txt and install manually in all the other CI runs, but that seems wrong.

@rgommers
Copy link
Member

Ah, that makes sense. It should already be present in most all CI runs (except for the ones with build isolation perhaps), because it's needed for building. It falls in the same category as compilers, pkg-config, etc. - I'd say it should not be in test_requirements.txt because ninja is not a Python package and you'd preferably get it from your system package manager (it being packaged on PyPI is a hack; meson-python has an elaborate workaround to only install it if it's not already present on the system).

@rgommers
Copy link
Member

tl;dr this is an Ubuntu job, so just install it with apt?

@mattip
Copy link
Member Author

mattip commented Jul 13, 2023

this is an Ubuntu job, so just install it with apt?

Kind of. "this" is also all wheel builds, which build in an isolated environment and then test.

@mattip
Copy link
Member Author

mattip commented Jul 13, 2023

ninja is needed a bit everywhere. While it can be installed by apt and choco, it is not clear how to install it on macOS. Apparently there is no yum package of that name available in the manylinux2014_i386 image. So I still did pip install in places where I was too lazy to work out an alternative.

@rgommers
Copy link
Member

So I still did pip install in places where I was too lazy to work out an alternative.

That sounds fine to me.

@mattip
Copy link
Member Author

mattip commented Jul 13, 2023

Looking more closely at the ninja PyPI package, it seems like a valid wheel solution to provide a binary for all platforms. It is a shame I needed to add it everywhere pip install -r test_requirements.txt is used instead of putting this inside test_requirements.txt

ninja ; sys_platform != "emscripten"

@mattip mattip marked this pull request as ready for review July 13, 2023 17:24
@mattip
Copy link
Member Author

mattip commented Jul 13, 2023

This is ready for review:

  • move cython and c-extension compilation to meson
  • add a c++ cython build test to the existing ones using the nprandom static library
  • remove a python3.9 azure job
  • add a spin -m full command to run slow tests

@hoodmane
Copy link
Contributor

hoodmane commented Jul 13, 2023

On the topic of

ninja ; sys_platform != "emscripten"

I've run into the same problem while working on pypa/cibuildwheel#1456 and I would like to fix it soon. There's a lot of complexity involved in convincing pip to behave correctly since it needs to run on the host linux Python but install stuff for emscripten Python. I think the correct way to fix this is to use PYTHONPATH to add customized versions of the standard library modules platform.py and sysconfig.py but it is a bit tricky to get right.

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.

This looks quite good, thanks Matti. I have only one significant comment.

@@ -80,6 +80,13 @@ setup_base()

run_test()
{
# meson has a hard dependency on ninja, and we need meson to build
Copy link
Member

Choose a reason for hiding this comment

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

minor: it'd be good not to repeat the same comment multiple times; can you either remove this or change to something like "see note in pyproject.toml for why ninja is installed as a test requirement"?

cwd=str(build_dir),
)
# We don't want a wheel build, so do the steps in a controlled way
# The meson.build file is not copied as part of the build, so generate it
Copy link
Member

Choose a reason for hiding this comment

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

This should not be necessary, you can install any file you want/need. Can you commit a regular meson.build file in random/_examples/cython/ and edit random/meson.build to install it rather than the _examples/cython/setup.py file that's installed now?

@rgommers
Copy link
Member

time spin test shows that the default test suite run goes from 7min03 to 2min47, which is nice for usability.

@mattip
Copy link
Member Author

mattip commented Jul 14, 2023

I addressed the review comments, CI is passing.

@rgommers
Copy link
Member

CI is passing.

It looks very red to me.

@rgommers
Copy link
Member

I think you forgot to commit the new meson.build file?

@mattip
Copy link
Member Author

mattip commented Jul 14, 2023

I think you forgot to commit the new meson.build file?

Thanks. Committed now, I guess I should refresh (f5) before jumping to conclusions.

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.

LGTM now, in it goes. Thanks Matti!

@rgommers rgommers merged commit 308b348 into numpy:main Jul 14, 2023
@rgommers rgommers added the 09 - Backport-Candidate PRs tagged should be backported label Jul 16, 2023
@charris charris added this to the 1.26.0 release milestone Jul 23, 2023
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Aug 3, 2023
@charris charris removed this from the 1.26.0 release milestone Aug 3, 2023
@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Aug 4, 2023
@charris
Copy link
Member

charris commented Aug 4, 2023

We may want to backport some of this to 1.26, so marking.

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Aug 4, 2023
@charris
Copy link
Member

charris commented Aug 4, 2023

We may want to backport some of this to 1.26, so marking.

Seems we don't need it, so removing label.

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.

4 participants