Coverage for /home/runner/work/coxbuild/coxbuild/src/coxbuild/extensions/python/__init__.py: 0%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from pathlib import Path
3import coxbuild
4from coxbuild.configurations import Configuration, ConfigurationAccessor
5from coxbuild.schema import group, run, task
6from coxbuild.tasks import Task, TaskContext
8from .. import ProjectSettings
10grouped = group("python")
13class Settings(ConfigurationAccessor):
14 __configname__ = "python"
16 def __init__(self, config: Configuration) -> None:
17 super().__init__(config)
18 self.project = ProjectSettings(config)
20 @property
21 def requirements(self) -> Path:
22 """Path to requirements.txt."""
23 return self.getPath("requirements") or self.project.src.joinpath("requirements.txt").resolve()
25 @requirements.setter
26 def requirements(self, value: Path) -> None:
27 self.config["requirements"] = value.resolve()
30def withSettings(task: Task) -> Task:
31 """Decorator to add settings argument to task context."""
32 def hook(context: TaskContext):
33 if context.config:
34 context.kwds.update(settings=Settings(context.config))
36 task.before(hook)
37 return task