Skip to main content

A Hatch plugin to enable building a conda package from your pyproject.toml without having to write a separate conda build recipe meta.yaml file

Project description

hatch-conda-build

Conda package builder for Hatch. Hatch is modern, extensible Python project manager.

Usage

Add hatch-conda-build within the build-system.requires field in your pyproject.toml file.

[build-system]
requires = ["hatchling", "hatch-conda-build"]
build-backend = "hatchling.build"

Additionally conda-build must be in your current path when running a hatch build.

hatch-conda-build uses grayskull to translate the requirements section of your pyproject.toml, which specifies dependencies on PyPi, to appropriate conda package names.

Building Conda Package

The builder plugin defines the conda target.

To start build process, run hatch build -t conda:

$ hatch build -t conda
[conda]
...

Installing the local package

The ouptut package is written to the dist/conda directory. This directory is a fully-indexed conda channel and can be used to install the package.

$ conda install -c ./dist/conda <package-name>

Conda-build Options

Additional builder configuration can be set in the following TOML header.

[tool.hatch.build.targets.conda]
...

Following table contains available customization of builder behavior.

Option Type Default Description
channels list[str] ['conda-forge'] Channels used for package build and testing
default_numpy_version str None numpy version, otherwise use conda-build default

Modifying the generated recipe

You can specify recipe metadata keys in following TOML header

[tool.hatch.build.targets.conda.recipe]
...

Recipe metadata is defined in TOML syntax. The metadata is merged using deepmerge with the following strategies

recipe_merger = Merger(
    type_strategies=[
        (dict, ["merge"]),
        (list, ["append"])
    ],
    fallback_strategies=["override"],
    type_conflict_strategies=["override"]
)

Most importantly, this will append list values if the key already exists. For example you can use nested key TOML syntax:

[tool.hatch.build.targets.conda.recipe]
requirements.run = ["anaconda-anon-usage"]
test.imports = ["my_package"]

will append the package name anaconda-anon-usage to the autogenerated run requirements and inject the test section into the recipe before it is built.

License

Plugin hatch-conda-build is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hatch_conda_build-0.1.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

hatch_conda_build-0.1.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file hatch_conda_build-0.1.2.tar.gz.

File metadata

  • Download URL: hatch_conda_build-0.1.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for hatch_conda_build-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1385f4986f544e5a2a555404b12282266711942485b1f2eaa1b72e3ba91fbae8
MD5 00079ba452581f0eb53f727813a0f60d
BLAKE2b-256 c0107c14dbb919542cf909a46fafb4c39a6d04fb09bdc649c5f7bc9bfe7873bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for hatch_conda_build-0.1.2.tar.gz:

Publisher: release.yaml on conda-incubator/hatch-conda-build

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file hatch_conda_build-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for hatch_conda_build-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2f8febc77a658516fb7dba2c92fc59d486f5ecfd6a0b6569fb8758a13d69f81a
MD5 8bd15ea2f6621dd54d5c56a9b280d60b
BLAKE2b-256 1a484d1affb4c0e17c4398c4c7e1d36f90a95ce683a455d8a700027a0c8f567c

See more details on using hashes here.

Provenance

The following attestation bundles were made for hatch_conda_build-0.1.2-py3-none-any.whl:

Publisher: release.yaml on conda-incubator/hatch-conda-build

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page