Skip to content

Commit 082fe2a

Browse files
committed
Add hack to find libraries on OSX
1 parent ce7cb76 commit 082fe2a

File tree

3 files changed

+82
-1
lines changed

3 files changed

+82
-1
lines changed

ctre/_osx_phoenix6_pkgcfg.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Hack to get around needing to depend on phoenix 6's binaries and
2+
# they aren't exported directly
3+
4+
5+
from os.path import abspath, join, dirname
6+
import phoenix6
7+
8+
_root = abspath(dirname(phoenix6.__file__))
9+
10+
libinit_import = "ctre._init_phoenix6"
11+
depends = []
12+
pypi_package = "phoenix6"
13+
14+
15+
def get_include_dirs():
16+
return []
17+
18+
19+
def get_library_dirs():
20+
return [join(_root, "lib")]
21+
22+
23+
def get_library_dirs_rel():
24+
return ["lib"]
25+
26+
27+
def get_library_names():
28+
return [
29+
"CTRE_PhoenixTools_Sim",
30+
"CTRE_SimCANCoder",
31+
"CTRE_SimPigeonIMU",
32+
"CTRE_SimProCANcoder",
33+
"CTRE_SimProPigeon2",
34+
"CTRE_SimProTalonFX",
35+
"CTRE_SimTalonFX",
36+
"CTRE_SimTalonSRX",
37+
"CTRE_SimVictorSPX",
38+
]
39+
40+
41+
def get_library_full_names():
42+
return [
43+
"libCTRE_PhoenixTools_Sim.dylib",
44+
"libCTRE_SimCANCoder.dylib",
45+
"libCTRE_SimPigeonIMU.dylib",
46+
"libCTRE_SimProCANcoder.dylib",
47+
"libCTRE_SimProPigeon2.dylib",
48+
"libCTRE_SimProTalonFX.dylib",
49+
"libCTRE_SimTalonFX.dylib",
50+
"libCTRE_SimTalonSRX.dylib",
51+
"libCTRE_SimVictorSPX.dylib",
52+
]

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ install_requires = [
1212

1313
[build-system]
1414
requires = [
15-
"robotpy-build<2025.0.0,>=2024.0.0b4",
15+
"robotpy-build<2025.0.0,>=2024.0.0b5",
1616
"wpilib<2025.0.0,>=2024.0.0b2",
1717
"phoenix6~=24.0.0b2",
1818
]
@@ -153,6 +153,12 @@ depends = [
153153
"ctre_tools_sim",
154154
]
155155

156+
[tool.robotpy-build.wrappers."ctre._cci_sim".override.os_osx]
157+
depends = [
158+
"ctre_tools_sim",
159+
"phoenix6_workaround"
160+
]
161+
156162
[tool.robotpy-build.wrappers."ctre._cci_sim".override.arch_athena]
157163
ignore = true
158164

setup.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
#!/usr/bin/env python3
22

3+
import sys
4+
5+
# HACK: insert an entrypoint for phoenix 6 so we can link to it
6+
if sys.platform.startswith("darwin"):
7+
import robotpy_build.pkgcfg_provider
8+
from importlib.metadata import entry_points, EntryPoint
9+
10+
def entry_points_hook(*args, **kwargs):
11+
ep = EntryPoint(
12+
name="phoenix6_workaround",
13+
value="ctre._osx_phoenix6_pkgcfg",
14+
group="robotpybuild",
15+
)
16+
17+
eps = entry_points(*args, **kwargs)
18+
if isinstance(eps, dict):
19+
eps["robotpybuild"] = (ep, *eps.get("robotpybuild", tuple()))
20+
else:
21+
eps = (ep, *eps)
22+
return eps
23+
24+
robotpy_build.pkgcfg_provider.entry_points = entry_points_hook
25+
326
from robotpy_build.setup import setup
427

528
setup()

0 commit comments

Comments
 (0)