Skip to content

Commit

Permalink
Add XRP extension to robotpy-xrp
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Feb 7, 2024
1 parent 9f9ddc5 commit bfedaf6
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
18 changes: 18 additions & 0 deletions subprojects/robotpy-xrp/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ install_requires = [
"wpilib==THIS_VERSION"
]

[tool.robotpy-build.metadata.entry_points]
robotpysimext = [
"xrp = xrp.extension",
]

[build-system]
requires = [
"robotpy-build<2025.0.0,~=2024.0.0",
Expand Down Expand Up @@ -45,3 +50,16 @@ group_id = "edu.wpi.first.xrpVendordep"
repo_url = "https://frcmaven.wpi.edu/artifactory/release"
version = "2024.2.1"
libs = ["xrpVendordep"]

[tool.robotpy-build.wrappers."xrp.extension".maven_lib_download]
artifact_id = "halsim_xrp"
group_id = "edu.wpi.first.halsim"
# repo_url = "https://frcmaven.wpi.edu/artifactory/release"
repo_url = "https://frcmaven.wpi.edu/artifactory/release"
version = "2024.2.1"

dlopenlibs = ["halsim_xrp"]

[tool.robotpy-build.wrappers."xrp.extension"]
name = "xrp_ext"
depends = ["wpiHal", "wpinet"]
3 changes: 3 additions & 0 deletions subprojects/robotpy-xrp/xrp/extension/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .main import loadExtension

__all__ = ["loadExtension"]
23 changes: 23 additions & 0 deletions subprojects/robotpy-xrp/xrp/extension/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import logging
import os
from os.path import abspath, dirname, join

logger = logging.getLogger("xrp.extension")


def loadExtension():
try:
import hal
except ImportError as e:
# really, should never happen...
raise ImportError("you must install robotpy-hal!") from e

from ..version import version

logger.info("WPILib XRP client %s", version)

root = join(abspath(dirname(__file__)), "lib")
ext = join(root, os.listdir(root)[0])
retval = hal.loadOneExtension(ext)
if retval != 0:
logger.warn("loading extension may have failed (error=%d)", retval)

0 comments on commit bfedaf6

Please sign in to comment.