Update to Bridges
This commit is contained in:
109
build_exe.py
109
build_exe.py
@@ -1,9 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
PyInstaller build script for simulation_host.py.
|
||||
Creates a standalone executable that includes PyBullet and pybullet_data.
|
||||
PyInstaller build script for drone simulation executables.
|
||||
Creates standalone executables that include PyBullet and dependencies.
|
||||
|
||||
Usage:
|
||||
python build_exe.py # Build standalone_simulation
|
||||
python build_exe.py simulation_host # Build simulation_host
|
||||
python build_exe.py standalone # Build standalone_simulation
|
||||
python build_exe.py all # Build all
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
@@ -22,23 +29,20 @@ def get_pybullet_data_path() -> str:
|
||||
return pybullet_data.getDataPath()
|
||||
|
||||
|
||||
def build_executable():
|
||||
print("=" * 60)
|
||||
print(" DRONE SIMULATION - BUILD EXECUTABLE")
|
||||
print("=" * 60)
|
||||
|
||||
def build_executable(source_name: str, output_name: str, console: bool = True):
|
||||
"""Build a single executable."""
|
||||
script_dir = Path(__file__).parent
|
||||
source_file = script_dir / "simulation_host.py"
|
||||
source_file = script_dir / source_name
|
||||
|
||||
if not source_file.exists():
|
||||
print(f"Error: {source_file} not found!")
|
||||
sys.exit(1)
|
||||
return False
|
||||
|
||||
print(f"\nBuilding: {source_name} -> {output_name}")
|
||||
print("-" * 40)
|
||||
|
||||
system = platform.system().lower()
|
||||
print(f"Platform: {system}")
|
||||
|
||||
pybullet_path = get_pybullet_data_path()
|
||||
print(f"PyBullet data path: {pybullet_path}")
|
||||
|
||||
if system == 'windows':
|
||||
separator = ';'
|
||||
@@ -51,43 +55,80 @@ def build_executable():
|
||||
str(source_file),
|
||||
'--onefile',
|
||||
'--clean',
|
||||
'--name=simulation_host',
|
||||
f'--name={output_name}',
|
||||
f'--add-data={data_spec}',
|
||||
]
|
||||
|
||||
if system == 'windows':
|
||||
build_args.append('--windowed')
|
||||
elif system == 'darwin':
|
||||
build_args.append('--windowed')
|
||||
else:
|
||||
if console:
|
||||
build_args.append('--console')
|
||||
|
||||
print("\nBuild configuration:")
|
||||
for arg in build_args:
|
||||
print(f" {arg}")
|
||||
|
||||
print("\nStarting PyInstaller build...")
|
||||
print("-" * 60)
|
||||
else:
|
||||
if system in ['windows', 'darwin']:
|
||||
build_args.append('--windowed')
|
||||
else:
|
||||
build_args.append('--console')
|
||||
|
||||
try:
|
||||
PyInstaller.__main__.run(build_args)
|
||||
print("-" * 60)
|
||||
print("\nBuild completed successfully!")
|
||||
|
||||
dist_dir = script_dir / "dist"
|
||||
if system == 'windows':
|
||||
exe_path = dist_dir / "simulation_host.exe"
|
||||
elif system == 'darwin':
|
||||
exe_path = dist_dir / "simulation_host.app"
|
||||
exe_path = dist_dir / f"{output_name}.exe"
|
||||
elif system == 'darwin' and not console:
|
||||
exe_path = dist_dir / f"{output_name}.app"
|
||||
else:
|
||||
exe_path = dist_dir / "simulation_host"
|
||||
exe_path = dist_dir / output_name
|
||||
|
||||
print(f"\nExecutable location: {exe_path}")
|
||||
print(f" Created: {exe_path}")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"\nBuild failed: {e}")
|
||||
print(f" Build failed: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Build simulation executables')
|
||||
parser.add_argument(
|
||||
'target',
|
||||
nargs='?',
|
||||
default='standalone',
|
||||
choices=['standalone', 'simulation_host', 'all'],
|
||||
help='What to build (default: standalone)'
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
print("=" * 60)
|
||||
print(" DRONE SIMULATION - BUILD EXECUTABLES")
|
||||
print("=" * 60)
|
||||
print(f"Platform: {platform.system()}")
|
||||
print(f"PyBullet data: {get_pybullet_data_path()}")
|
||||
|
||||
success = True
|
||||
|
||||
if args.target in ['standalone', 'all']:
|
||||
success &= build_executable(
|
||||
'standalone_simulation.py',
|
||||
'drone_simulation',
|
||||
console=False
|
||||
)
|
||||
|
||||
if args.target in ['simulation_host', 'all']:
|
||||
success &= build_executable(
|
||||
'simulation_host.py',
|
||||
'simulation_host',
|
||||
console=True
|
||||
)
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
if success:
|
||||
print(" BUILD COMPLETE!")
|
||||
print(" Executables in: dist/")
|
||||
else:
|
||||
print(" BUILD FAILED!")
|
||||
sys.exit(1)
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
build_executable()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user