From 082fe2a60499c5cd0b8f2d8365b2c47ec2363ecd Mon Sep 17 00:00:00 2001 From: Dustin Spicuzza Date: Sun, 12 Nov 2023 01:23:44 -0500 Subject: [PATCH] Add hack to find libraries on OSX --- ctre/_osx_phoenix6_pkgcfg.py | 52 ++++++++++++++++++++++++++++++++++++ pyproject.toml | 8 +++++- setup.py | 23 ++++++++++++++++ 3 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 ctre/_osx_phoenix6_pkgcfg.py diff --git a/ctre/_osx_phoenix6_pkgcfg.py b/ctre/_osx_phoenix6_pkgcfg.py new file mode 100644 index 0000000..b9aa9cf --- /dev/null +++ b/ctre/_osx_phoenix6_pkgcfg.py @@ -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", + ] diff --git a/pyproject.toml b/pyproject.toml index 75df29d..4f81c5c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", ] @@ -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 diff --git a/setup.py b/setup.py index 3542d0c..7ca42e4 100644 --- a/setup.py +++ b/setup.py @@ -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()