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: Create features and environments from extras #1077

Merged
merged 22 commits into from
Apr 5, 2024

Conversation

olivier-lacroix
Copy link
Contributor

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

fixes #1062

src/cli/init.rs Outdated Show resolved Hide resolved
src/cli/init.rs Outdated Show resolved Hide resolved
@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
});
environments.by_name.insert(EnvironmentName::Default, 0);
}

// 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
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
Contributor Author

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

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.

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.

docs/advanced/pyproject_toml.md Outdated Show resolved Hide resolved
@baszalmstra
Copy link
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
Contributor Author

@baszalmstra there you go: #1077 (comment)

@ruben-arts
Copy link
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
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
Contributor

Thanks @olivier-lacroix !

@ruben-arts ruben-arts merged commit 1d259ff into prefix-dev:main Apr 5, 2024
27 checks passed
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
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
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
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
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