Skip to content

Commit

Permalink
Document the add & remove cli behaviour with pyproject.toml manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier-lacroix committed May 7, 2024
1 parent 34105df commit af72faf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ Adds dependencies to the [manifest file](configuration.md).
It will only add if the package with its version constraint is able to work with rest of the dependencies in the project.
[More info](../features/multi_platform_configuration.md) on multi-platform configuration.

If the project manifest is a `pyproject.toml`, adding a pypi dependency will add it to the native pyproject `project.dependencies` array, or to the native `project.optional-dependencies` table if a feature is specified:
- `pixi add --pypi boto3` would add `boto3` to the `project.dependencies` array
- `pixi add --pypi boto3 --feature aws` would add `boto3` to the `project.dependencies.aws` array

These dependencies will be read by pixi as if they had been added to the pixi `pypi-dependencies` tables of the default or a named feature.

##### Arguments

1. `<SPECS>`: The package(s) to add, space separated. The version constraint is optional.
Expand Down Expand Up @@ -181,6 +187,10 @@ pixi run --environment cuda python

Removes dependencies from the [manifest file](configuration.md).

If the project manifest is a `pyproject.toml`, removing a pypi dependency with the `--pypi` flag will remove it from either
- the native pyproject `project.dependencies` array or the native `project.optional-dependencies` table (if a feature is specified)
- pixi `pypi-dependencies` tables of the default or a named feature (if a feature is specified)

##### Arguments

1. `<DEPS>...`: List of dependencies you wish to remove from the project.
Expand Down
10 changes: 8 additions & 2 deletions src/cli/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ pub struct Args {
///
/// Mixing `--platform` and `--build`/`--host` flags is supported
///
/// The `--pypi` option will add the package as a pypi-dependency this can not be mixed with the conda dependencies
/// The `--pypi` option will add the package as a pypi dependency. This can not be mixed with the conda dependencies
/// - `pixi add --pypi boto3`
/// - `pixi add --pypi "boto3==version"
///
/// If the project manifest is a `pyproject.toml`, adding a pypi dependency will add it to the native pyproject `project.dependencies` array
/// or to the native `project.optional-dependencies` table if a feature is specified:
/// - `pixi add --pypi boto3` would add `boto3` to the `project.dependencies` array
/// - `pixi add --pypi boto3 --feature aws` would add `boto3` to the `project.dependencies.aws` array
/// These dependencies will be read by pixi as if they had been added to the pixi `pypi-dependencies` tables of the default or a named feature.
///
#[arg(required = true)]
pub specs: Vec<String>,

Expand Down Expand Up @@ -87,7 +93,7 @@ pub struct Args {
#[arg(long, short)]
pub platform: Vec<Platform>,

/// The feature for which the dependency should be added
/// The feature for which the dependency should be added.
#[arg(long, short)]
pub feature: Option<String>,

Expand Down
5 changes: 5 additions & 0 deletions src/cli/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ use crate::project::manifest::FeatureName;
use crate::{consts, project::SpecType, Project};

/// Remove the dependency from the project
///
/// If the project manifest is a `pyproject.toml`, removing a pypi dependency with the `--pypi` flag will remove it from either
/// - the native pyproject `project.dependencies` array or the native `project.optional-dependencies` table (if a feature is specified)
/// - pixi `pypi-dependencies` tables of the default or a named feature (if a feature is specified)
///
#[derive(Debug, Default, Parser)]
pub struct Args {
/// List of dependencies you wish to remove from the project
Expand Down

0 comments on commit af72faf

Please sign in to comment.