22
22
from .environment import EnvironmentParseError , ParsedEnvironment , parse_environment
23
23
from .logger import log
24
24
from .oci_container import OCIContainerEngineConfig
25
- from .projectfiles import get_requires_python_str
25
+ from .projectfiles import get_dependency_groups , get_requires_python_str
26
26
from .typing import PLATFORMS , PlatformName
27
27
from .util import (
28
28
MANYLINUX_ARCHS ,
@@ -92,6 +92,7 @@ class BuildOptions:
92
92
before_test : str | None
93
93
test_requires : list [str ]
94
94
test_extras : str
95
+ test_groups : list [str ]
95
96
build_verbosity : int
96
97
build_frontend : BuildFrontendConfig | None
97
98
config_settings : str
@@ -568,6 +569,13 @@ def __init__(
568
569
disallow = DISALLOWED_OPTIONS ,
569
570
)
570
571
572
+ self .project_dir = Path (command_line_arguments .package_dir )
573
+ try :
574
+ with self .project_dir .joinpath ("pyproject.toml" ).open ("rb" ) as f :
575
+ self .pyproject_toml = tomllib .load (f )
576
+ except FileNotFoundError :
577
+ self .pyproject_toml = {}
578
+
571
579
@property
572
580
def config_file_path (self ) -> Path | None :
573
581
args = self .command_line_arguments
@@ -584,8 +592,10 @@ def config_file_path(self) -> Path | None:
584
592
585
593
@functools .cached_property
586
594
def package_requires_python_str (self ) -> str | None :
587
- args = self .command_line_arguments
588
- return get_requires_python_str (Path (args .package_dir ))
595
+ return get_requires_python_str (self .project_dir , self .pyproject_toml )
596
+
597
+ def dependency_groups (self , * groups : str ) -> tuple [str , ...]:
598
+ return get_dependency_groups (self .pyproject_toml , * groups )
589
599
590
600
@property
591
601
def globals (self ) -> GlobalOptions :
@@ -672,6 +682,9 @@ def build_options(self, identifier: str | None) -> BuildOptions:
672
682
"test-requires" , option_format = ListFormat (sep = " " )
673
683
).split ()
674
684
test_extras = self .reader .get ("test-extras" , option_format = ListFormat (sep = "," ))
685
+ test_groups_str = self .reader .get ("test-groups" , option_format = ListFormat (sep = "," ))
686
+ test_groups = [x for x in test_groups_str .split ("," ) if x ]
687
+ test_dependency_groups = self .dependency_groups (* test_groups )
675
688
build_verbosity_str = self .reader .get ("build-verbosity" )
676
689
677
690
build_frontend_str = self .reader .get (
@@ -771,8 +784,9 @@ def build_options(self, identifier: str | None) -> BuildOptions:
771
784
return BuildOptions (
772
785
globals = self .globals ,
773
786
test_command = test_command ,
774
- test_requires = test_requires ,
787
+ test_requires = [ * test_requires , * test_dependency_groups ] ,
775
788
test_extras = test_extras ,
789
+ test_groups = test_groups ,
776
790
before_test = before_test ,
777
791
before_build = before_build ,
778
792
before_all = before_all ,
0 commit comments