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

Bundle NodeJS with mystmd so users don't have to install it on their own #1443

Closed
choldgraf opened this issue Aug 9, 2024 · 4 comments · Fixed by #1487
Closed

Bundle NodeJS with mystmd so users don't have to install it on their own #1443

choldgraf opened this issue Aug 9, 2024 · 4 comments · Fixed by #1487
Labels
enhancement New feature or request

Comments

@choldgraf
Copy link
Collaborator

Our documentation asks users to install NodeJS and NPM on their own in addition to installing MyST. Most users aren't familiar with these workflows, and installing nodejs from scratch is an extra barrier to trying out MyST. We get a bit closer by telling users to install conda, but this has some weird stuff going on with Anaconda supposedly suing organizations that aren't paying them for using their default packaging channels.

Could we bundle the right NodeJS version with the mystmd package? This would reduce some install complexity for users if they didn't have to think about NodeJS at all.

Implementation ideas

I know that the sphinx-theme-builder package does this so perhaps we can learn from that.

It uses the nodeenv package to download Node into an isolated environment in the package. Here's where a lot of the nodejs logic is inside Furo

@choldgraf choldgraf added the enhancement New feature or request label Aug 9, 2024
@agoose77
Copy link
Contributor

agoose77 commented Aug 9, 2024

@choldgraf yes, and this is on my roadmap for 1.0. I need to revisit it because IIRC I don't think nodeenv uses per-platform wheels, so I want to check how robust it is

@rowanc1
Copy link
Collaborator

rowanc1 commented Aug 9, 2024

This is only for the pypi/conda package right? Could easily see something that checks for node and a version and installs it if it isn't there?

It is nice that the npm version installs in less than a second on CI.

@choldgraf
Copy link
Collaborator Author

@rowanc1 yes this is just for the pip install of MyST. If I recall, nodeenv creates a .nodeenv directory and saves a node environment there, only for use by the package.

We could ask @pradyunsg for some pointers if he'd be willing to give them, I think he's wrestled with nodeenv to get this working for the sphinx-theme-builder

@pradyunsg
Copy link

pradyunsg commented Aug 10, 2024

if he'd be willing to give them

Always happy to share knowledge. ^.^

Could easily see something that checks for node and a version and installs it if it isn't there?

Absolutely! I didn't want to use the already-installed copy because I have limited trust that redistributors aren't meddling with NodeJS (whoops) but checking versions is something that sphinx-theme-builder does today -- although that serves as a sanity check of the version mismatches rather than a short-circuit. The short-circuit of using the system install of NodeJS there is documented here.

nodeenv basically downloads and installs from https://nodejs.org/download/release/ (https://github.com/ekalinin/nodeenv/blob/1.9.1/nodeenv.py#L1116) and has a bunch of environment variables it sets up to get things to use the downloaded copy.

I have some logic being injected in the bit linked in the issue description/first post/OP for making nicer tracebacks because nodeenv provides very little context in the errors that it raises in case of issues. You can do python -m nodeenv and it'll work just fine without all the runpy/rich.traceback shenanigans.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants