Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pixi as an install tool #2099

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 48 additions & 9 deletions conda_smithy/configure_feedstock.py
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,34 @@ def render_github_actions_services(jinja_env, forge_config, forge_dir):
fh.write(new_file_contents)


def render_pixi(jinja_env, forge_config, forge_dir):
target_fname = os.path.join(forge_dir, "pixi.toml")
remove_file_or_dir(target_fname)
if forge_config["conda_install_tool"] != "pixi":
return
template = jinja_env.get_template("pixi.toml.tmpl")
ci_support_path = os.path.join(forge_dir, ".ci_support")
variants = []
if os.path.exists(ci_support_path):
for filename in os.listdir(ci_support_path):
if filename.endswith(".yaml"):
variant_name, _ = os.path.splitext(filename)
variants.append(variant_name)
platforms = [
platform.replace("_", "-")
for platform, service in forge_config["provider"].items()
if service
]
jaimergp marked this conversation as resolved.
Show resolved Hide resolved
new_file_contents = template.render(
smithy_version=__version__,
platforms=platforms,
variants=variants,
**forge_config,
)
with write_file(target_fname) as fh:
fh.write(new_file_contents)


def copy_feedstock_content(forge_config, forge_dir):
feedstock_content = os.path.join(conda_forge_content, "feedstock_content")
skip_files = _get_skip_files(forge_config)
Expand Down Expand Up @@ -2404,6 +2432,16 @@ def _load_forge_config(forge_dir, exclusive_config_file, forge_yml=None):
else:
config["remote_ci_setup_update"] = config["remote_ci_setup"]

_build_tools_deps = (
config["conda_build_tool_deps"].split() + config["remote_ci_setup"]
)
_build_tools_deps = MatchSpec.merge(
[dep.strip("\"'") for dep in _build_tools_deps]
)
config["build_tool_deps_dict"] = {
spec.name: str(spec.version) for spec in _build_tools_deps
}

if not config["github_actions"]["triggers"]:
self_hosted = config["github_actions"]["self_hosted"]
config["github_actions"]["triggers"] = (
Expand Down Expand Up @@ -2761,7 +2799,6 @@ def main(
)

config = _load_forge_config(forge_dir, exclusive_config_file, forge_yml)

config["feedstock_name"] = os.path.basename(forge_dir)

env = make_jinja_env(forge_dir)
Expand All @@ -2783,42 +2820,44 @@ def main(
render_info.append(
render_circle(env, config, forge_dir, return_metadata=True)
)

logger.debug("circle rendered")

render_info.append(
render_travis(env, config, forge_dir, return_metadata=True)
)

logger.debug("travis rendered")

render_info.append(
render_appveyor(env, config, forge_dir, return_metadata=True)
)

logger.debug("appveyor rendered")

render_info.append(
render_azure(env, config, forge_dir, return_metadata=True)
)

logger.debug("azure rendered")

render_info.append(
render_drone(env, config, forge_dir, return_metadata=True)
)

logger.debug("drone rendered")

render_info.append(
render_woodpecker(env, config, forge_dir, return_metadata=True)
)

logger.debug("woodpecker rendered")

render_info.append(
render_github_actions(env, config, forge_dir, return_metadata=True)
)

logger.debug("github_actions rendered")
render_github_actions_services(env, config, forge_dir)

render_github_actions_services(env, config, forge_dir)
logger.debug("github_actions services rendered")

render_pixi(env, config, forge_dir)
logger.debug("pixi config rendered")

# put azure first just in case
azure_ind = ([ri["provider_name"] for ri in render_info]).index("azure")
tmp = render_info[0]
Expand Down
5 changes: 3 additions & 2 deletions conda_smithy/data/conda-forge.json
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,8 @@
"enum": [
"conda",
"mamba",
"micromamba"
"micromamba",
"pixi"
],
"type": "string"
},
Expand All @@ -1777,7 +1778,7 @@
}
],
"default": "micromamba",
"description": "Use this option to choose which tool is used to provision the tooling in your\nfeedstock. Defaults to micromamba.\n\nIf conda or mamba are chosen, the latest Miniforge will be used to\nprovision the base environment. If micromamba is chosen, Miniforge\nis not involved; the environment is created directly by micromamba.",
"description": "Use this option to choose which tool is used to provision the tooling in your\nfeedstock. Defaults to micromamba.\n\nIf conda or mamba are chosen, the latest Miniforge will be used to\nprovision the base environment. If micromamba or pixi are chosen,\nMiniforge is not involved; the environment is created directly by\nmicromamba or pixi.",
"title": "Conda Install Tool"
},
"conda_forge_output_validation": {
Expand Down
19 changes: 10 additions & 9 deletions conda_smithy/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,20 +626,21 @@ class ConfigModel(BaseModel):
),
)

conda_install_tool: Optional[Literal["conda", "mamba", "micromamba"]] = (
Field(
default="micromamba",
description=cleandoc(
"""
conda_install_tool: Optional[
Literal["conda", "mamba", "micromamba", "pixi"]
] = Field(
default="micromamba",
description=cleandoc(
"""
Use this option to choose which tool is used to provision the tooling in your
feedstock. Defaults to micromamba.

If conda or mamba are chosen, the latest Miniforge will be used to
provision the base environment. If micromamba is chosen, Miniforge
is not involved; the environment is created directly by micromamba.
provision the base environment. If micromamba or pixi are chosen,
Miniforge is not involved; the environment is created directly by
micromamba or pixi.
"""
),
)
),
)

conda_forge_output_validation: Optional[bool] = Field(
Expand Down
18 changes: 17 additions & 1 deletion conda_smithy/templates/build_steps.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ echo > /opt/conda/conda-meta/history
micromamba install --root-prefix ~/.conda --prefix /opt/conda \
--yes --override-channels --channel conda-forge --strict-channel-priority \
pip {{ conda_install_tool_deps }} {{ conda_build_tool_deps }} {{ " ".join(remote_ci_setup) }}
{%- elif conda_install_tool == "pixi" %}
curl -fsSL https://pixi.sh/install.sh | bash
export PATH="~/.pixi/bin:$PATH"
pushd "${FEEDSTOCK_ROOT}"
arch=$(uname -m)
if [[ "$arch" == "x86_64" ]]; then
arch="64"
fi
sed -i.bak "s/platforms = .*/platforms = [\"linux-${arch}\"]/" pixi.toml
echo "Creating environment"
PIXI_CACHE_DIR=/opt/conda pixi install
pixi list
echo "Activating environment"
eval "$(pixi shell-hook)"
mv pixi.toml.bak pixi.toml
popd
{%- endif %}

{%- if conda_build_tool == "mambabuild" %}
Expand All @@ -64,7 +80,7 @@ export CONDA_LIBMAMBA_SOLVER_NO_CHANNELS_FROM_INSTALLED=1
{{ conda_install_tool }} update --update-specs --yes --quiet --channel conda-forge --strict-channel-priority \
pip {{ conda_install_tool_deps }} {{ conda_build_tool_deps }} {{ " ".join(remote_ci_setup_update) }}
{%- endif %}
{% if local_ci_setup %}
{% if conda_install_tool != "pixi" and local_ci_setup %}
beckermr marked this conversation as resolved.
Show resolved Hide resolved
conda uninstall --quiet --yes --force {{ " ".join(remote_ci_setup)}}
pip install --no-deps ${RECIPE_ROOT}/.
{%- endif %}
Expand Down
51 changes: 51 additions & 0 deletions conda_smithy/templates/pixi.toml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This file was generated automatically from conda-smithy. To update this configuration,
# update the conda-forge.yml and/or the recipe/meta.yaml.
# -*- mode: yaml -*-
jaimergp marked this conversation as resolved.
Show resolved Hide resolved

[project]
name = "{{ feedstock_name }}"
version = "{{ smithy_version }}"
description = "Pixi configuration for conda-forge/{{ feedstock_name }}"
authors = ["@conda-forge/{{ feedstock_name[:-11] }}"]
channels = ["conda-forge"]
platforms = {{ platforms }}

[dependencies]
beckermr marked this conversation as resolved.
Show resolved Hide resolved
{%- for spec_name, spec_constraints in build_tool_deps_dict.items() %}
{{ spec_name }} = "{{ spec_constraints }}"
{%- endfor %}
{%- if local_ci_setup %}

[pypi-dependencies]
conda_forge_ci_setup = { path = "./" }
{%- endif %}

[tasks]
inspect-all = "inspect_artifacts --all-packages"
{%- if conda_build_tool != "rattler-build" %}
build = "{{ conda_build_tool }} build {{ recipe_dir }}"
debug = "{{ conda_build_tool }} build {{ recipe_dir }}"
{%- else %}
build = "{{ conda_build_tool }} build --recipe {{ recipe_dir }}"
{%- endif %}
{%- for variant in variants %}
{%- if conda_build_tool != "rattler-build" %}
build-{{ variant }} = "{{ conda_build_tool }} build {{ recipe_dir }} -m .ci_support/{{ variant }}.yaml --suppress-variables --clobber-file .ci_support/clobber_{{ variant }}.yaml"
debug-{{ variant }} = "{{ conda_build_tool }} debug {{ recipe_dir }} -m .ci_support/{{ variant }}.yaml"
{%- else %}
build-{{ variant }} = "{{ conda_build_tool }} build --recipe {{ recipe_dir }} -m .ci_support/{{ variant }}.yaml"
{%- endif %}
inspect-{{ variant }} = "inspect_artifacts --recipe-dir {{ recipe_dir }} -m .ci_support/{{ variant }}.yaml"
{%- endfor %}

[feature.smithy.dependencies]
conda-smithy = "*"

[feature.smithy.tasks]
build-locally = "python ./build-locally.py"
smithy = "conda-smithy"
rerender = "conda-smithy rerender"
lint = "conda-smithy lint {{ recipe_dir}}"

[environments]
smithy = ["smithy"]
21 changes: 20 additions & 1 deletion conda_smithy/templates/run_osx_build.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ mv "${MAMBA_ROOT_PREFIX}/pkgs" "${MINIFORGE_HOME}"
echo "Cleaning up micromamba"
rm -rf "${MAMBA_ROOT_PREFIX}" "${micromamba_exe}" || true
( endgroup "Provisioning base env with micromamba" ) 2> /dev/null
{%- elif conda_install_tool == "pixi" %}
( startgroup "Provisioning base env with pixi" ) 2> /dev/null
curl -fsSL https://pixi.sh/install.sh | bash
export PATH="~/.pixi/bin:$PATH"
arch=$(uname -m)
if [[ "$arch" == "x86_64" ]]; then
arch="64"
fi
sed -i.bak "s/platforms = .*/platforms = [\"osx-${arch}\"]/" pixi.toml
echo "Creating environment"
pixi install
pixi list
echo "Activating environment"
eval "$(pixi shell-hook)"
mv pixi.toml.bak pixi.toml
( endgroup "Provisioning base env with pixi" ) 2> /dev/null
{%- else %}
( startgroup "Installing a fresh version of Miniforge" ) 2> /dev/null

Expand All @@ -57,8 +73,11 @@ bash "${MINIFORGE_FILE}" -b -p "${MINIFORGE_HOME}"
{%- set BUILD_CMD="conda-build" %}
{%- endif %}

{%- if conda_install_tool != "pixi" %}
echo "Activating environment"
source "${MINIFORGE_HOME}/etc/profile.d/conda.sh"
conda activate base
{%- endif %}
{%- if conda_solver %}
export CONDA_SOLVER="{{ conda_solver }}"
{%- endif %}
Expand All @@ -71,7 +90,7 @@ export CONDA_LIBMAMBA_SOLVER_NO_CHANNELS_FROM_INSTALLED=1
pip {{ conda_install_tool_deps }} {{ conda_build_tool_deps }} {{ " ".join(remote_ci_setup) }}
{%- endif %}

{% if local_ci_setup %}
{% if conda_install_tool != "pixi" and local_ci_setup %}
conda uninstall --quiet --yes --force {{ " ".join(remote_ci_setup) }}
pip install --no-deps {{ recipe_dir }}/.
{%- endif %}
Expand Down
43 changes: 42 additions & 1 deletion conda_smithy/templates/run_win_build.bat.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@

setlocal enableextensions enabledelayedexpansion

FOR %%A IN ("%~dp0.") DO SET "REPO_ROOT=%%~dpA"
{%- if conda_install_tool == "pixi" %}
if "%MINIFORGE_HOME%"=="" (
set "MINIFORGE_HOME=%REPO_ROOT%\.pixi\envs\default"
) else (
set "PIXI_CACHE_DIR=%MINIFORGE_HOME%"
)
{%- else %}
if "%MINIFORGE_HOME%"=="" set "MINIFORGE_HOME=%USERPROFILE%\Miniforge3"
{%- endif %}
:: Remove trailing backslash, if present
if "%MINIFORGE_HOME:~-1%"=="\" set "MINIFORGE_HOME=%MINIFORGE_HOME:~0,-1%"

Expand Down Expand Up @@ -40,6 +49,35 @@ if !errorlevel! neq 0 exit /b !errorlevel!
echo Removing %MAMBA_ROOT_PREFIX%
del /S /Q "%MAMBA_ROOT_PREFIX%"
del /S /Q "%MICROMAMBA_TMPDIR%"
{%- elif conda_install_tool == "pixi" %}
call :start_group "Provisioning base env with pixi"
echo Installing pixi
powershell -NoProfile -ExecutionPolicy unrestricted -Command "iwr -useb https://pixi.sh/install.ps1 | iex"
if !errorlevel! neq 0 exit /b !errorlevel!
set "PATH=%USERPROFILE%\.pixi\bin;%PATH%"
echo Installing environment
if "%PIXI_CACHE_DIR%"=="%MINIFORGE_HOME%" (
mkdir "%MINIFORGE_HOME%"
copy /Y pixi.toml "%MINIFORGE_HOME%"
pushd "%MINIFORGE_HOME%"
) else (
pushd "%REPO_ROOT%"
)
move /y pixi.toml pixi.toml.bak
set "arch=64"
if "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "arch=arm64"
powershell -NoProfile -ExecutionPolicy unrestricted -Command "(Get-Content pixi.toml.bak -Encoding UTF8) -replace 'platforms = .*', 'platforms = [''win-%arch%'']' | Out-File pixi.toml -Encoding UTF8"
pixi install
if !errorlevel! neq 0 exit /b !errorlevel!
pixi list
if !errorlevel! neq 0 exit /b !errorlevel!
set "ACTIVATE_PIXI=%TMP%\pixi-activate-%RANDOM%.bat"
pixi shell-hook > "%ACTIVATE_PIXI%"
if !errorlevel! neq 0 exit /b !errorlevel!
call "%ACTIVATE_PIXI%"
if !errorlevel! neq 0 exit /b !errorlevel!
move /y pixi.toml.bak pixi.toml
popd
call :end_group
{%- else %}
call :start_group "Installing a fresh version of Miniforge"
Expand All @@ -56,7 +94,10 @@ call :end_group
call :start_group "Configuring conda"

:: Activate the base conda environment
{%- if conda_install_tool != "pixi" %}
echo Activating environment
call "%MINIFORGE_HOME%\Scripts\activate.bat"
{%- endif %}

{%- if conda_solver %}
:: Configure the solver
Expand All @@ -74,7 +115,7 @@ echo Installing dependencies
if !errorlevel! neq 0 exit /b !errorlevel!
{%- endif %}

{%- if local_ci_setup %}
{%- if conda_install_tool != "pixi" and local_ci_setup %}
echo Overriding conda-forge-ci-setup with local version
conda.exe uninstall --quiet --yes --force {{ " ".join(remote_ci_setup) }}
if !errorlevel! neq 0 exit /b !errorlevel!
Expand Down
24 changes: 24 additions & 0 deletions news/2099-pixi
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**Added:**

* Added ``pixi`` as valid ``conda_install_tool`` option.
Includes several preconfigured tasks like ``build``, ``debug``, ``rerender``, or ``lint``. (#2099)

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
Loading