nodejs icon indicating copy to clipboard operation
nodejs copied to clipboard

Install a Python interpreter at buildtime when node-gyp is used

Open ryanmoran opened this issue 2 years ago • 5 comments

Describe the Enhancement

I'd like to be able to use node-gyp to install native addons to node_modules. Some of these native addons require a Python interpreter. This will only need to be available during the build phase.

Possible Solution

This buildpack should include the cpython buildpack as an optional buildpack in all of its order groups.

Motivation

The Paketo Base stack does not have a Python interpreter installed and so requires that I use the Full stack. I'd like to eventually see Python removed from the Full stack, and I'd like to be able to compile native addons that require Python on the current Base stack as well.

ryanmoran avatar Dec 13 '22 23:12 ryanmoran

cc/ @voor

ryanmoran avatar Dec 13 '22 23:12 ryanmoran

@ryanmoran if the cpython buildpack is optional, which buildpack (if any) in nodejs build order would require it, and under what conditions?

It seems like we'd need to define both sides of the requires/provides contract, otherwise we end up with an optional buildpack that is never used. Am I missing something?

robdimsdale avatar Dec 15 '22 14:12 robdimsdale

You are totally right. Its unspecified here, but the npm-install and yarn-install buildpacks would need to detect that node-gyp is a dependency and that cpython is required.

ryanmoran avatar Dec 15 '22 17:12 ryanmoran

An example app that would require cpython through node-gyp can be found at https://github.com/Gerg/gyp-app.

ryanmoran avatar Mar 24 '23 22:03 ryanmoran

@ryanmoran This issue is rather old, but still valid I guess. It sounded handy to me first, but I am not so sure about the actual value add anymore. It would only work for very specific stacks. right? For stacks NOT having python BUT a compiler chain to build the native extensions.

That is true for the base stack, but isn't it quite specific?

And what is the difference to just use the full stack for building, but the run image from the base stack? That would basically be the same right? But with some user action.

c0d1ngm0nk3y avatar Sep 27 '24 07:09 c0d1ngm0nk3y