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

ENH/BLD: Add install tags for tests #20712

Merged
merged 13 commits into from
May 21, 2024
Merged

Conversation

czgdp1807
Copy link
Member

@czgdp1807 czgdp1807 commented May 14, 2024

Same as numpy/numpy#26274

Reference issue

What does this implement/fix?

Additional information

@github-actions github-actions bot added scipy.stats scipy.io scipy.sparse.linalg scipy.sparse scipy.optimize scipy.signal scipy.interpolate scipy.ndimage scipy.integrate scipy.misc scipy.odr scipy.spatial scipy.sparse.csgraph CI Items related to the CI tools such as CircleCI, GitHub Actions or Azure Meson Items related to the introduction of Meson as the new build system for SciPy Build issues Issues with building from source, including different choices of architecture, compilers and OS labels May 14, 2024
@tylerjereddy
Copy link
Contributor

This PR doesn't have a description, should I assume what you're trying to do is build on Ralf's work in NumPy to install the tests as a separate "package" for the purposes of PyPI releases? Or something else?

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 @czgdp1807, this looks very clean now and all seems to work as advertised.

$ python -m build -wnx -Cinstall-args=--tags=runtime,python-runtime,devel
$ mv scipy-1.14.0.dev0-cp312-cp312-linux_x86_64.whl scipy-1.14.0.dev0-cp312-cp312-linux_x86_64-no-tests.whl
$ python -m build -wnx

$ ls -l dist/*.whl
... 22140538 ... dist/scipy-1.14.0.dev0-cp312-cp312-linux_x86_64-no-tests.whl
... 25101662 ... dist/scipy-1.14.0.dev0-cp312-cp312-linux_x86_64.whl

So the produced wheels are ~12% smaller. In addition, this will help people who want to strip out the tests, for example:

A wheel for separately installable tests can be produced with a one-line diff:

diff --git a/pyproject.toml b/pyproject.toml
index ab241ac23..3fc1eecfd 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -32,7 +32,7 @@ requires = [
 ]
 
 [project]
-name = "scipy"
+name = "scipy-tests"
 version = "1.14.0.dev0"
 # TODO: add `license-files` once PEP 639 is accepted (see meson-python#88)
 #       at that point, no longer include them in `py3.install_sources()`
$ python -m build -wnx -Cinstall-args=--tags=tests
$ ls -l dist/*.whl
...  2966947 ... dist/scipy_tests-1.14.0.dev0-cp312-cp312-linux_x86_64.whl

There is another set of test files to strip, which is test extension modules:

$ ls -l build/scipy/*/*.so | rg test
-rwxr-xr-x 1 rgommers rgommers    28664 17 mei 18:04 build/scipy/integrate/_test_multivariate.cpython-312-x86_64-linux-gnu.so
-rwxr-xr-x 1 rgommers rgommers   270968 17 mei 18:04 build/scipy/integrate/_test_odeint_banded.cpython-312-x86_64-linux-gnu.so
-rwxr-xr-x 1 rgommers rgommers   151456 17 mei 18:04 build/scipy/io/_test_fortran.cpython-312-x86_64-linux-gnu.so
-rwxr-xr-x 1 rgommers rgommers    52912 17 mei 18:04 build/scipy/_lib/_test_ccallback.cpython-312-x86_64-linux-gnu.so
-rwxr-xr-x 1 rgommers rgommers   158752 21 mei 13:45 build/scipy/_lib/_test_deprecation_call.cpython-312-x86_64-linux-gnu.so
-rwxr-xr-x 1 rgommers rgommers    92272 21 mei 13:45 build/scipy/_lib/_test_deprecation_def.cpython-312-x86_64-linux-gnu.so
-rwxr-xr-x 1 rgommers rgommers    31336 17 mei 18:04 build/scipy/ndimage/_ctest.cpython-312-x86_64-linux-gnu.so
-rwxr-xr-x 1 rgommers rgommers   386480 21 mei 13:45 build/scipy/ndimage/_cytest.cpython-312-x86_64-linux-gnu.so
-rwxr-xr-x 1 rgommers rgommers  1095216 21 mei 13:45 build/scipy/special/_test_internal.cpython-312-x86_64-linux-gnu.so

Could you change the install tags on those targets to tests as well?

.github/workflows/linux.yml Outdated Show resolved Hide resolved
@czgdp1807
Copy link
Member Author

I think for scipy-tests we need to do it in a separate PR. I think we need to do create two [project] (I don't know if its allowed), one for scipy (without tests) and one for scipy-tests.

@rgommers
Copy link
Member

I think for scipy-tests we need to do it in a separate PR. I think we need to do create two [project] (I don't know if its allowed), one for scipy (without tests) and one for scipy-tests.

Yeah don't worry about that. It's not something we have to do anything about before starting to actually produce wheels without tests included. And two [project] sections are not allowed indeed.

@czgdp1807 czgdp1807 requested a review from rgommers May 21, 2024 15:13
@czgdp1807
Copy link
Member Author

All ready on this PR.

@rgommers
Copy link
Member

Found one more sizable set of files to remove, pushed a fix. With that, we're at:

  • full wheel: 25.1 MB
  • test-only: 4.6 MB
  • wheels without tests: 20.5 MB

Once we remove the already-deprecated scipy.misc in the future, which also contains some data files, then it's down to 18.6 MB. That is getting somewhere:)

@rgommers rgommers merged commit de8d573 into scipy:main May 21, 2024
31 checks passed
@rgommers
Copy link
Member

Okay, let's declare victory here - in it went! Nice work @czgdp1807.

Cc @h-vetinari for visibility: for the next release it may be nice to start using this in conda-forge to produce scipy and scipy-tests, that would clean things up a lot.

@rgommers rgommers added this to the 1.14.0 milestone May 21, 2024
@czgdp1807 czgdp1807 deleted the install_tags branch May 21, 2024 17:44
@h-vetinari
Copy link
Member

That's great news; this took a lot of manual processing on the conda-forge that will be great to get rid of. Thanks for the heads-up and the work here!

@rgommers
Copy link
Member

gh-20812 includes docs for this new feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build issues Issues with building from source, including different choices of architecture, compilers and OS CI Items related to the CI tools such as CircleCI, GitHub Actions or Azure enhancement A new feature or improvement Meson Items related to the introduction of Meson as the new build system for SciPy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants