-
Notifications
You must be signed in to change notification settings - Fork 293
Build native dependencies with spaces in apm's path #673
Conversation
775af07 to
14004d9
Compare
|
@smashwilson what's the story here for Windows? |
|
@BinaryMuse Windows should be unaffected, as Windows users will go in through I should verify that |
|
I have been installing packages with native dependencies fine on Windows, and I know @damieng has as well. Both of us have spaces in the directory path. |
|
@50Wliu Perfect. I just confirmed that this works: |
| opts.streaming = true if @verbose | ||
|
|
||
| @fork @atomNodeGypPath, installNodeArgs, opts, (code, stderr='', stdout='') -> | ||
| atomNodeGypPath = process.env.ATOM_NODE_GYP_PATH or require.resolve('node-gyp/bin/node-gyp') |
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.
This feels a bit weird to me. I poked around a bit trying to use @npm.config.get('node-gyp') but that's pointed to the node_modules/.bin/ symlink, not the node-gyp.js script, so @fork wasn't happy with it, and I didn't want to swap it out for a @spawn because it looked important to preserve the node executable.
|
@BinaryMuse I'd appreciate a look-over when you get the chance 😁 |
Requirements
Description of the Change
Currently, Atom Beta is unable to install packages that directly or transitively include a native dependency, because the Makefile that
node-gypgenerate includes whitespace in a dependency list, causing the following failure:This PR works around the issue by providing a custom Makefile generator that escapes these paths.
Passing the custom generator to gyp is a bit... involved.
node-gyphardcodes an-fmakeargument to the gyp invocation and doesn't provide a mechanism to pass a custom--format. To work around this, I've introduced apython-interceptor.shscript that's passed to npm asPYTHON, which node-gyp will exec to invoke gyp.python-interceptor.shdirectly execs the real Python binary preserving all arguments as-is, except when it's running the gyp entrypoint, in which case it detects and removes any-for--formatarguments and replaces them with a--formatargument that invokes the custom generator.Because
gypassumes that paths don't contain a-character, the custom generator is provided togypby adding its containing directory toPYTHONPATHand specifying the generator as<modulename>.py. That triggersgyp's module file importing logic to import the correct module name, but by manipulating thePYTHONPATHourselves we sidestep the-split earlier.Alternate Designs
The best option here is to fix the problem at the source. It's a one-line fix upstream in node-gyp. I do intend to file a PR there, but I'd rather have this a temporary fix we can 🚢 independently until that works its way through the pipeline of getting feedback and getting merged 👉 being released in node-gyp 👉 being released in npm.
Benefits
The immediate benefit is that
apm-beta installorupgradecommands will succeed for packages that include native dependencies, from the commandline or within the Atom UI.It requires no action on the part of either npm package authors or
apmusers for builds to succeed.Possible Drawbacks
The
python-interceptor.shscript relies on the presence of a/bin/bashbinary that understands arrays. There may be Linux distros where that is not true.Applicable Issues