poetryrun

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

Poetry Run Cloud Native Buildpack

gcr.io/paketo-buildpacks/poetry-run

The Paketo Poetry Run CNB sets the start command for a given poetry application. The buildpack expects that the app contains a valid pyproject.toml at the root, and that it has exactly one poetry script.

More specifically, the buildpack requires that pyproject.toml looks like the following:

[tool.poetry.scripts]
some-script = "some.module:some_method"

The resulting start command for this example would be poetry run some-script.

See the poetry run documentation for more information.

Integration

This buildpacks writes a start command, so currently there is no conceivable reason to require it as a dependency.

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 <path/to/cpython.cnb> -b <path/to/pip.cnb> -b <path/to/poetry.cnb> -b <path/to/poetry-install.cnb> -b build/buildpackage.cnb

Application Detection

This buildpack detects on the presence of exactly one poetry script defined in pyproject.toml. More specifically, the buildpack will detect if pyproject.toml looks like the following:

[tool.poetry.scripts]
some-script = "some.module:some_method"

Run Tests

To run all unit tests, run:

./scripts/unit.sh

To run all integration tests, run:

/scripts/integration.sh

Known issues and limitations

  • Only one (and exactly one) script may be defined in the pyproject.toml file. Zero scripts, or multiple scripts, will result in the buildpack failing detection and therefore not participating in the order group.

Documentation

Index

Constants

View Source
const CPython = "cpython"

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

View Source
const CacheLayerName = "cache"

CacheLayerName holds the poetry cache.

View Source
const Poetry = "poetry"

Poetry is the name of the dependency provided by the Poetry buildpack: https://github.com/paketo-buildpacks/poetry.

View Source
const PoetryVenv = "poetry-venv"

PoetryVenv is the name of the dependency provided by the Poetry Install buildpack.

View Source
const VenvLayerName = "poetry-venv"

VenvLayerName is the name of the layer where the venv dependencies are installed to.

Variables

This section is empty.

Functions

func Build

func Build(pyProjectParser PyProjectParser, logger scribe.Emitter) packit.BuildFunc

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

Build assigns the image a launch process of 'poetry run <script>' where <script> is the key of the only script present for Poetry to run.

func Detect

func Detect(pyProjectParser PyProjectParser) packit.DetectFunc

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

Detection will contribute a Build Plan that provides site-packages, and requires cpython and pip at build.

Detection is contingent on there being one or more scripts to run defined in the pyproject.toml under [tool.poetry.scripts]

Types

type BuildPlanMetadata

type BuildPlanMetadata struct {
	// Build denotes the dependency is needed at build-time.
	Launch bool `toml:"launch"`
}

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

type PyProjectConfig

type PyProjectConfig struct {
	Tool struct {
		Poetry struct {
			Scripts map[string]string `toml:"scripts"`
		} `toml:"poetry"`
	} `toml:"tool"`
}

type PyProjectConfigParser

type PyProjectConfigParser struct {
}

func NewPyProjectConfigParser

func NewPyProjectConfigParser() PyProjectConfigParser

func (PyProjectConfigParser) Parse

func (p PyProjectConfigParser) Parse(filepath string) (string, error)

Parse returns the name of the script for Poetry to execute If there is no file, no script to run, or multiple scripts to run, Parse returns an empty string and a nil error If there is an error reading the file, Parse returns an error

type PyProjectParser

type PyProjectParser interface {
	Parse(string) (string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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