Skip to content

Commit dec1c38

Browse files
committed
Replace 'robotpy_extras' with 'components'
- This is mostly cosmetic, but hopefully communicates the purpose better
1 parent d95c71f commit dec1c38

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

robotpy_installer/cli_sync.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ class Sync:
3030
# Version of robotpy this project depends on
3131
robotpy_version = "{robotpy_version}"
3232
33-
# Which extras should be installed
34-
# -> equivalent to `pip install robotpy[extra1, ...]
35-
robotpy_extras = []
33+
# Which optional RobotPy components should be installed?
34+
# -> equivalent to `pip install robotpy[component1, ...]
35+
components = []
3636
37-
# Other pip packages to install (each element is equivalent to
38-
# a line in requirements.txt)
37+
# Other pip packages to install, such as vendor packages (each element
38+
# is equivalent to a line in requirements.txt)
3939
requires = []
4040
4141
If no pyproject.toml exists, a default is created using the current robotpy

robotpy_installer/pyproject.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class RobotPyProjectToml:
5050
robotpy_version = "2024.0.0b4"
5151
5252
# equivalent to `robotpy[cscore, ...]`
53-
robotpy_extras = ["cscore"]
53+
components = ["cscore"]
5454
5555
# Other pip installable requirement lines
5656
requires = [
@@ -62,17 +62,17 @@ class RobotPyProjectToml:
6262
#: Version of robotpy that is depended on
6363
robotpy_version: Version
6464

65-
robotpy_extras: typing.List[str] = dataclasses.field(default_factory=list)
65+
components: typing.List[str] = dataclasses.field(default_factory=list)
6666

6767
#: Requirement for the robotpy meta package -- all RobotPy projects must
6868
#: depend on it
6969
@property
7070
def robotpy_requires(self) -> Requirement:
71-
if self.robotpy_extras:
72-
extras = f"[{','.join(self.robotpy_extras)}]"
71+
if self.components:
72+
components = f"[{','.join(self.components)}]"
7373
else:
74-
extras = ""
75-
return Requirement(f"robotpy{extras}=={self.robotpy_version}")
74+
components = ""
75+
return Requirement(f"robotpy{components}=={self.robotpy_version}")
7676

7777
#: User's custom requirements
7878
requires: typing.List[Requirement] = dataclasses.field(default_factory=list)
@@ -401,13 +401,14 @@ def write_default_pyproject(
401401
# Version of robotpy this project depends on
402402
robotpy_version = "{robotpy_version}"
403403
404-
# Which extra RobotPy components should be installed
404+
# Which optional robotpy components should be installed?
405405
# -> equivalent to `pip install robotpy[extra1, ...]
406-
robotpy_extras = [
406+
components = [
407407
# ##EXTRAS##
408408
]
409409
410-
# Other pip packages to install
410+
# Other pip packages to install, such as vendor packages (each element
411+
# is equivalent to a line in requirements.txt)
411412
requires = []
412413
413414
"""
@@ -484,13 +485,18 @@ def _load(
484485
)
485486
raise UnsupportedRobotpyVersion(msg)
486487

487-
robotpy_extras_any = robotpy_data.get("robotpy_extras")
488-
if isinstance(robotpy_extras_any, list):
489-
robotpy_extras = list(map(str, robotpy_extras_any))
490-
elif not robotpy_extras_any:
491-
robotpy_extras = []
488+
if "robotpy_extras" in robotpy_data:
489+
raise PyprojectError(
490+
"'robotpy_extras' has been replaced with 'components', see the documentation for details"
491+
)
492+
493+
components_any = robotpy_data.get("components")
494+
if isinstance(components_any, list):
495+
components = list(map(str, components_any))
496+
elif not components_any:
497+
components = []
492498
else:
493-
robotpy_extras = [str(robotpy_extras_any)]
499+
components = [str(components_any)]
494500

495501
requires_any = robotpy_data.get("requires")
496502
if isinstance(requires_any, list):
@@ -504,7 +510,7 @@ def _load(
504510

505511
return RobotPyProjectToml(
506512
robotpy_version=robotpy_version,
507-
robotpy_extras=robotpy_extras,
513+
components=components,
508514
requires=requires,
509515
)
510516

0 commit comments

Comments
 (0)