miniconda

package module
v0.10.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

Miniconda Cloud Native Buildpack

The Paketo Buildpack for Miniconda is a Cloud Native Buildpack that installs miniconda into a layer and makes it available on the PATH.

The buildpack is published for consumption at gcr.io/paketo-buildpacks/miniconda.

Configuration

Environment Variable Description
$BP_MINICONDA_SOLVER Configure the solver to be used (current valid value is mamba)

Integration

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

[[requires]]

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

  # The version of the conda 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 "4.*", "4.7.*", or even
  # "4.7.12".
  version = "4.7.12"

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

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

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

Usage

To package this buildpack for consumption:

$ ./scripts/package.sh --version <version-number>

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 build/buildpackage.cnb -b <other-buildpacks..>

To use the mamba solver:

pack build <app-name> \
           --env BP_MINICONDA_SOLVER=mamba \
           -p <path-to-app> \
           -b build/buildpackage.cnb \
           -b <other-buildpacks..>

Vendoring

Follow these steps to vendor python packages in your app using conda

Prerequisites

  • Must be run on linux OS and case-sensitive file system
  • Install conda build tools: conda install conda-build

Steps

  1. cd <my_conda_app>
  2. Create environment.yml file in the root of your app
  3. CONDA_PKGS_DIRS=vendor/noarch conda env create -f environment.yml -n <env_name>
  4. conda index vendor
  5. conda list -n <env_name> -e > package-list.txt
  6. Commit environment.yml, vendor, and package-list.txt

Documentation

Index

Constants

View Source
const (
	// This is the key name that we use to store the sha of the script we
	// download in the layer metadata, which is used to determine if the conda
	// layer can be resued on during a rebuild.
	DepKey = "dependency-sha"
)

Variables

This section is empty.

Functions

func Build

func Build(
	dependencyManager DependencyManager,
	runner Runner,
	sbomGenerator SBOMGenerator,
	logger 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 miniconda dependency to download, download it into a layer, run the miniconda script to install conda into a separate 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.

Detection always passes, and will contribute a Build Plan that provides conda.

func GetEnvOrDefault added in v0.10.0

func GetEnvOrDefault(key, defaultValue string) string

Types

type DependencyManager

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

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

type Executable

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

Executable defines the interface for invoking an executable.

type Runner

type Runner interface {
	Run(runPath, layerPath string) error
}

Runner defines the interface for invoking the miniconda script downloaded as a dependency.

type SBOMGenerator added in v0.4.0

type SBOMGenerator interface {
	GenerateFromDependency(dependency postal.Dependency, dir string) (sbom.SBOM, error)
}

type ScriptRunner

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

ScriptRunner implements the Runner interface

func NewScriptRunner

func NewScriptRunner(executable Executable) ScriptRunner

NewScriptRunner creates an instance of the ScriptRunner given an Executable that runs `bash`.

func (ScriptRunner) Run

func (s ScriptRunner) Run(runPath, condaLayerPath string) error

Run invokes the miniconda script located in the given runPath, which installs conda into the a layer path designated by condaLayerPath.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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