Say I have created a python project foobar
with the following layout:
foobar
├── __init__.py
├── core/
├── network/
└── plotting/
- I would like to have
pip install foobar
to install only the core part of the package, along with core dependencies:
foobar
├── __init__.py
└── core/
- I would like to have
pip install foobar[plotting]
to install plotting capabilities and extra dependencies on-top of the core installation:
foobar
├── __init__.py
├── core/
└── plotting/
- I would like to have
pip install foobar[all]
to install everything:
foobar
├── __init__.py
├── core/
├── network/
└── plotting/
Dependency groups for the above scenarios seem simple enough to define in the pyproject.toml
file:
[project]
name = "foobar"
...
dependencies = [
"foo",
"bar",
]
[project.optional-dependencies]
network = [
"requests",
]
plotting = [
"PyQt6",
"pyqtgraph",
]
all = [
"foobar[network,plotting]",
]
dev = [
"foobar[all]",
"pytest",
"ruff",
"black",
]
But it’s unclear to me whether the package contents can be installed as I intend through some kind of definition in the pyproject.toml
file. How can this be accomplished?
You need to sign in to view this answers
Leave feedback about this