Skip to content

Recipe Generation#

Generate conda recipes from various package ecosystems.

These functions fetch package metadata from upstream repositories and generate ready-to-use Stage0Recipe objects.

You can import the generation functions from rattler_build:

from rattler_build import (
    generate_pypi_recipe,
    generate_cran_recipe,
    generate_cpan_recipe,
    generate_luarocks_recipe,
)

generate_pypi_recipe#

Generate a conda recipe from a PyPI package.

Parameters:

Name Type Description Default
package str

The name of the PyPI package to generate a recipe for.

required
version str | None

Specific version of the package to use. If None, uses the latest version.

None
use_mapping bool

Whether to use conda-forge package name mappings for dependencies. This helps map PyPI names to their corresponding conda-forge package names.

True

Returns:

Type Description
Stage0Recipe

A Stage0Recipe object representing the generated recipe.

Raises:

Type Description
RuntimeError

If the package cannot be found or if there's a network error.

Example

Generate a recipe for the latest version of flit-core:

from rattler_build import generate_pypi_recipe

recipe = generate_pypi_recipe("flit-core")
recipe.as_single_output().package.name
# 'flit-core'

generate_cran_recipe#

Generate a conda recipe from a CRAN (R) package.

Parameters:

Name Type Description Default
package str

The name of the CRAN package to generate a recipe for.

required
universe str | None

The R universe to fetch the package from. Defaults to "cran" if not specified. Other options include specific R-universe repositories.

None

Returns:

Type Description
Stage0Recipe

A Stage0Recipe object representing the generated recipe.

Raises:

Type Description
RuntimeError

If the package cannot be found or if there's a network error.

Example

Generate a recipe for a CRAN package:

from rattler_build import generate_cran_recipe

recipe = generate_cran_recipe("assertthat")
recipe.as_single_output().package.name
# 'r-assertthat'

generate_cpan_recipe#

Generate a conda recipe from a CPAN (Perl) package.

Parameters:

Name Type Description Default
package str

The name of the CPAN package to generate a recipe for.

required
version str | None

Specific version of the package to use. If None, uses the latest version.

None

Returns:

Type Description
Stage0Recipe

A Stage0Recipe object representing the generated recipe.

Raises:

Type Description
RuntimeError

If the package cannot be found or if there's a network error.

Example

Generate a recipe for a CPAN package:

from rattler_build import generate_cpan_recipe

recipe = generate_cpan_recipe("Try-Tiny")
recipe.as_single_output().package.name
# 'perl-try-tiny'

generate_luarocks_recipe#

Generate a conda recipe from a LuaRocks package.

Parameters:

Name Type Description Default
rock str

The LuaRocks package specification. Can be in one of these formats: - "module" - uses the latest version - "module/version" - uses a specific version - "author/module/version" - specifies author, module and version - Direct rockspec URL

required

Returns:

Type Description
Stage0Recipe

A Stage0Recipe object representing the generated recipe.

Raises:

Type Description
RuntimeError

If the package cannot be found or if there's a network error.

Example

Generate a recipe for a LuaRocks package:

from rattler_build import generate_luarocks_recipe

recipe = generate_luarocks_recipe("luafilesystem")
recipe.as_single_output().package.name
# 'lua-luafilesystem'