-
Notifications
You must be signed in to change notification settings - Fork 108
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
Add building of pyodide universal wheels #918
Conversation
Looks pretty straightforward. Does anyone know offhand it a platform-specific wheel takes precedence over a universal one? I'd hope it does. |
Yes, they take precedence. And since we have wheels for all major platforms, the universal one should really only ever be installed when installed through pyodide. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #918 +/- ##
=======================================
Coverage 81.69% 81.69%
=======================================
Files 182 182
Lines 47585 47585
Branches 11584 11584
=======================================
Hits 38875 38875
- Misses 6518 6520 +2
+ Partials 2192 2190 -2 |
To clarify, did this PR addressed the concerns here: #285 (comment) ? |
I believe the idea here is to sidestep the issue by omitting the cython extension. (I don't understand the implications of omitting it.) |
I think so, yes. Ultimately, having a cython-extension really only makes sense if using the c-backend. For the python backend there shouldn't be any dependency that's related to compilation. |
Thanks for the assist @maresb! |
@lucianopaz, I'm very interested to get your thoughts on this approach. Is it viable to simply omit the extension when building a universal wheel? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I understand, the code here should work. It will produce a universal wheel without the cython extension for scan. I think that the setup.py
could be improved so that it doesn't rely on environment variables but that is more of a detail.
My bigger concern is the same that I said originally: building a universal wheel with reduced capabilities will do more harm than good in the long run. As pointed out here, universal wheels will be preferred by pip over platform specific wheels. This means that, any installation will need to require a platform specific version of pytensor
manually to avoid getting the universal wheel. The correct way to deal with this is to get pytensor
built using the pyodide build toolchain so that we have a platform specific version that can run on the browser.
if is_pyodide: | ||
# For pyodide we build a universal wheel that must be pure-python | ||
# so we must omit the cython-version of scan. | ||
ext_modules = [] | ||
else: | ||
ext_modules = [ | ||
Extension( | ||
name="pytensor.scan.scan_perform", | ||
sources=["pytensor/scan/scan_perform.pyx"], | ||
include_dirs=[numpy.get_include()], | ||
), | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depending on an environment variable to conditionally include an extension is very unorthodox and I don't think that it will be robust in the future. As far as I know, there is no canonical way to conditionally include an extension or not when using pyproject.toml or the older setup.py. However, there is a way to get platform conditional requirements following this pep. Maybe we could look at the sys
information to identify that python is running from the browser instead of having is_pyodide
conditioned on the environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm extremely pro-declarative config, so I'd really like to do this better.
Unfortunately after taking a brief look through the environment markers, I don't see any particular variables that can help in our situation. This feels not so surprising to me since "universal" vs "platform-specific" seems more like a "build" parameter than an "environment" parameter, making it something to be handled at the build-backend (setuptools
) level rather than the project-config level. On the same note, the pyproject.toml
standard doesn't seem to support ext_modules
. So I don't have any ideas for how we could do this better.
Also, unfortunately using ext_modules
seems to marry us to setuptools
which I loathe, but that's out-of-scope for this PR.
My reading of the stack overflow answer is that the priority is: platform-specific compatible wheel > universal wheel > sdist |
I don't think that's the case. And I have confirmed that non-pyodide installs work the same across all major platforms. I don't think the risk is that high to give this a try. We can test to make sure we don't break anything on existing platforms. |
Oh! You’re right, I misread the last sentence
So platform specific wheels will be preferred, then universal wheels and finally source distributions. I take back what I said about the risks then. This should be mostly fine. |
Thanks @lucianopaz. Can we get an approval? |
I'm a bit uncomfortable that we're not testing the universal wheel. Maybe I can finish off #560 right now... |
what might this be about? |
This way versioneer can read pyproject.toml
1a161f9
to
68e5338
Compare
* Add building of pyodide universal wheels * precommit * Fix precommit. Readd comment. * Fix precommit2 * Minor improvement to ext_modules conditional definition * Bump Python version so that tomllib is included This way versioneer can read pyproject.toml * Add wheel package to build dependencies * Update .github/workflows/pypi.yml * Revert unnecessary * ruff --------- Co-authored-by: Ben Mares <[email protected]>
Closes #285 and #360.
These require pure-python wheels which does not work if we ship a cython-version of scan, so this build does not include this extension module.