Skip to content

Commit

Permalink
Add hack to find libraries on OSX
Browse files Browse the repository at this point in the history
  • Loading branch information
virtuald committed Nov 12, 2023
1 parent ce7cb76 commit 082fe2a
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
52 changes: 52 additions & 0 deletions ctre/_osx_phoenix6_pkgcfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Hack to get around needing to depend on phoenix 6's binaries and
# they aren't exported directly


from os.path import abspath, join, dirname
import phoenix6

_root = abspath(dirname(phoenix6.__file__))

libinit_import = "ctre._init_phoenix6"
depends = []
pypi_package = "phoenix6"


def get_include_dirs():
return []


def get_library_dirs():
return [join(_root, "lib")]


def get_library_dirs_rel():
return ["lib"]


def get_library_names():
return [
"CTRE_PhoenixTools_Sim",
"CTRE_SimCANCoder",
"CTRE_SimPigeonIMU",
"CTRE_SimProCANcoder",
"CTRE_SimProPigeon2",
"CTRE_SimProTalonFX",
"CTRE_SimTalonFX",
"CTRE_SimTalonSRX",
"CTRE_SimVictorSPX",
]


def get_library_full_names():
return [
"libCTRE_PhoenixTools_Sim.dylib",
"libCTRE_SimCANCoder.dylib",
"libCTRE_SimPigeonIMU.dylib",
"libCTRE_SimProCANcoder.dylib",
"libCTRE_SimProPigeon2.dylib",
"libCTRE_SimProTalonFX.dylib",
"libCTRE_SimTalonFX.dylib",
"libCTRE_SimTalonSRX.dylib",
"libCTRE_SimVictorSPX.dylib",
]
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install_requires = [

[build-system]
requires = [
"robotpy-build<2025.0.0,>=2024.0.0b4",
"robotpy-build<2025.0.0,>=2024.0.0b5",
"wpilib<2025.0.0,>=2024.0.0b2",
"phoenix6~=24.0.0b2",
]
Expand Down Expand Up @@ -153,6 +153,12 @@ depends = [
"ctre_tools_sim",
]

[tool.robotpy-build.wrappers."ctre._cci_sim".override.os_osx]
depends = [
"ctre_tools_sim",
"phoenix6_workaround"
]

[tool.robotpy-build.wrappers."ctre._cci_sim".override.arch_athena]
ignore = true

Expand Down
23 changes: 23 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
#!/usr/bin/env python3

import sys

# HACK: insert an entrypoint for phoenix 6 so we can link to it
if sys.platform.startswith("darwin"):
import robotpy_build.pkgcfg_provider
from importlib.metadata import entry_points, EntryPoint

def entry_points_hook(*args, **kwargs):
ep = EntryPoint(
name="phoenix6_workaround",
value="ctre._osx_phoenix6_pkgcfg",
group="robotpybuild",
)

eps = entry_points(*args, **kwargs)
if isinstance(eps, dict):
eps["robotpybuild"] = (ep, *eps.get("robotpybuild", tuple()))
else:
eps = (ep, *eps)
return eps

robotpy_build.pkgcfg_provider.entry_points = entry_points_hook

from robotpy_build.setup import setup

setup()

0 comments on commit 082fe2a

Please sign in to comment.