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

feat: Export conda environment.yml #2003

Merged
merged 23 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1ff98c3
export conda explicit specification file from project
synapticarbors Aug 21, 2024
5a26aed
fix formatting errors
synapticarbors Aug 21, 2024
63479bb
refactor export conda explicit to dump multiple spec files
synapticarbors Aug 25, 2024
bf436ee
Merge remote-tracking branch 'upstream/main' into export-conda-explicit
synapticarbors Aug 25, 2024
c1a4e30
update export conda_explicit_spec cli docs
synapticarbors Aug 25, 2024
00007d4
Remove pypi functionality from export conda explicit spec
synapticarbors Sep 5, 2024
272e8b3
fix whitespace issue
synapticarbors Sep 5, 2024
288e900
feat: Export conda environment.yml
abkfenris Sep 7, 2024
8ba6606
Merge remote-tracking branch 'upstream/main' into export-conda-yaml
abkfenris Sep 10, 2024
0046c8b
Specify the environment for the platform specific test
abkfenris Sep 11, 2024
62871d4
Don't fail on features that don't have dependencies in a feature
abkfenris Sep 11, 2024
be4a174
Removed args should be removed from tests as well
abkfenris Sep 11, 2024
8dc6b53
Apply suggestions from code review
abkfenris Sep 16, 2024
42ccb4f
Add some initial downstream tests and apply suggestions
abkfenris Sep 16, 2024
a54dbad
Removed failing test (needs environment variable?), and cd into manif…
abkfenris Sep 17, 2024
b39f100
Disable windows env export tests
abkfenris Sep 17, 2024
c4066b3
Include CLI suggested changes
abkfenris Sep 17, 2024
600e59d
Merge remote-tracking branch 'upstream/main' into export-conda-yaml
abkfenris Sep 17, 2024
72c95b5
Show commands to make export test script easier to understand
abkfenris Sep 17, 2024
a2bff2b
Filter export tests
abkfenris Sep 17, 2024
5053348
Make sure export tests depend on the build
abkfenris Sep 17, 2024
7cb1b59
Merge remote-tracking branch 'upstream/main' into export-conda-yaml
abkfenris Sep 17, 2024
0af9012
Fix workflow formatting
abkfenris Sep 17, 2024
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
29 changes: 29 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,35 @@ jobs:
- build
uses: ./.github/workflows/test_downstream.yml

export-filter:
name: Only run example tests if relevant code or manifests have changed
runs-on: ubuntu-20.04
needs:
- build
outputs:
exports: ${{ steps.filter.outputs.exports }}

steps:
- name: checkout repo
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
exports:
- src/cli/project/export/conda_environment.rs
- src/cli/project/export/test-data/testenv/*
- examples/pypi-source-deps/*
- examples/pypi-custom-registry/*
- examples/pypi-find-links/*
- examples/docker/*

export_tests:
name: "Export tests"
needs: export-filter
if: ${{ needs.export-filter.outputs.exports == 'true' }}
uses: ./.github/workflows/test_exports.yml

test_common_wheels:
name: "Test installation of common wheels"
needs:
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/test_exports.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: "Test exports"

on:
workflow_call:


jobs:
test-export:
name: ${{ matrix.arch.name }} - Export Tests
runs-on: ${{ matrix.arch.os }}
strategy:
fail-fast: false
matrix:
arch:
# Linux
- {
target: x86_64-unknown-linux-musl,
os: ubuntu-20.04,
name: "Linux",
}
# MacOS
- { target: x86_64-apple-darwin, os: macos-13, name: "MacOS-x86" }
- { target: aarch64-apple-darwin, os: macos-14, name: "MacOS-arm" } # macOS-14 is the ARM chipset
# # Windows
# - {
# target: x86_64-pc-windows-msvc,
# os: windows-latest,
# extension: .exe,
# name: "Windows",
# }
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: setup micromamba
uses: mamba-org/[email protected]
- name: Download binary from build
uses: actions/download-artifact@v4
with:
name: pixi-${{ matrix.arch.target }}${{ matrix.arch.extension }}
path: pixi_bin
- name: Debug
run: |
pwd
- name: Setup unix binary, add to github path
if: matrix.arch.name != 'Windows'
run: |
mv pixi_bin/pixi-${{ matrix.arch.target }} pixi_bin/pixi
chmod a+x pixi_bin/pixi
echo "$(pwd)/pixi_bin" >> $GITHUB_PATH
- name: Create Directory and Move Executable
if: matrix.arch.name == 'Windows' && matrix.arch.target == 'x86_64-pc-windows-msvc'
run: |
New-Item -ItemType Directory -Force -Path "D:\.pixi"
Move-Item -Path "pixi_bin/pixi-${{ matrix.arch.target }}${{ matrix.arch.extension }}" -Destination "D:\.pixi\pixi.exe"
shell: pwsh
- name: Add to PATH
if: matrix.arch.name == 'Windows' && matrix.arch.target == 'x86_64-pc-windows-msvc'
run: echo "D:\.pixi" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_PATH
shell: pwsh
- name: Verify and Use Executable
if: matrix.arch.name == 'Windows' && matrix.arch.target == 'x86_64-pc-windows-msvc'
run: |
echo "Current PATH: $env:PATH"
pixi --version
shell: pwsh
- name: Help
run: pixi --help
- name: Info
run: pixi info
- name: Install pixi
run: pixi install -v
- name: Test export
shell: bash
run: bash tests/test_export.sh
23 changes: 23 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1178,6 +1178,29 @@ List the environments in the manifest file.
pixi project environment list
```

### `project export conda_environment`

Exports a conda [`environment.yml` file](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-from-an-environment-yml-file). The file can be used to create a conda environment using conda/mamba:

```shell
pixi project export conda-environment environment.yml
mamba create --name <env> --file environment.yml
```

##### Arguments

1. `<OUTPUT_PATH>`: Optional path to render environment.yml to. Otherwise it will be printed to standard out.

##### Options

- `--environment <ENVIRONMENT> (-e)`: Environment to render.
- `--platform <PLATFORM> (-p)`: The platform to render.

```sh
pixi project export conda-environment --environment lint
pixi project export conda-environment --platform linux-64 environment.linux-64.yml
```

### `project export conda_explicit_spec`

Render a platform-specific conda [explicit specification file](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#building-identical-conda-environments)
Expand Down
6 changes: 6 additions & 0 deletions docs/switching_from/conda.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ pixi init --import environment.yml
```
This will create a new project with the dependencies from the `environment.yml` file.

??? tip "Exporting your environment"
If you are working with Conda users or systems, you can [export your environment to a `environment.yml`](../reference/cli.md#project-export-conda_environment) file to share them.
```shell
pixi project export conda
```
Additionally you can export a [conda explicit specification](../reference/cli.md#project-export-conda_explicit_spec).

## Troubleshooting
Encountering issues? Here are solutions to some common problems when being used to the `conda` workflow:
Expand Down
Loading
Loading