sphinx_rtd_theme icon indicating copy to clipboard operation
sphinx_rtd_theme copied to clipboard

Python 3 support for node-js build stack

Open benjaoming opened this issue 3 years ago • 8 comments
trafficstars

node-sass 4.3.0 is super-old and uses a stack for Python 2. Since then, a bunch of newer support has landed for both Node and Python versions.

I suggest updating to 5.0.0, since prior releases just seem to be about very small bug fixes and support of many newer Node versions: https://github.com/sass/node-sass/releases

PR incoming...

benjaoming avatar Aug 17 '22 11:08 benjaoming

Same issue with bourbon-neat.

benjaoming avatar Aug 17 '22 11:08 benjaoming

Oh game over, looks like we are stuck on Python 2 because of Wyrm.

bourbon-neat 1.9 is required, Wyrm is not compatible with Neat 2.0+.
The expected selector for the bourbon-neat dependency in package.json is "~1.9".

benjaoming avatar Aug 17 '22 11:08 benjaoming

Python 3 is definitely usable, but you cannot upgrade SASS, Wyrm, or Bourbon.

Upgrading these is a known issue, and the fix so far has be to drop the entire dependency chain and switch to Bootstrap. I would avoid trying to change these dependencies, as there was a fair amount of work that went into finding the correct configuration of dependencies that worked

agjohnson avatar Aug 17 '22 18:08 agjohnson

There is a good amount of information on the dependencies here: https://github.com/readthedocs/sphinx_rtd_theme/pull/771

agjohnson avatar Aug 17 '22 18:08 agjohnson

Are we talking about the same thing? The Node stack needs Python 2 in order to work AFAICT. There are for instance print "foobar" statements in the executed code of the node packages, which fail hard.

benjaoming avatar Aug 17 '22 21:08 benjaoming

Yeah, I'm not quite sure where you are running into errors, but perhaps having more information on how you're noticing errors would help.

The theme definitely builds on Python 3, I am using 3.8 locally only because I haven't tried upgrading to 3.11 yet, but I'm sure that also works.

Python 3 tests are all passing here (note, no dependency changes besides Jinja2<3.1 and Node==14.20): https://github.com/readthedocs/sphinx_rtd_theme/pull/1316

image

agjohnson avatar Aug 17 '22 21:08 agjohnson

There is something smelly going on.

While I have definitely had issues with a ghost Node 18 installation (which was supposed to be Node 14), I am now also having error-free builds with Python 3!

node-gyp 3.8 (which we are using) is NOT supposed to work with Python 3. That support landed in version 5: https://github.com/nodejs/node-gyp/blob/main/CHANGELOG.md#v500-2019-06-13

benjaoming avatar Aug 19 '22 17:08 benjaoming

Btw my errors happened during npm run build and contained errors about print statements in node-gyp, which are definitely indicating python 2 code :)

benjaoming avatar Aug 19 '22 17:08 benjaoming

I'm mostly sure we worked past these issues, but just for historical note:

The answer here is that a system level node-gyp will take precedence over the locally installed version. So as long as you have a modern node-gyp installed, this package will build. Unfortunately, node-gyp here is a bit more tedious because of the dependency chain back to Wyrm and Bourbon.

agjohnson avatar Mar 13 '23 16:03 agjohnson

It seems perfectly fine to close this :+1: I think you could be right that there is something going on with system-level.

benjaoming avatar Mar 13 '23 16:03 benjaoming

Thanks for your patient feedback @agjohnson :heart:

benjaoming avatar Mar 13 '23 16:03 benjaoming

Always! Closing does make sense I suppose, I don't think we have the appetite to fork Wyrm to upgrade Bourbon -> Neat -> node-gyp :cold_sweat:

And the answer almost certainly is to drop all of them for modern dependencies or bootstrap.

agjohnson avatar Mar 13 '23 16:03 agjohnson

Yes definitely agree: I want to stress that the point here like originated from a misconception... but the intention was fix an issue so we can have an isolated and reliable Docker environment for all this old stuff... but I still hadn't dipped my toes into the full stack :)

I think the Docker environment needs a few tweaks, but they're easier to handle at an appropriate occasion, not as some pro-active venture :)

benjaoming avatar Mar 13 '23 16:03 benjaoming

I want to stress that the point here like originated from a misconception

Hah well I'd say it's more than a misconception too, the original issue originated from a very annoying bug. We definitely shouldn't need system level dependencies to build this here :upside_down_face:

I believe I tried it here, and I'm not sure if there is an easy way to make Wyrm and friends happy with it, but dropping node-sass entirely, for the Dart sass implementation does work around the node-gyp issue entirely:

https://github.com/readthedocs/ethical-ad-client/pull/149

So, there are maybe 2 options there that don't involve us fiddling with node-gyp any further. I'm hopefully we can avoid applying our efforts to patching up node-gyp installation issues.

At least we have a way to avoid being blocked here for now.

agjohnson avatar Mar 13 '23 17:03 agjohnson