pipenv

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

Pipenv Cloud Native Buildpack

The Paketo Pipenv Buildpack is a Cloud Native Buildpack that installs pipenv into a layer and makes it available on the PATH.

The buildpack is published for consumption at gcr.io/paketo-community/pipenv and paketocommunity/pipenv.

Behavior

This buildpack always participates.

The buildpack will do the following:

  • At build time:
    • Contributes the pipenv binary to a layer
    • Prepends the pipenv layer to the PYTHONPATH
    • Adds the newly installed pipenv location to PATH
  • At run time:
    • Does nothing

Configuration

Environment Variable Description
$BP_PIPENV_VERSION Configure the version of pipenv to install. Buildpack releases (and the pipenv versions for each release) can be found here.

Integration

The Pipenv CNB provides pipenv as a dependency. Downstream buildpacks, can require the pipenv dependency by generating a Build Plan TOML file that looks like the following:

[[requires]]

  # The name of the Pipenv dependency is "pipenv". This value is considered
  # part of the public API for the buildpack and will not change without a plan
  # for deprecation.
  name = "pipenv"

  # The version of the Pipenv dependency is not required. In the case it
  # is not specified, the buildpack will provide the default version, which can
  # be seen in the buildpack.toml file.
  # If you wish to request a specific version, the buildpack supports
  # specifying a semver constraint in the form of "2018.*", "2018.11.*", or even
  # "2018.11.26".
  version = "2018.11.26"

  # The Pipenv buildpack supports some non-required metadata options.
  [requires.metadata]

    # Setting the build flag to true will ensure that the Pipenv
    # depdendency is available on the $PATH for subsequent buildpacks during
    # their build phase. If you are writing a buildpack that needs to run Pipenv
    # during its build process, this flag should be set to true.
    build = true

    # Setting the launch flag to true will ensure that the Pipenv
    # dependency is available on the $PATH for the running application. If you are
    # writing an application that needs to run Pipenv at runtime, this flag should
    # be set to true.
    launch = true

Usage

To package this buildpack for consumption:

$ ./scripts/package.sh --version x.x.x

This will create a buildpackage.cnb file under the build directory which you can use to build your app as follows: pack build <app-name> -p <path-to-app> -b <cpython-buildpack> -b <pip-buildpack> -b build/buildpackage.cnb -b <some-pipenv-consumer-buildpack>.

To run the unit and integration tests for this buildpack:

$ ./scripts/unit.sh && ./scripts/integration.sh

Documentation

Index

Constants

View Source
const (
	Pipenv           = "pipenv"
	PipFileLock      = "Pipfile.lock"
	DependencySHAKey = "dependency_sha"
	CPython          = "cpython"
	Pip              = "pip"
)

Variables

View Source
var Priorities = []interface{}{"BP_PIPENV_VERSION"}

Functions

func Build

func Build(
	entryResolver EntryResolver,
	dependencyManager DependencyManager,
	installProcess InstallProcess,
	siteProcess SitePackageProcess,
	logs scribe.Emitter,
	clock chronos.Clock,
) packit.BuildFunc

Build will return a packit.BuildFunc that will be invoked during the build phase of the buildpack lifecycle.

Build will find the right pipenv dependency to install, install it in a layer, and generate Bill-of-Materials. It also makes use of the checksum of the dependency to reuse the layer when possible.

func Detect

func Detect() packit.DetectFunc

Detect will return a packit.DetectFunc that will be invoked during the detect phase of the buildpack lifecycle.

This buildpack always passes detection and will contribute a Build Plan that provides pipenv.

If a version is provided via the $BP_PIPENV_VERSION environment variable, that version of pipenv will be a requirement.

Types

type BuildPlanMetadata

type BuildPlanMetadata struct {
	// VersionSource denotes where dependency version came from (e.g. an
	// environment variable).
	VersionSource string `toml:"version-source"`

	// Version denotes the version of a dependency, if there is one.
	Version string `toml:"version"`

	// Build denotes the dependency is needed at build-time.
	Build bool `toml:"build"`

	// Launch denotes the dependency is needed at runtime.
	Launch bool `toml:"launch"`
}

BuildPlanMetadata is the buildpack specific data included in build plan requirements.

type DependencyManager

type DependencyManager interface {
	Resolve(path, id, version, stack string) (postal.Dependency, error)
	Deliver(dependency postal.Dependency, cnbPath, destPath, platformPath string) error
	GenerateBillOfMaterials(dependencies ...postal.Dependency) []packit.BOMEntry
}

DependencyManager defines the interface for picking the best matching dependency and installing it.

type EntryResolver

type EntryResolver interface {
	Resolve(string, []packit.BuildpackPlanEntry, []interface{}) (packit.BuildpackPlanEntry, []packit.BuildpackPlanEntry)
	MergeLayerTypes(string, []packit.BuildpackPlanEntry) (launch, build bool)
}

EntryResolver defines the interface for picking the most relevant entry from the Buildpack Plan entries.

type Executable

type Executable interface {
	Execute(pexec.Execution) error
}

Executable defines the interface for invoking an executable.

type InstallProcess

type InstallProcess interface {
	Execute(srcPath, destLayerPath string) error
}

InstallProcess defines the interface for installing the pipenv dependency into a layer.

type PipenvInstallProcess

type PipenvInstallProcess struct {
	// contains filtered or unexported fields
}

func NewPipenvInstallProcess

func NewPipenvInstallProcess(executable Executable) PipenvInstallProcess

NewPipenvInstallProcess creates a PipenvInstallProcess instance.

func (PipenvInstallProcess) Execute

func (p PipenvInstallProcess) Execute(srcPath, targetLayerPath string) error

Execute installs the pipenv binary from source code located in the given srcPath into the layer path designated by targetLayerPath.

type SitePackageProcess

type SitePackageProcess interface {
	Execute(targetLayerPath string) (string, error)
}

SitePackageProcess defines the interface for looking up site packages within a layer.

type SiteProcess

type SiteProcess struct {
	// contains filtered or unexported fields
}

SiteProcess implements the Executable interface.

func NewSiteProcess

func NewSiteProcess(executable Executable) SiteProcess

NewSiteProcess creates an instance of the SiteProcess given an Executable.

func (SiteProcess) Execute

func (p SiteProcess) Execute(targetLayerPath string) (string, error)

Execute runs a python command to locate the site packages within the given targetLayerPath.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL