-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
deps: Bump node-gyp to latest ^10.2.0 for Python 3.12 compat #137
base: master
Are you sure you want to change the base?
Conversation
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.
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 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
.)