|
1 |
| -Every Pixi workspace is described by a Pixi manifest. |
2 |
| -In this simple example we have a single task `start` which runs a Python file and two dependencies, `cowpy` and `python`. |
| 1 | +# Basic usage of Pixi |
3 | 2 |
|
4 |
| -```toml title="pixi.toml" |
5 |
| ---8<-- "docs/source_files/pixi_workspaces/introduction/task_add/pixi.toml" |
6 |
| -``` |
| 3 | +Pixi can do alot of things, but it is designed to be simple to use. |
| 4 | +Let's go through the basic usage of Pixi. |
7 | 5 |
|
8 |
| -`channels` describes where our dependencies come from and `platforms` which platforms we support. |
9 |
| -However, you might wonder why we need to specify the platforms if Pixi could just extract this information from your operating system. |
10 |
| -That is because every dependency in your environment is stored in the lockfile called `pixi.lock`. |
11 |
| -This ensures that even if you run your workspace on a different platform, the environment will contain exactly the dependencies that were solved on your machine. |
12 |
| -This is one of the core features that makes Pixi reproducible. |
13 |
| -Learn more about lock files in [this chapter](./workspace/lockfile.md). |
| 6 | +## Managing workspaces or projects |
14 | 7 |
|
| 8 | +- [`pixi init`](./reference/cli/pixi/init.md) - create a new Pixi manifest in the current directory |
| 9 | +- [`pixi add`](./reference/cli/pixi/add.md) - add a dependency to your manifest |
| 10 | +- [`pixi remove`](./reference/cli/pixi/remove.md) - remove a dependency from your manifest |
| 11 | +- [`pixi update`](./reference/cli/pixi/update.md) - update dependencies in your manifest |
| 12 | +- [`pixi upgrade`](./reference/cli/pixi/upgrade.md) - upgrade the dependencies in your manifest to the latest versions, even if you pinned them to a specific version |
| 13 | +- [`pixi lock`](./reference/cli/pixi/lock.md) - create or update the lockfile for your manifest |
| 14 | +- [`pixi info`](./reference/cli/pixi/info.md) - show information about your workspace |
| 15 | +- [`pixi run`](./reference/cli/pixi/run.md) - run a task defined in your manifest or any command in the current environment |
| 16 | +- [`pixi shell`](./reference/cli/pixi/shell.md) - start a shell in the current environment |
| 17 | +- [`pixi list`](./reference/cli/pixi/list.md) - list all dependencies in the current environment |
| 18 | +- [`pixi tree`](./reference/cli/pixi/tree.md) - show a tree of dependencies in the current environment |
| 19 | +- [`pixi clean`](./reference/cli/pixi/clean.md) - remove the environment from your machine |
15 | 20 |
|
16 |
| -## Multiple environments |
17 |
| - |
18 |
| -We already have a quite powerful setup which is sufficient for many use cases. |
19 |
| -However, certain things are hard to do with the way things are set up right now. |
20 |
| -What if I wanted to check if my script works with multiple versions of Python? |
21 |
| -There cannot be multiple versions of the same package in one environment. |
22 |
| -Luckily, Pixi is able to manage multiple environments! |
| 21 | +## Managing global installations |
| 22 | +Pixi can manage global installations of tools and environments. |
| 23 | +It installs the environments in a central location, so you can use them from anywhere. |
23 | 24 |
|
24 |
| -Environments are composed of features, so let's create a `py312` and `py313` features each with `python` set to a different version. |
25 |
| -Then we will add those features to environments of the same name. |
26 |
| - |
27 |
| -```toml title="pixi.toml" |
28 |
| ---8<-- "docs/source_files/pixi_workspaces/introduction/multi_env/pixi.toml" |
29 |
| -``` |
| 25 | +- [`pixi global install`](./reference/cli/pixi/global/install.md) - install a package into it's own environment in the global space. |
| 26 | +- [`pixi global uninstall`](./reference/cli/pixi/global/uninstall.md) - uninstall an environment from the global space. |
| 27 | +- [`pixi global add`](./reference/cli/pixi/global/add.md) - add a package to an existing globally installed environment. |
| 28 | +- [`pixi global sync`](./reference/cli/pixi/global/sync.md) - sync the globally installed environments with the global manifest, describing all the environments you want to install. |
| 29 | +- [`pixi global edit`](./reference/cli/pixi/global/edit.md) - edit the global manifest. |
| 30 | +- [`pixi global update`](./reference/cli/pixi/global/update.md) - update the global environments |
| 31 | +- [`pixi global list`](./reference/cli/pixi/global/list.md) - list all the installed environments |
30 | 32 |
|
31 |
| -Pixi does two things behind the scenes which might not be immediately obvious. |
32 |
| -First, it automatically creates both a feature and environment called `default`. |
33 |
| -`[dependencies]` and `[tasks]` belong to that feature. |
34 |
| -Second, it adds the `default` feature to each environment unless you explicitly opt-out. |
35 |
| -That means you can read the manifest as if it were declared like this: |
| 33 | +More information: [Global Tools](./global_tools/introduction.md) |
36 | 34 |
|
37 |
| -!!! warning |
| 35 | +## Running one-off commands |
| 36 | +Pixi can run one-off commands in a specific environment. |
38 | 37 |
|
39 |
| - This written out for demonstration purposes. |
40 |
| - Don't spell "default" out like this in your own manifest, Pixi will do it for you behind the scenes. |
| 38 | +- [`pixi exec`](./reference/cli/pixi/exec.md) - run a command in a temporary environment. |
| 39 | +- [`pixi exec --spec`](./reference/cli/pixi/exec.md#arg---spec) - run a command in a temporary environment, with a specific specification. |
41 | 40 |
|
42 |
| -```toml |
43 |
| -[workspace] |
44 |
| -channels = ["conda-forge"] |
45 |
| -name = "hello-world" |
46 |
| -platforms = ["linux-64", "osx-arm64", "win-64"] |
47 |
| - |
48 |
| -# [tasks] belong to the default feature |
49 |
| -[feature.default.tasks] |
50 |
| -start = 'python hello.py' |
51 |
| - |
52 |
| -# [dependencies] belong to the default feature |
53 |
| -[feature.default.dependencies] |
54 |
| -cowpy = "1.1.*" |
55 |
| - |
56 |
| -[feature.py312.dependencies] |
57 |
| -python = "3.12.*" |
58 |
| - |
59 |
| -[feature.py313.dependencies] |
60 |
| -python = "3.13.*" |
61 |
| - |
62 |
| -[environments] |
63 |
| -# Pixi automatically creates a default environment that consists only of the default feature |
64 |
| -default = ["default"] |
65 |
| -# Unless you opt-out with `no-default-feature`, every environment contains the default feature |
66 |
| -py312 = ["default", "py312"] |
67 |
| -py313 = ["default", "py313"] |
68 |
| -``` |
69 |
| - |
70 |
| -Let's adapt the Python script so that it displays the current Python version: |
71 |
| - |
72 |
| -```py title="hello.py" |
73 |
| ---8<-- "docs/source_files/pixi_workspaces/introduction/multi_env/hello.py" |
74 |
| -``` |
75 |
| - |
76 |
| -The task `start` is available in both `py312` and `py313`, so we can test the script like this to test against Python 3.12: |
| 41 | +For example: |
77 | 42 |
|
78 | 43 | ```bash
|
79 |
| -pixi run --environment=py312 start |
| 44 | +> pixi exec python -VV |
| 45 | +Python 3.13.5 | packaged by conda-forge | (main, Jun 16 2025, 08:24:05) [Clang 18.1.8 ] |
| 46 | +> pixi exec --spec "python=3.12" python -VV |
| 47 | +Python 3.12.11 | packaged by conda-forge | (main, Jun 4 2025, 14:38:53) [Clang 18.1.8 ] |
80 | 48 | ```
|
81 | 49 |
|
82 |
| -``` |
83 |
| - _________________________ |
84 |
| -< Hello from Python 3.12! > |
85 |
| - ------------------------- |
86 |
| - \ ^__^ |
87 |
| - \ (oo)\_______ |
88 |
| - (__)\ )\/\ |
89 |
| - ||----w | |
90 |
| - || || |
91 |
| -``` |
| 50 | +## Multiple environments |
| 51 | +Pixi workspaces allow you to manage multiple environments. |
| 52 | +An environment is build out of one or multiple features. |
92 | 53 |
|
93 |
| -And we can run this command to try it with Python 3.13: |
| 54 | +- [`pixi add --feature`](./reference/cli/pixi/add.md#arg---feature) - add a package to a feature |
| 55 | +- [`pixi task add --feature`](./reference/cli/pixi/task/add.md#arg---feature) - add a task to a specific feature |
| 56 | +- [`pixi workspace environment add`](./reference/cli/pixi/workspace/environment/add.md) - add an environment to the workspace |
| 57 | +- [`pixi run --environment`](./reference/cli/pixi/run.md#arg---environment) - run a command in a specific environment |
| 58 | +- [`pixi shell --environment`](./reference/cli/pixi/shell.md#arg---environment) - activate a specific environment |
| 59 | +- [`pixi list --environment`](./reference/cli/pixi/list.md#arg---environment) - list the dependencies in a specific environment |
94 | 60 |
|
| 61 | +More information: [Multiple environments](./workspace/multi_environment.md) |
95 | 62 |
|
96 |
| -```bash |
97 |
| -pixi run --environment=py313 start |
98 |
| -``` |
| 63 | +## Tasks |
| 64 | +Pixi can run cross-platform tasks using it's built-in task runner. |
| 65 | +This can be a predefined task or any normal executable. |
99 | 66 |
|
| 67 | +- [`pixi run`](./reference/cli/pixi/run.md) - Run a task or command |
| 68 | +- [`pixi task add`](./reference/cli/pixi/task/add.md) - Add a new task to the manifest |
| 69 | + |
| 70 | +Tasks can have other tasks as dependencies. |
| 71 | +Here is an example of a more complex task usecase |
| 72 | +```toml title="pixi.toml" |
| 73 | +[tasks] |
| 74 | +build = "make build" |
| 75 | +# using the toml table view |
| 76 | +[tasks.test] |
| 77 | +cmd = "pytest" |
| 78 | +depends-on = ["build"] |
100 | 79 | ```
|
101 |
| - _________________________ |
102 |
| -< Hello from Python 3.13! > |
103 |
| - ------------------------- |
104 |
| - \ ^__^ |
105 |
| - \ (oo)\_______ |
106 |
| - (__)\ )\/\ |
107 |
| - ||----w | |
108 |
| - || || |
109 |
| -``` |
| 80 | +More information: [Tasks](./workspace/advanced_tasks.md) |
| 81 | + |
| 82 | +## Multi platform support |
| 83 | +Pixi supports multiple platforms out of the box. |
| 84 | +You can specify which platforms your workspace supports and Pixi will ensure that the dependencies are compatible with those platforms. |
| 85 | + |
| 86 | +- [`pixi add --platform`](./reference/cli/pixi/add.md#arg---platform) - add a package only to a specific platform |
| 87 | +- [`pixi workspace platform add`](./reference/cli/pixi/workspace/platform/add.md) - add a platform to the workspace that you want to support with your project |
| 88 | + |
| 89 | +More information: [Multi platform support](./workspace/multi_platform_configuration.md) |
| 90 | + |
| 91 | +## Utilities |
| 92 | +Pixi comes with a set of utilities to help you debug or manage your setup. |
| 93 | + |
| 94 | +- [`pixi info`](./reference/cli/pixi/info.md) - Show information about the current workspace, and the global setup. |
| 95 | +- [`pixi config`](./reference/cli/pixi/config.md) - Show or edit the Pixi configuration. |
| 96 | +- [`pixi tree`](./reference/cli/pixi/tree.md) - Show a tree of dependencies in the current environment. |
| 97 | +- [`pixi list`](./reference/cli/pixi/list.md) - List all dependencies in the current environment. |
| 98 | +- [`pixi clean`](./reference/cli/pixi/clean.md) - Remove the project environments from your machine. |
| 99 | +- `pixi help` - Show help for Pixi commands. |
| 100 | +- `pixi help <subcommand>` - Show help for a specific Pixi command. |
| 101 | +- [`pixi auth`](./reference/cli/pixi/auth.md) - Manage authentication for conda channels. |
| 102 | +- [`pixi search`](./reference/cli/pixi/search.md) - Search for packages in the configured channels. |
| 103 | +- [`pixi completion`](./reference/cli/pixi/completion.md) - Generate shell completion scripts for Pixi commands. |
110 | 104 |
|
111 | 105 |
|
112 | 106 | ## Going further
|
|
0 commit comments