What's the best practice to use optional-dependencies as environment dependencies too? #662
-
e.g. I want to define some optional dependencies to be installed as package extras as follows: [project.optional-dependencies]
quality = [
"black~=22.6.0",
"flake8~=4.0.1",
"isort~=5.10.1",
"pre-commit~=2.20.0",
] And then I want to use those optional dependencies as the dependencies for a certain environment, should I do it this way? [tool.hatch.envs.quality]
dependencies = [
"pkg[quality]"
]
detached = true Is there a better way to do this? Does it make sense to work this way? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
https://hatch.pypa.io/latest/config/environment/overview/#features |
Beta Was this translation helpful? Give feedback.
-
It seems as if If I use
If I remove
|
Beta Was this translation helpful? Give feedback.
-
So I'm trying to create an environment with pytest etc. installed. This is my toml file: [project]
name = "rrapi"
version = "0.0.1"
authors = [
{name ="...", email="..."},
]
requires-python = ">=3.11"
dependencies = [
"fastapi == 0.95.0",
"httpx == 0.24.0",
"uvicorn == 0.21.1",
]
[project.optional-dependencies]
dev = [
"pytest == 7.2.1",
"pytest-env == 0.8.1",
"pre-commit == 3.2.1",
]
[tool.hatch.envs.rrapi]
features = [
"dev"
]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build" When I run [tool.hatch.envs.rrapi]
dependencies = [
"pytest == 7.2.1",
"pytest-env == 0.8.1",
"pre-commit == 3.2.1",
] But that also doesn't install pytest or the others. |
Beta Was this translation helpful? Give feedback.
https://hatch.pypa.io/latest/config/environment/overview/#features