-
-
Notifications
You must be signed in to change notification settings - Fork 786
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
full nodejs support in file_packager.py v2 #183
Conversation
The node support here is just for the
the way it is structured now, What are your thoughts about this ? |
Thanks for working on this @gabrielfreire! I'm not competent to review JS code for NodeJS, and you will have to wait for @mdboom 's review, but your work on this is very much appreciated!
Possibly, but now it's just ~350 LoC, it's not that large, and keeping it in one file might be simpler for the now? We could always solve this issue later when it arrives? |
Yes, thanks for working on this! I'm sort of happy that we don't have a lot of npm / webpack stuff right now. There's already a lot of technologies that are required to understand in pyodide (Makefiles, emscripten, python packaging) that I'm a little wary of adding one more. However, I think your suggestion to provide an npm package for pyodide is a good one and will inevitably lead us down that road. Maybe we add that stuff at that time as a separate PR? I don't mind a few hundred more lines of code in pyodide.js in order to support Node now in this PR. |
Hehe i understand you, no npm/webpack then, but is it possible to merge this PR and generate other |
How would I test that this is working in Node? (Manual testing is fine for now -- I just want to sanity check it). |
WhenWe will only be able to test this in Node when i finish pyodide.js with the node integration, probably won't be for this PR as i would like to fetch the HowI believe that once everything is ready in
Remember,
)
and in the test job run:
final structure would look like this
this is how i would do it, any thoughts ? |
I think we would have something like this in the CircleCI test-node:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- run:
name: test
command: |
# This Debian is so old, it doesn't know about wasm as a mime type, which then
# causes Firefox to complain when loading it. Let's just add the new mime type.
sudo bash -c "echo 'application/wasm wasm' >> /etc/mime.types"
npm run tests |
AlsoHaving the |
Regarding testing in a separate job in Circle CI that totally makes sense. FYI node is already bundled under The question is more short term, to merge this PR it would be good to have some way of checking that the added changes work. I understand that other PRs may be necessary to get something fully working, but can we not check it at least roughly with some external script (e.g. what you proposed in #14 (comment) or using your external (Also if you can please reference issues in PRs -- it makes finding information easier, I edited the PR description here to add the links) |
I understand, give me 20 minutes, i'll create a new repository with all the necessary files so i don't depend on remote files being built and a test file with some tests in it |
Hi guys @rth and @mdboom BuildingRequirements
Testing
|
hey @rth, I would like to help with this PR if I can. do you remember where we left off here? |
ping @mdboom @gabrielfreire Hi guys, what other changes do we need if we merge this PR? |
Hi @rickyes and @teonbrooks , this PR should have been merged 2 years ago in my opinion, but i guess this feature wasn't the focus at that moment and the PR didn't get much attention, so i kind of abandoned the project. The repository is still there if you guys want to work on it. Cheers. |
@gabrielfreire Thanks again for your contribution and reply, I'm not familiar with the implementation of this project, @teonbrooks can you help with this PR? |
Or I can try to familiarize myself with the project and open a new PR. |
Yes, sorry it never got merged at the time. If someone is interested in continuing it it would very welcome. In particular, it would be necessary to merge master in and add tests to the CI as discussed above. (You can create a new PR by checking-out this branch in your fork). |
@rickyes, yes, feel free to take this PR over. I initially thought I would work on it but it didn't manage to do so |
We have stopped using our own file_packager.py fork, so I think we ought to close this. |
Agreed. It would be good though to re-evaluate what would be necessary for nodejs support and if necessary contribute it to emscripten. |
Continuation of #164
partially addresses #14
Changes
where it sets the Module
var Module = ...
, added a check to look forprocess[%(EXPORT_NAME)s]
which is where PyodideNode.js stores itspyodide
Module.where it tries to set
PACKAGE_PATH
, added support for nodejs and stopped throwing errors if not in a browser, now the error is thrown if the user is on some mysterious environment that is not browser, worker or nodejs.changed the
fetchRemotePackage
method to check forXMLHttpRequest
before trying to fetch anything, if user is not on a browser, usenodejs
isomorphic-fetch
/fs
to fetch remote/local packagesafter the data has been fetched, there are some problematic asserts for
nodejs
, sometimes the buffer is not thearrayBuffer
, but thearrayBuffer.buffer
it was necessary to change from
line 700
assert(arrayBuffer instanceof ArrayBuffer, 'bad input to processPackageData');
to
assert((arrayBuffer instanceof ArrayBuffer || arrayBuffer.buffer instanceof ArrayBuffer), 'bad input to processPackageData');
and from line 701
var byteArray = new Uint8Array(arrayBuffer);
to
var byteArray = new Uint8Array(arrayBuffer instanceof ArrayBuffer ? arrayBuffer : arrayBuffer.buffer);
this format was tested using
PyodideNode.js
onpyodide.asm.data.js
andnumpy.js
and works fine.