Files
dependencies/bzip2/setup.py
Adeeb Shihadeh db4664139a add bzip2 package (#28)
Static build of bzip2 1.0.8 (libbz2.a + bzlib.h) for use as a
vendored dependency in openpilot replay/cabana tools.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 12:01:40 -08:00

62 lines
1.3 KiB
Python

import os
import platform
import subprocess
from setuptools.command.build_py import build_py
try:
from wheel.bdist_wheel import bdist_wheel
except ImportError:
bdist_wheel = None
class BuildBzip2(build_py):
"""Run build.sh to compile bzip2 before collecting package data."""
def run(self):
pkg_dir = os.path.dirname(os.path.abspath(__file__))
marker = os.path.join(pkg_dir, "bzip2", "install", "lib", "libbz2.a")
if not os.path.exists(marker):
build_script = os.path.join(pkg_dir, "build.sh")
subprocess.check_call(["bash", build_script], cwd=pkg_dir)
super().run()
cmdclass = {"build_py": BuildBzip2}
if bdist_wheel is not None:
class PlatformWheel(bdist_wheel):
"""Produce a platform-specific, Python-version-agnostic wheel."""
def finalize_options(self):
super().finalize_options()
self.root_is_pure = False
def get_tag(self):
system = platform.system()
machine = platform.machine()
if system == "Linux":
plat = f"linux_{machine}"
elif system == "Darwin":
plat = "macosx_11_0_arm64"
else:
plat = f"{system.lower()}_{machine}"
return "py3", "none", plat
cmdclass["bdist_wheel"] = PlatformWheel
def setup():
from setuptools import setup as _setup
_setup(cmdclass=cmdclass)
if __name__ == "__main__":
setup()