Skip to content

SciPy v1.14.1#5031

Merged
agriyakhetarpal merged 2 commits intopyodide:mainfrom
agriyakhetarpal:feat/package/scipy-1.14.1
Aug 26, 2024
Merged

SciPy v1.14.1#5031
agriyakhetarpal merged 2 commits intopyodide:mainfrom
agriyakhetarpal:feat/package/scipy-1.14.1

Conversation

@agriyakhetarpal
Copy link
Member

Description

This PR updates SciPy to version 1.14.1. Tagging recipe maintainers: @lesteve, @steppi; and @rgommers, for visibility. SciPy was previously updated in #5012 to version 1.14.0.

Checklists

@agriyakhetarpal
Copy link
Member Author

I confirmed that SciPy is building with the previously added patches, and all tests pass with no new failures. With this PR, we will be up to date with SciPy on PyPI and just (a little) behind the SciPy main branch/development branch(es).

@agriyakhetarpal
Copy link
Member Author

I could spend some time looking into the install tags feature in this PR, which was carried over from the previous one. Since @rgommers mentioned in #5012 (comment) that all (test and non-test) modules are built and install tags affect just the install-time functionality, it might make sense to separate SciPy into two packages/recipes, scipy and scipy-tests, and run tests from scipy-tests?

@agriyakhetarpal
Copy link
Member Author

Copy link
Member

@ryanking13 ryanking13 left a comment

Choose a reason for hiding this comment

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

Thanks!

it might make sense to separate SciPy into two packages/recipes, scipy and scipy-tests, and run tests from scipy-tests?

Sounds reasonable to me, but is it possible to build tests only? Or do you mean having two scipy packages w/ tests and w/o tests?

@rgommers
Copy link
Contributor

is it possible to build tests only? Or do you mean having two scipy packages w/ tests and w/o tests?

It should be test-only. How to do it is documented at http://scipy.github.io/devdocs/building/redistributable_binaries.html#stripping-the-test-suite-from-a-wheel-or-installed-package. It should take almost no extra time to build two wheels if you follow the hint on caching in those docs.

@agriyakhetarpal
Copy link
Member Author

agriyakhetarpal commented Aug 24, 2024

Yes, I meant "scipy (without tests)" and "scipy (tests only)", indeed. Here's how I can envision this working:

  • such that a new recipe for scipy-tests is created that will depend on scipy,
  • the test-related configuration and files will be moved to scipy-tests so that the tests will be running from there instead of from scipy,
  • this way, both packages would be installed at the time of testing, and
  • we would need an extra patch that changes the package name from scipy to scipy-tests, while the rest of the patches will remain the same as the earlier ones.

I'll have to see how to cache the builds because two separate recipes would mean that both packages are built in different directories (their own ones next to their meta.yaml files), which brings forth a few problems as noted below.

Initially, I tried storing the built files for both under a common location that can be accessed, say, i.e., $PYODIDE_ROOT/scipy_builds/, but it turns out that these environment variables are set just for the script: section, and are not available for the backend-flags: section (they're empty at that stage of the build) – so we'll either need to improvise a bit in hacky ways, or make PYODIDE_ROOT available everywhere on the pyodide-build side (I'm not sure how desirable that would be, though).

Even if I specify something like ../scipy/build/ as the build directory to go back up and into scipy/, it seems to ignore that. Then, I tried some custom commands in the scipy-tests's recipe's script: section to copy over the built files, while making scipy a host dependency of it so that they are never built at the same time (and instead one after the other):

# copy files from the previously-built scipy before scipy-tests is built
cp -r $PYODIDE_ROOT/packages/scipy/build/scipy-$SCIPY_VERSION/scipy_build_cache/ \
$PYODIDE_ROOT/packages/scipy-tests/build/scipy-tests-$SCIPY_VERSION/scipy_build_cache/

This leads to failures because something like /tmp/tmptv0lxkva/cc isn't going to be defined once another recipe's build starts. If I have to proceed this way, I need to disable build isolation (i.e., in line with the -wnx suggestion in the documentation) which is something to be done by the build frontend. We currently don't have a frontend-flags: field where we can pass on pypa/build's --no-isolation equivalent, because we don't support this option in the pyodide build command yet. This seems to be a blocker for getting this runtime-and-test separation going. Should I try to add support for this option in pyodide-build, or is there a better way to handle this problem that I might be missing?

@agriyakhetarpal
Copy link
Member Author

Nonetheless, this problem is a blocker only for building the scipy-tests package "efficiently", and not for updating SciPy to version 1.14.1. Building scipy-tests non-efficiently without caching would work, too, but it is redundant, of course, and I'm not too keen on doing that for our CI.

If this task takes too much time, then there is a case to be made about incorporating this enhancement as part of a follow-up PR, since this PR has brought us close to a potential out-of-tree Pyodide build and CI job for SciPy – provided that the circumventions around the Fortran problems/patches/ints-vs-voids are only going to reduce in the future via scipy/scipy#18566. I'm not a SciPy maintainer, and nor have I followed its development daily as much as @rgommers has continued to do over the last twenty years, but I don't think the files that are problematic for us are touched every day in PRs that would make Pyodide-related debugging too painful. This is backed by the fact that we have been fortunate to need a relatively lesser amount of changes for v1.13.0 ⟹ v1.14.1 in comparison to the extent of what we needed for v1.12.0 ⟹ v1.13.0, all of which makes me feel quite optimistic about it all in the future :)

@rgommers
Copy link
Contributor

I'll have to see how to cache the builds because two separate recipes would mean that both packages are built in different directories

Ah, that is going to be a pain, and probably not worth it. For conda-forge the recipe is "multi-output", so it builds two packages at once. If we cannot build two wheels from a single recipe here, then I'd forget about using this functionality for now (Pyodide already has a mechanism to strip tests, so using install tags isn't necessary).

Nonetheless, this problem is a blocker only for building the scipy-tests package "efficiently", and not for updating SciPy to version 1.14.1. Building scipy-tests non-efficiently without caching would work, too, but it is redundant, of course, and I'm not too keen on doing that for our CI.

agreed

a potential out-of-tree Pyodide build and CI job for SciPy [...] but I don't think the files that are problematic for us are touched every day in PRs that would make Pyodide-related debugging too painful

I'd like to wait with trying this, since there are still too many Fortran-related patches and I don't think it's reasonable to ask SciPy maintainers to deal with those.

@ryanking13
Copy link
Member

Nonetheless, this problem is a blocker only for building the scipy-tests package "efficiently", and not for updating SciPy to version 1.14.1. Building scipy-tests non-efficiently without caching would work, too, but it is redundant, of course, and I'm not too keen on doing that for our CI.

Thanks for looking into it. As Ralf mentioned, I don't think it is that worth it unless the build time of scipy-tests takes too long, especially we are going to unvendor recipes. So, for now, let's just build it twice.

@agriyakhetarpal
Copy link
Member Author

agriyakhetarpal commented Aug 26, 2024

Thanks for looking into it. As Ralf mentioned, I don't think it is that worth it unless the build time of scipy-tests takes too long, especially we are going to unvendor recipes. So, for now, let's just build it twice.

Just to clarify, @ryanking13scipy and scipy-tests will be built in the same amount of time, and it would increase the CI time for the build-packages-numpy-dependents job by ~5-10 minutes, since we have three threads running at once in CircleCI. The currently existing functionality to strip the tests with unvendor-tests: true would be better instead of building twice, wouldn't it?

@ryanking13
Copy link
Member

The currently existing functionality to strip the tests with unvendor-tests: true would be better instead of building twice, wouldn't it?

Yes, that sounds reasonable to me.

@agriyakhetarpal
Copy link
Member Author

Great! Merging this PR, then, since all [scipy] tests are passing.

@agriyakhetarpal agriyakhetarpal merged commit 76f1f0c into pyodide:main Aug 26, 2024
@agriyakhetarpal agriyakhetarpal deleted the feat/package/scipy-1.14.1 branch August 26, 2024 12:35
@hoodmane
Copy link
Member

Thanks @agriyakhetarpal!

lagru added a commit to scikit-image/scikit-image that referenced this pull request Sep 15, 2024
…sting (#7525)

This PR follows up on changes made in gh-7350. Here's a small, point-wise summary noting the changes here:

- It updates the Emscripten/Pyodide CI job added in gh-7350 and removes the workaround JavaScript-based test suite file, since we fixed the `s_cmp` OpenBLAS unresolved symbol coming from SciPy upstream, having updated SciPy in-tree in Pyodide (see pyodide/pyodide#4719, pyodide/pyodide#5012, pyodide/pyodide#5031, and more). This should make the testing slightly cleaner than before, and the test suite now runs till the end without any Pyodide fatal errors being reported.
The [Pyodide xbuildenv](https://github.com/pyodide/pyodide/releases/tag/0.27.0a2) can now be used to set up a virtual environment in which the tests can be run in the same way they were before.
The [`pyodide-build` tool](https://github.com/pyodide/pyodide-build) has been unvendored from the Pyodide repository and now infers the Pyodide version from the releases, downloading the relevant files from the GitHub release. Hence, the `PYODIDE_VERSION` environment variable is no longer required.
- There were some tests that have been failing on 32-bit platforms, which were last discussed quite a while ago: #3091. They surprisingly passed in a WASM 32-bit environment here without issues, which is great. I have updated the skipping conditions to accommodate this.
- There's a known problem with the pytest bytecode generation when running the tests with the xbuildenv interpreter – I disabled the pytest internal cache plugin to fix that, but ignoring the warning (pypa/cibuildwheel#1966 (comment)) works equally as well. Please let me know if there is a preference. :)

Additional context

- Pyodide CI support was first discussed in gh-7265.
- At the time of writing, Pyodide 0.27alpha2 is used in the CI job; once 0.27 stable comes out (should be soon) and `cibuildwheel` updates to it, that (plus this PR) will help unblock another PR that I had opened a while back: gh-7440. I can rebase that PR when ready.
- pyodide/pyodide#4871 (comment)

---

Co-authored-by: Lars Grüter <20140352+lagru@users.noreply.github.com>
@agriyakhetarpal agriyakhetarpal mentioned this pull request Jan 3, 2025
3 tasks
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 this pull request may close these issues.

4 participants