Skip to content

feat: Create features and environments from extras#1077

Merged
ruben-arts merged 22 commits into
prefix-dev:mainfrom
olivier-lacroix:pyproject-extras
Apr 5, 2024
Merged

feat: Create features and environments from extras#1077
ruben-arts merged 22 commits into
prefix-dev:mainfrom
olivier-lacroix:pyproject-extras

Conversation

@olivier-lacroix
Copy link
Copy Markdown
Contributor

@olivier-lacroix olivier-lacroix commented Mar 28, 2024

fixes #1062

Comment thread src/cli/init.rs Outdated
Comment thread src/cli/init.rs Outdated
@olivier-lacroix olivier-lacroix marked this pull request as ready for review March 29, 2024 05:41
@olivier-lacroix olivier-lacroix force-pushed the pyproject-extras branch 2 times, most recently from 8d29abd to 46532e5 Compare March 29, 2024 05:52
Comment thread src/project/manifest/mod.rs Outdated

// Add all named environments
// Note: if the default Environment is redefined, but does not specify a solve-group,
// it is not added to the 'default' solve-group.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this OK?

Or do we want to add it to the 'default' solve-group? That is, the following

[environments]
default = ["somefeature"]

Would be parsed as if the TOML contained

[environments]
default = { features = ["somefeature"], solve-group = "default" } 

@olivier-lacroix
Copy link
Copy Markdown
Contributor Author

@ruben-arts @baszalmstra any thought on this PR?

Copy link
Copy Markdown
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.

I like it, it relatively simple and small but behaves like the [project.dependencies] which I am for. The ability to overwrite and extend using the normal pixi feature tables is also nice.

Comment thread docs/advanced/pyproject_toml.md Outdated
@baszalmstra
Copy link
Copy Markdown
Contributor

Also create a "default" solve group, associated to the default environment, as per comment.

Can you link that comment? I am unable to find it.

I dont think I agree with this because it feels weird to me that for all other environments you do always have to be explicit about solve-groups.

@ruben-arts ruben-arts self-assigned this Apr 4, 2024
Co-authored-by: Ruben Arts <ruben@prefix.dev>
@olivier-lacroix
Copy link
Copy Markdown
Contributor Author

@baszalmstra there you go: #1077 (comment)

@ruben-arts
Copy link
Copy Markdown
Contributor

I'm sorry for the confusement @olivier-lacroix, @baszalmstra kinda convinced me outside of this thread. Lets put the default = {features = [], solve-group = "default"} back in. It's easier to make this implicit after having it explicit then the other way around.
As making this implicit is a breaking change. Because in theory user could already be using the "default" solve-group for non-default environments.

@olivier-lacroix olivier-lacroix force-pushed the pyproject-extras branch 2 times, most recently from 54133a7 to 77bcd85 Compare April 5, 2024 02:29
@olivier-lacroix
Copy link
Copy Markdown
Contributor Author

olivier-lacroix commented Apr 5, 2024

@ruben-arts no worries, I reverted that bit. I also:

  • Refactored the parsing of pyproject.toml in init.rs to take advantage of the new custom TomlError
  • Added an info message about the created environments if any (to align with what was done re. the install of the package itself).
  • Added an info message when pixi init is run against a pyproject.toml that contains a pixi section already
  • Filtered unused features out
  • Updated the flask example

@ruben-arts
Copy link
Copy Markdown
Contributor

Thanks @olivier-lacroix !

Comment on lines +143 to +145
- **default** with 'package1' as pypi dependency
- **test** with 'package1' and 'pytest' as pypi dependencies
- **all** with 'package1', 'package2' and 'pytest' as pypi dependencies
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With the above, is it correct that installing the test environment with pixi would install pytest from pypi rather than conda-forge?

If I wanted my pixi test environment to only install dependencies from conda-forge can I specify that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dhirschfeld you are correct.

Currently, you would have to manually add them to the tool.pixi.feature.test.dependencies table. What you want is also on my wishlist :-) #532

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So, if I did manually specify the test dependencies in [tool.pixi.feature.test.dependencies] table, then that would be used instead of mapping pypi dependencies from the [project.optional-dependencies] table?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. Pixi currently solves pypi dependencies after the conda ones. And if it detects a package is already provided by one of the conda packages requested, it is skipped.

@olivier-lacroix olivier-lacroix deleted the pyproject-extras branch April 20, 2024 09:09
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.

Interpret optional extras in pyproject.toml as pixi features

5 participants