Skip to content

Commit

Permalink
Request cpython if there is a node-gyp dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
c0d1ngm0nk3y committed Aug 16, 2024
1 parent 0f46145 commit 37e3dc6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
1 change: 1 addition & 0 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const (
NodeModules = "node_modules"
Node = "node"
Npm = "npm"
Cpython = "cpython"

LayerNameNodeModules = "modules"
LayerNameCache = "npm-cache"
Expand Down
33 changes: 25 additions & 8 deletions detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func Detect() packit.DetectFunc {
return packit.DetectResult{}, err
}
version := pkg.GetVersion()
pythonNeeded := false
// TODO: check if a dependency to node-gyp is present

nodeDependency := packit.BuildPlanRequirement{
Name: Node,
Expand All @@ -54,21 +56,36 @@ func Detect() packit.DetectFunc {
}
}

return packit.DetectResult{
npmDependency := packit.BuildPlanRequirement{
Name: Npm,
Metadata: BuildPlanMetadata{
Build: true,
},
}

cPythonDependency := packit.BuildPlanRequirement{
Name: Cpython,
Metadata: BuildPlanMetadata{
Build: true,
},
}

result := packit.DetectResult{
Plan: packit.BuildPlan{
Provides: []packit.BuildPlanProvision{
{Name: NodeModules},
},
Requires: []packit.BuildPlanRequirement{
nodeDependency,
{
Name: Npm,
Metadata: BuildPlanMetadata{
Build: true,
},
},
npmDependency,
},
},
}, nil
}

if pythonNeeded {
result.Plan.Requires = append(result.Plan.Requires, cPythonDependency)
}

return result, nil
}
}

0 comments on commit 37e3dc6

Please sign in to comment.