Skip to content

Commit

Permalink
Merge branch '2024' into ensure-valid-version
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Dec 12, 2024
2 parents 1fa1e9b + ccfdb56 commit 9440ca8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 8 additions & 1 deletion robotpy_installer/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,14 @@ def get_pypi_version(self, package: str, use_certifi: bool) -> Version:

# Sort the versions
maxv = Version(str(int(_WPILIB_YEAR) + 1))
versions = sorted(v for v in versions if v < maxv)

def _version_ok(v: Version) -> bool:
ok = v < maxv and not v.is_devrelease
if ok and not _IS_BETA:
ok = not v.is_prerelease
return ok

versions = sorted(v for v in versions if _version_ok(v))
if not versions:
raise InstallerException(f"could not find {package} version on pypi")

Expand Down
13 changes: 13 additions & 0 deletions robotpy_installer/pyproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import tomli
import tomlkit

from . import installer
from . import pypackages
from .pypackages import Packages, Env
from .errors import Error
Expand All @@ -22,6 +23,10 @@ class NoRobotpyError(PyprojectError):
pass


class UnsupportedRobotpyVersion(PyprojectError):
pass


def toml_path(project_path: pathlib.Path):
return project_path / "pyproject.toml"

Expand Down Expand Up @@ -223,6 +228,14 @@ def _load(
f"{pyproject_path}: tools.robotpy.robotpy_version is not a valid version"
) from None

supported_year = int(installer._WPILIB_YEAR)
if robotpy_version.major != supported_year:
msg = (
f"Only RobotPy {supported_year}.x is supported by this version "
f"of robotpy-installer ({pyproject_path} has {robotpy_version})"
)
raise UnsupportedRobotpyVersion(msg)

robotpy_extras_any = robotpy_data.get("robotpy_extras")
if isinstance(robotpy_extras_any, list):
robotpy_extras = list(map(str, robotpy_extras_any))
Expand Down

0 comments on commit 9440ca8

Please sign in to comment.