Skip to content
TheChatArchiveThe Chat Archive
o3-2025-04-16· OpenAIHugging Face LMArena Human Preference 140K

In pyproject.toml, I can define extra_requires via [project.optional-dependencies].…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with DeepSeekdeepseek-v3-0324’s answer.
  1. User

    In pyproject.toml, I can define extra_requires via [project.optional-dependencies]. Suppose I define two such extras extraa = ["package1", "package2"] and extrab = ["package1", "package3"]. Is there a convenient way to create an "all" extras that would include both of there without repeating the list of packages?

  2. Assistant

    Short answer
    No.
    The PEP-621 syntax that [project.optional-dependencies] follows only allows every key to map to a literal list of requirement strings.
    It does not let one extra “include” another or express set operations such as unions, so you would have to spell the packages out again:

    [project.optional-dependencies]
    extraa = ["package1", "package2"]
    extrab = ["package1", "package3"]
    all    = ["package1", "package2", "package3"]   # duplicated on purpose
    

    Work-arounds / remarks

    • Users can always install several extras at once (pip install myproj[extraa,extrab]), so an “all” extra isn’t strictly required.

    • If you really want to keep the list in one place, you’d need a build-time solution outside the spec, e.g.
    – generate the pyproject.toml with a script,
    – or use a build backend that offers its own metadata hooks (Hatch, Flit, etc.) to compute an extra dynamically.
    Such tricks are backend-specific and won’t work in plain static pyproject.toml.

    In standard pyproject.toml alone, duplication is unavoidable.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.