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: Implement PEP735 support #2448

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

olivier-lacroix
Copy link
Contributor

@olivier-lacroix olivier-lacroix commented Nov 10, 2024

Fixes #2256 as well as #2149 (maybe we want to create a separate issue to interpret / use markers).

This PR adds handling of [dependency-groups] in pyproject.toml:

  • any group in this table is interpreted as a feature by pixi (similar to current behaviour for optional-dependencies)
  • if a dependency group and a group of optional dependencies have the same name, all dependencies will be added to a single common feature

This PR also changes the behaviour of pixi add --pypi in case of a pyproject.toml manifest:

  • if a feature is specified, the dependency is now added to the [dependency-groups] table instead of the [optional-dependencies] table currently
  • if --platform or --editable is specified, the pypi dependency will be added to the tool.pixi.pypi-dependencies table instead, since native arrays have no support for platform-specific or editable dependencies.

This PR also changes the behaviour of pixi init when starting from an existing pyproject.toml manifest:

  • one environment per dependency-group will be added to the environments table, similar to what is being done currently with groups of optional dependencies.

As a drive-by improvement, when removing a pypi dependency from a pyproject.toml manifest, any empty array will be deleted.

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First off, thank you 💯, amazing contribution! Well documented, Kudos!

I have a few small requests to finish it off.

Also could it print in what location it was added in the pixi add output. e.g.:

❯ pixi add --pypi --location optional-dependencies boltons
✔ Added boltons >=24.1.0, <25
Added these to `optional-dependencies`.

❯ pixi add --pypi numpy
✔ Added numpy >=2.1.3, <3
Added these as `project.dependencies`.

❯ pixi add --pypi --feature test pytest
✔ Added numpy >=2.1.3, <3
Added these as `dependency-groups`.

src/cli/add.rs Outdated Show resolved Hide resolved
src/cli/add.rs Outdated Show resolved Hide resolved
src/cli/upgrade.rs Show resolved Hide resolved
@tdejager
Copy link
Contributor

@olivier-lacroix would having a dependency-group with foo and an optional-feature with foo merge the dependencies together into the same foo pixi feature?

@olivier-lacroix
Copy link
Contributor Author

@olivier-lacroix would having a dependency-group with foo and an optional-feature with foo merge the dependencies together into the same foo pixi feature?

Yes it would

@olivier-lacroix
Copy link
Contributor Author

@ruben-arts , @tdejager this is ready to merge I think.

@ruben-arts I started implementing the location printing, but I think this can wait a follow-up PR / decision on the CLI API.

Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superb! Thanks for implementing this!

@ruben-arts ruben-arts merged commit 3cda60d into prefix-dev:main Nov 18, 2024
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Python dependency groups
3 participants