Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ unitree = [

manipulation = [
# Planning (Drake)
"drake>=1.40.0; platform_machine != 'aarch64'",
"drake==1.45.0; sys_platform == 'darwin' and platform_machine != 'aarch64'",
"drake>=1.40.0; sys_platform != 'darwin' and platform_machine != 'aarch64'",

# Hardware SDKs
"piper-sdk",
Expand Down
53 changes: 48 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,63 @@
# limitations under the License.

import os
from pathlib import Path
import struct
import sys

from pybind11.setup_helpers import Pybind11Extension, build_ext
from setuptools import find_packages, setup


def python_is_macos_universal_binary(executable: str | None = None) -> bool:
"""
Returns True if the given executable is a macOS universal (fat) binary.
"""
FAT_MAGIC = 0xCAFEBABE # big-endian fat
FAT_CIGAM = 0xBEBAFECA # little-endian fat
FAT_MAGIC_64 = 0xCAFEBABF # big-endian fat 64
FAT_CIGAM_64 = 0xBFBAFECA # little-endian fat 64

if executable is None:
executable = sys.executable

path = Path(executable)
if not path.exists():
return False

try:
with path.open("rb") as f:
header = f.read(4)
if len(header) < 4:
return False

magic = struct.unpack(">I", header)[0]
return magic in {
FAT_MAGIC,
FAT_CIGAM,
FAT_MAGIC_64,
FAT_CIGAM_64,
}
except OSError:
return False


extra_compile_args = [
"-O3", # Maximum optimization
"-ffast-math", # Fast floating point
]
# when the python exe is a universal binary, this option fails because the compiler
# call tries to build a matching (e.g. universal) binary, clang doesn't support this option for universal binaries
# if the user is using an arm64 specific binary (ex: nix build) then the optimization exists and is useful
if not python_is_macos_universal_binary():
extra_compile_args.append("-march=native")

# C++ extensions
ext_modules = [
Pybind11Extension(
"dimos.navigation.replanning_a_star.min_cost_astar_ext",
[os.path.join("dimos", "navigation", "replanning_a_star", "min_cost_astar_cpp.cpp")],
extra_compile_args=[
"-O3", # Maximum optimization
"-march=native", # Optimize for current CPU
"-ffast-math", # Fast floating point
],
extra_compile_args=extra_compile_args,
define_macros=[
("NDEBUG", "1"),
],
Expand Down
92 changes: 79 additions & 13 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading