-
-
Notifications
You must be signed in to change notification settings - Fork 12
deps: Bump node-gyp to latest ^10.2.0 for Python 3.12 compat #137
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
Conversation
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 I understand it, the main benefit of this bump is that end users shouldn't need to install a setuptools
package, but I'm having trouble verifying that it's working that way.
Here are the steps I've used:
- Check out this branch
- Rebase it against
master
(since I'm on arm64 and want to get the recent fix) yarn install
- I did an
ln -s
into a folder on myPATH
to alias the full path tobin/ppm
asppm-test
- Temporarily removed my
setuptools
installation withbrew uninstall python-setuptools
ppm-test install --check
fails with the following error:
> module-with-native-code@ install /Users/andrew/Code/JavaScript/ppm/native-module > node-gyp rebuild
undefined
Traceback (most recent call last):
File "/Users/andrew/Code/JavaScript/ppm/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 42, in
import gyp # noqa: E402
^^^^^^^^^^
File "/Users/andrew/Code/JavaScript/ppm/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py", line 9, in
import gyp.input
File "/Users/andrew/Code/JavaScript/ppm/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in
from distutils.version import StrictVersion
ModuleNotFoundError: No module named 'distutils'
gyp ERR! configure error
gyp ERR! stack Error:gyp
failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/Users/andrew/Code/JavaScript/ppm/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at ChildProcess.emit (node:events:365:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Darwin 23.4.0
gyp ERR! command "/Users/andrew/Code/JavaScript/ppm/bin/node" "/Users/andrew/Code/JavaScript/ppm/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/andrew/Code/JavaScript/ppm/native-module
gyp ERR! node -v v16.0.0
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! module-with-native-code@ install:node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the module-with-native-code@ install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/andrew/.pulsar/.apm/_logs/2024-09-15T20_47_14_872Z-debug.log
I had initially used npm
instead of yarn
and figured that was the problem, since yarn
supports the resolutions
field in package.json
and npm
doesn't. But no matter what I did, I couldn't convince npm/node-gyp
to resolve to 10.2.0
.
Things I've tried:
- Deleting
package-lock.json
before runningyarn install
- Verifying the string
9.4.0
appears nowhere inyarn.lock
- Nuking
node_modules
and reinstalling - Adding a
"npm/node-gyp": "^10.2.0",
line into theresolutions
field (was just trying random stuff at this point)
I can't seem to convince yarn
that npm/node-gyp
should be using 10.2.0
. This might need some more voodoo — or maybe we just have to update our npm-cli fork to point to 10.2.0
.
Thank you for the review, I can confirm now, after extra effort to ensure I believe the It's also possible git repo
CONCLUSION: Okay, so this needs some messing around with our fork of |
Includes an edition of nodejs/gyp-next which vendors Python 'packaging' library and moves away from 'distutils', which used to be shipped with Python, but was deprecated, and then dropped starting in Python 3.12. --- This solves an error -- Python 3.12 users without 'distutils' (or 'setuptools' which provides 'distutils') on their systems would get an error like the following when trying to build native C/C++ code: ``` from distutils.version import StrictVersion ModuleNotFoundError: No module named 'distutils' ``` Newer gyp-next 0.16.0+ (and by extension node-gyp 10+) avoids the error by not depending on the library that was dropped from being included "out of the box" with Python as of Python 3.12. (It vendors 'packaging' module to do its version string parsing, rather than relying on the now-missing 'distutils'.)
node-gyp v10 bumped its `engines` field and dropped Node 14 support. Well... we're going to test CI against Node v14 anyway. So ignore the `engines` fields of the packages we're installing, even if they claim not to support Node 14.
I'm pushing a rebased version on top of the latest |
b49662c
to
4d026b5
Compare
This version of our fork of npm-cli stops bundling dependencies under npm-cli's node_modules dir (in the npm-cli tarball itself), allowing ppm repo's Yarn resolutions to take precedence over npm-cli's (and its sub-dependencies') specified version of dependencies such as node-gyp. In other words, this change should make it much easier to bump the version of node-gyp included with ppm.
OK! I can confirm this much: the steps that me-from-September detailed above (for which which me-from-February is forever grateful) work swimmingly this time around. I also went into a package directory ( I admit I'm a bit curious how this will go for PulsarNext — and honestly a bit surprised that package installation works on PulsarNext at all. It's bizarre to me that, while Pulsar 1.125 runs Electron 12.2.3 and Node 14, our copy of If there aren't any scary implications of this version bump — like if everything still works the way it worked before — and the only benefit is that we don't have to make people install |
Thank you much for taking another look at this! The only thing I was worried about with the node-gyp bump is that they claim to stop supporting NodeJS 14 as of Brazen, bold, apparently it works. Anyhow: Given that CI is still running against NodeJS 14, I'm not particularly worried. As for verifying the fix to a high degree of certainty: Maybe I will try to reproduce the issue with Python 3.12 on Yes, we can stop worrying about (Long-winded tangent time) And yeah, as for what version of NodeJS ppm runs on... AFAIK it hasn't mattered in a long time. Why We could easily change it, and I have been half-meaning to at least bump to the latest patch release of NodeJS 16, even considering that 16 is fully EOL at this point! We test on 18 as well, so that is an option. I recall being reluctant to update because they keep ballooning NodeJS in size each major version, but oh, well. They want it to include everything and the kitchen sink, to obsolete some of the most essential third-party libraries, pave the cow-paths, make it batteries-included. Makes sense, I guess. Just a bit heavy as a runtime for (Last I recall, some of |
Luckily, it sounds like that's not a blocker for PulsarNext, and we can bump our |
So the next steps would be something like:
Does that sound right, @DeeDeeG? |
By the way: I still don't know what changed in the CI environment that explains why this stopped working… but now that I've looked into it, I'm more puzzled about how it ever worked in the first place. When we run The shell script downloads the correct version of node, then rebuilds (There should only be one version installed on the Windows CI image, right? I'll do a couple more quick experiments with this before I give up. I know this problem is likely going to be made irrelevant, but it would still be satisfying to be able to identify the root cause here.) |
Copy-pasting/paraphrasing from Discord...: I can happily report this fix works on my machine with Python 3.12.
|
Well, So, it should be |
Right, until I dug into the code I didn't realize that |
Includes an edition of
nodejs/gyp-next
which vendors Pythonpackaging
library and moves away fromdistutils
, which used to be shipped with Python, but was deprecated starting in Python 3.10, and then dropped starting in Python 3.12.This solves an error -- Python 3.12 users without
distutils
(or elsesetuptools
which providesdistutils
) on their systems would get an error like the following when trying to build native C/C++ code:Newer gyp-next 0.16.0+ (and by extension node-gyp 10+) avoids the error by not depending on the library that was dropped from being included "out of the box" with Python as of Python 3.12. (It vendors
packaging
module to do its version string parsing, rather than relying on the now-missingdistutils
.)