Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions integration/installers/miniconda_versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
. "github.com/paketo-buildpacks/occam/matchers"

integration_helpers "github.com/paketo-buildpacks/python-installers/integration"
"github.com/paketo-buildpacks/python-installers/pkg/installers/miniconda"
)

func minicondaTestVersions(t *testing.T, context spec.G, it spec.S) {
Expand Down Expand Up @@ -81,7 +82,7 @@ func minicondaTestVersions(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_MINICONDA_VERSION": firstMinicondaVersion}).
WithEnv(map[string]string{miniconda.EnvVersion: firstMinicondaVersion}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), firstLogs.String)

Expand Down Expand Up @@ -110,7 +111,7 @@ func minicondaTestVersions(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_MINICONDA_VERSION": secondMinicondaVersion}).
WithEnv(map[string]string{miniconda.EnvVersion: secondMinicondaVersion}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), secondLogs.String)

Expand Down
5 changes: 3 additions & 2 deletions integration/installers/pip_layer_reuse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
. "github.com/paketo-buildpacks/occam/matchers"

integration_helpers "github.com/paketo-buildpacks/python-installers/integration"
"github.com/paketo-buildpacks/python-installers/pkg/installers/pip"
)

func pipTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
Expand Down Expand Up @@ -160,7 +161,7 @@ func pipTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_PIP_VERSION": dependencies[0].Version}).
WithEnv(map[string]string{pip.EnvVersion: dependencies[0].Version}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), logs.String)

Expand All @@ -179,7 +180,7 @@ func pipTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_PIP_VERSION": dependencies[1].Version}).
WithEnv(map[string]string{pip.EnvVersion: dependencies[1].Version}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), logs.String)

Expand Down
5 changes: 3 additions & 2 deletions integration/installers/pipenv_layer_reuse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
. "github.com/paketo-buildpacks/occam/matchers"

integration_helpers "github.com/paketo-buildpacks/python-installers/integration"
"github.com/paketo-buildpacks/python-installers/pkg/installers/pipenv"
)

func pipenvTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
Expand Down Expand Up @@ -143,7 +144,7 @@ func pipenvTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_PIPENV_VERSION": dependencies[0].Version}).
WithEnv(map[string]string{pipenv.EnvVersion: dependencies[0].Version}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), logs.String)

Expand All @@ -154,7 +155,7 @@ func pipenvTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_PIPENV_VERSION": dependencies[1].Version}).
WithEnv(map[string]string{pipenv.EnvVersion: dependencies[1].Version}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), logs.String)

Expand Down
5 changes: 3 additions & 2 deletions integration/installers/pixi_layer_reuse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
. "github.com/paketo-buildpacks/occam/matchers"

integration_helpers "github.com/paketo-buildpacks/python-installers/integration"
"github.com/paketo-buildpacks/python-installers/pkg/installers/pixi"
)

func pixiTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
Expand Down Expand Up @@ -157,7 +158,7 @@ func pixiTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_PIXI_VERSION": dependencies[0].Version}).
WithEnv(map[string]string{pixi.EnvVersion: dependencies[0].Version}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), logs.String)

Expand All @@ -175,7 +176,7 @@ func pixiTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_PIXI_VERSION": dependencies[2].Version}).
WithEnv(map[string]string{pixi.EnvVersion: dependencies[2].Version}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), logs.String)

Expand Down
5 changes: 3 additions & 2 deletions integration/installers/poetry_versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
. "github.com/paketo-buildpacks/occam/matchers"

integration_helpers "github.com/paketo-buildpacks/python-installers/integration"
"github.com/paketo-buildpacks/python-installers/pkg/installers/poetry"
)

func poetryTestVersions(t *testing.T, context spec.G, it spec.S) {
Expand Down Expand Up @@ -82,7 +83,7 @@ func poetryTestVersions(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_POETRY_VERSION": firstPoetryVersion}).
WithEnv(map[string]string{poetry.EnvVersion: firstPoetryVersion}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), firstLogs.String)

Expand Down Expand Up @@ -112,7 +113,7 @@ func poetryTestVersions(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_POETRY_VERSION": secondPoetryVersion}).
WithEnv(map[string]string{poetry.EnvVersion: secondPoetryVersion}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), secondLogs.String)

Expand Down
5 changes: 3 additions & 2 deletions integration/installers/uv_layer_reuse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
. "github.com/paketo-buildpacks/occam/matchers"

integration_helpers "github.com/paketo-buildpacks/python-installers/integration"
"github.com/paketo-buildpacks/python-installers/pkg/installers/uv"
)

func uvTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
Expand Down Expand Up @@ -157,7 +158,7 @@ func uvTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_UV_VERSION": dependencies[0].Version}).
WithEnv(map[string]string{uv.EnvVersion: dependencies[0].Version}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), logs.String)

Expand All @@ -175,7 +176,7 @@ func uvTestLayerReuse(t *testing.T, context spec.G, it spec.S) {
settings.Buildpacks.PythonInstallers.Online,
settings.Buildpacks.BuildPlan.Online,
).
WithEnv(map[string]string{"BP_UV_VERSION": dependencies[2].Version}).
WithEnv(map[string]string{uv.EnvVersion: dependencies[2].Version}).
Execute(name, source)
Expect(err).ToNot(HaveOccurred(), logs.String)

Expand Down
4 changes: 3 additions & 1 deletion pkg/installers/miniconda/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const (

// DepName is the name of the metadata.dependencies id
DepId = "miniconda3"

EnvVersion = "BP_MINICONDA_VERSION"
)

// Priorities is a list of possible places where the buildpack could look for a
// specific version of miniconda3 to install, ordered from highest to lowest priority.
var Priorities = []interface{}{"BP_MINICONDA_VERSION"}
var Priorities = []interface{}{EnvVersion}
4 changes: 2 additions & 2 deletions pkg/installers/miniconda/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ func Detect() packit.DetectFunc {
return func(context packit.DetectContext) (packit.DetectResult, error) {
var requirements []packit.BuildPlanRequirement

if version, ok := os.LookupEnv("BP_MINICONDA_VERSION"); ok {
if version, ok := os.LookupEnv(EnvVersion); ok {
requirements = []packit.BuildPlanRequirement{
{
Name: Conda,
Metadata: build.BuildPlanMetadata{
VersionSource: "BP_MINICONDA_VERSION",
VersionSource: EnvVersion,
Version: version,
},
},
Expand Down
8 changes: 4 additions & 4 deletions pkg/installers/miniconda/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Expect(result).To(Equal(packit.DetectResult{
Plan: packit.BuildPlan{
Provides: []packit.BuildPlanProvision{
{Name: "conda"},
{Name: miniconda.Conda},
},
},
}))
Expand All @@ -48,7 +48,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {

context("when BP_MINICONDA_VERSION is set", func() {
it.Before(func() {
t.Setenv("BP_MINICONDA_VERSION", "some-version")
t.Setenv(miniconda.EnvVersion, "some-version")
})

it("returns a build plan that provides the version of conda from BP_MINICONDA_VERSION", func() {
Expand All @@ -57,14 +57,14 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {

Expect(result.Plan).To(Equal(packit.BuildPlan{
Provides: []packit.BuildPlanProvision{
{Name: "conda"},
{Name: miniconda.Conda},
},
Requires: []packit.BuildPlanRequirement{
{
Name: "conda",
Metadata: build.BuildPlanMetadata{
Version: "some-version",
VersionSource: "BP_MINICONDA_VERSION",
VersionSource: miniconda.EnvVersion,
},
},
},
Expand Down
20 changes: 12 additions & 8 deletions pkg/installers/pip/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@

package pip

// Pip is the name of the layer into which pip dependency is installed.
const Pip = "pip"
const (
// Pip is the name of the layer into which pip dependency is installed.
Pip = "pip"

const PipSrc = "pip-source"
PipSrc = "pip-source"

// CPython is the name of the python runtime dependency provided by the CPython buildpack: https://github.com/paketo-buildpacks/cpython
const CPython = "cpython"
// CPython is the name of the python runtime dependency provided by the CPython buildpack: https://github.com/paketo-buildpacks/cpython
CPython = "cpython"

// DependencyChecksumKey is the name of the key in the pip layer TOML whose value is pip dependency's SHA256.
const DependencyChecksumKey = "dependency_checksum"
// DependencyChecksumKey is the name of the key in the pip layer TOML whose value is pip dependency's SHA256.
DependencyChecksumKey = "dependency_checksum"

EnvVersion = "BP_PIP_VERSION"
)

// Priorities is a list of possible places where the buildpack could look for a
// specific version of Pip to install, ordered from highest to lowest priority.
var Priorities = []interface{}{"BP_PIP_VERSION"}
var Priorities = []interface{}{EnvVersion}
4 changes: 2 additions & 2 deletions pkg/installers/pip/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

// Return a pip requirement
func GetVersionedRequirement() *packit.BuildPlanRequirement {
pipVersion := os.Getenv("BP_PIP_VERSION")
pipVersion := os.Getenv(EnvVersion)
if pipVersion == "" {
return nil
}
Expand All @@ -33,7 +33,7 @@ func GetVersionedRequirement() *packit.BuildPlanRequirement {
return &packit.BuildPlanRequirement{
Name: Pip,
Metadata: build.BuildPlanMetadata{
VersionSource: "BP_PIP_VERSION",
VersionSource: EnvVersion,
Version: pipVersion,
},
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/installers/pip/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {

context("when BP_PIP_VERSION is set", func() {
it.Before(func() {
t.Setenv("BP_PIP_VERSION", "some-version")
t.Setenv(pip.EnvVersion, "some-version")
})

it("returns a build plan that provides the version of pip from BP_PIP_VERSION", func() {
Expand All @@ -73,7 +73,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Name: pip.Pip,
Metadata: build.BuildPlanMetadata{
Version: "some-version",
VersionSource: "BP_PIP_VERSION",
VersionSource: pip.EnvVersion,
},
},
},
Expand All @@ -82,7 +82,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {

context("when the provided version is of the form X.Y", func() {
it.Before(func() {
t.Setenv("BP_PIP_VERSION", "2.11")
t.Setenv(pip.EnvVersion, "2.11")
})

it("selects the version X.Y.0", func() {
Expand All @@ -105,7 +105,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Name: pip.Pip,
Metadata: build.BuildPlanMetadata{
Version: "2.11.0",
VersionSource: "BP_PIP_VERSION",
VersionSource: pip.EnvVersion,
},
},
},
Expand All @@ -115,7 +115,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {

context("when the provided version is of the form X.Y.Z", func() {
it.Before(func() {
t.Setenv("BP_PIP_VERSION", "22.1.3")
t.Setenv(pip.EnvVersion, "22.1.3")
})

it("selects the exact provided version X.Y.Z", func() {
Expand All @@ -138,7 +138,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Name: pip.Pip,
Metadata: build.BuildPlanMetadata{
Version: "22.1.3",
VersionSource: "BP_PIP_VERSION",
VersionSource: pip.EnvVersion,
},
},
},
Expand All @@ -148,7 +148,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {

context("when the provided version is of some other form", func() {
it.Before(func() {
t.Setenv("BP_PIP_VERSION", "some.other")
t.Setenv(pip.EnvVersion, "some.other")
})

it("selects the exact provided version", func() {
Expand All @@ -171,7 +171,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Name: pip.Pip,
Metadata: build.BuildPlanMetadata{
Version: "some.other",
VersionSource: "BP_PIP_VERSION",
VersionSource: pip.EnvVersion,
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion pkg/installers/pipenv/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const (
DependencyChecksumKey = "dependency_checksum"
CPython = "cpython"
Pip = "pip"
EnvVersion = "BP_PIPENV_VERSION"
)

var Priorities = []interface{}{"BP_PIPENV_VERSION"}
var Priorities = []interface{}{EnvVersion}
4 changes: 2 additions & 2 deletions pkg/installers/pipenv/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ func Detect() packit.DetectFunc {

requirements = append(requirements, pip.GetRequirement())

pipEnvVersion, ok := os.LookupEnv("BP_PIPENV_VERSION")
pipEnvVersion, ok := os.LookupEnv(EnvVersion)
if ok {
requirements = append(requirements, packit.BuildPlanRequirement{
Name: Pipenv,
Metadata: build.BuildPlanMetadata{
Version: pipEnvVersion,
VersionSource: "BP_PIPENV_VERSION",
VersionSource: EnvVersion,
},
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/installers/pipenv/detect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {

context("when BP_PIPENV_VERSION is set", func() {
it.Before(func() {
t.Setenv("BP_PIPENV_VERSION", "1.2.3")
t.Setenv(pipenv.EnvVersion, "1.2.3")
})

it("returns a plan that provides a specific pipenv version", func() {
Expand Down Expand Up @@ -102,7 +102,7 @@ func testDetect(t *testing.T, context spec.G, it spec.S) {
Name: pipenv.Pipenv,
Metadata: build.BuildPlanMetadata{
Version: "1.2.3",
VersionSource: "BP_PIPENV_VERSION",
VersionSource: pipenv.EnvVersion,
},
},
},
Expand Down
4 changes: 3 additions & 1 deletion pkg/installers/pixi/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ const (
DepKey = "dependency-sha"

PixiArchiveTemplateName = "uv-%s-unknown-linux-musl"

EnvVersion = "BP_PIXI_VERSION"
)

var Priorities = []interface{}{
"BP_PIXI_VERSION",
EnvVersion,
}
Loading
Loading