Concatenate 2 arrays in pyproject.toml
Asked Answered
F

1

5

I'm giving a shot to the pyproject.toml file, and I'm stuck on this simple task. Consider the following optional dependencies:

[project.optional-dependencies]
style = ["black", "codespell", "isort", "flake8"]
test = ["pytest", "pytest-cov"]
all = ["black", "codespell", "isort", "flake8", "pytest", "pytest-cov"]

Is there a way to avoid copy/pasting all the optional-dep in the all key? Is there a way to do all = style + test at least?

Flypaper answered 26/5, 2022 at 21:29 Comment(0)
G
9

There is no such feature directly in the toml markup.

However, there is a tricky way to do this in Python packaging by depending on yourself:

[project.optional-dependencies]
style = ["black", "codespell", "isort", "flake8"]
test = ["pytest", "pytest-cov"]
all = ["myproject[style]", "myproject[test]"]

Source:

Circular dependency is a feature that Python packaging is explicitly designed to allow, so it works and should continue to work.

Gymnosophist answered 6/6, 2022 at 22:29 Comment(1)
you can (if you want) condense it a bit more by doing all = ["myproject[style,test]"]Unmoved

© 2022 - 2024 — McMap. All rights reserved.