Getting started
Introduction#
Next to managing workflows and environments, pixi can also build packages. This is useful for the following reasons:
- Building and uploading a package to a conda channel
- Allowing users to directly depend on the source and build it automatically
- Managing multiple packages in a workspace
We've been working to support these use-cases with the build
feature in pixi.
The vision is to enable building of packages from source, for any language, on any platform.
Known limitations
Currently, the build
feature has a number of limitations:
- Limited set of build-backends.
- Build-backends are probably missing a lot of parameters/features.
- Recursive source dependencies are not supported. ( source dependencies that have source dependencies )
- Workspace dependencies cannot be inherited.
Setting up the Manifest#
# Specifies properties for the whole workspace
[workspace]
preview = ["pixi-build"]
channels = ["https://prefix.dev/conda-forge"]
platforms = ["win-64", "linux-64", "osx-arm64", "osx-64"]
# There can be multiple packages in a workspace
# In `package` you specify properties specific to the package
[package]
name = "simple_python"
version = "0.1.0"
# Here the build system of the package is specified
# We are using `pixi-build-python` in order to build a Python package
[build-system]
build-backend = { name = "pixi-build-python", version = "*" }
channels = [
"https://prefix.dev/pixi-build-backends",
"https://prefix.dev/conda-forge",
]
# The Python package `simple_python` uses `hatchling` as Python build backend
[host-dependencies]
hatchling = "*"
# We add our package as dependency to the workspace
[dependencies]
simple_python = { path = "." }
Since the build feature is still in preview, you have to add "pixi-build" to workspace.preview
.
In package
you specify properties specific to the package you want to build.
Packages are built by using build backends.
By specifying package.build-system.build-backend
and package.build-system.channels
you determine which backend is used and from which channel it will be downloaded.
In this example, we are using pixi-build-python
in order to build a Python package.
[build-system]
build-backend = { name = "pixi-build-python", version = "*" }
channels = [
"https://prefix.dev/pixi-build-backends",
"https://prefix.dev/conda-forge",
]
- Specifies workspace properties like the name, channels, and platforms. This is currently an alias for
project
. - Since the build feature is still in preview, you have to add "pixi-build" to
workspace.preview
. - We need to add our package as dependency to the workspace.
- In
package
you specify properties specific to the package you want to build. - Packages are built by using build backends.
By specifying
build-system.build-backend
andbuild-system.channels
you determine which backend is used and from which channel it will be downloaded. - There are different build backends.
Pixi backends can describe how to build a conda package, for a certain language or build tool.
For example,
pixi-build-python
, allows building a Python package into a conda package. simple_python
useshatchling
as Python build backend so this needs to be mentioned inhost-dependencies
. Read up on host-dependencies in the Dependency Types- Python PEP517 backends like
hatchling
know how to build a Python package. Sohatchling
creates a Python package, andpixi-build-python
turns the Python package into a conda package.
CLI Commands#
Using the preview feature you can now build packages from source.
pixi build
has been added and will build a.conda
file out of your package.- Other commands like
pixi install
andpixi run
automatically make use of the build feature when apath
,git
orurl
dependency is present.