Skip to content

Interpret optional extras in pyproject.toml as pixi features #1062

Closed

Description

@olivier-lacroix

Problem description

#999 will bring in initial pyproject.toml support.

I propose to interpret groups of extras dependencies in [project.optional-dependencies] as pixi features specifying some pypi dependencies.

Each of these could then be mapped to a pixi environment, depending on one or several features (a group of extra dependencies can contain a reference to another group of optional dependencies of the package itself).

I think it would make sense to create a tool.pixi.environments table during init.

A couple of questions:

  • Should that table be amended automatically after init, to propagate changes in [project.optional-dependencies]? I would assume not as one may not want to generate an environment per group of extra. Another option would be to keep it in sync, but for a list of excluded extras
  • Should we define a single solve group across all environments? I would assume so, as I think it maps better with how the groups of extra dependencies are being used in python.

So for instance:

[project]
name = 'my-package'
dependencies = [
    # ...
]

[project.optional-dependencies]
# development dependency groups
extra1 = [
    # ...
]

# feature dependency groups
extra2 = [
    # ...
]
extra3 = [
    "my-package[extra2]", # could also be .[extra2]
    # ...
]

Would inject upon pixi init the following table

[tool.pixi.environments]
extra1 = {features = ["extra1"], solve-group = "default"}
extra2 = {features = ["extra2"], solve-group = "default"}
extra3 = {features = ["extra3","extra2"], solve-group = "default"}

I'll be happy to implement this once #999 is merged in.

Activity

  1. olivier-lacroix commented on Mar 29, 2024

    @olivier-lacroix
    ContributorAuthor

    @ruben-arts the PR for this is in. I am not 100% sure, but I believe that being able to lock all the extra groups consistently like this is pretty unique to pixi :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions