paketo-buildpacks / nodejs

A Cloud Native Buildpack for Node.JS
Apache License 2.0
55 stars 20 forks source link

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

Open ryanmoran opened 1 year ago

ryanmoran commented 1 year ago

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 commented 1 year ago

cc/ @voor

robdimsdale commented 1 year ago

@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?

ryanmoran commented 1 year ago

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 commented 1 year ago

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