frigate/docker/hailo8l/pyhailort_build_scripts/setup.py
spanner3003 b1e5b3515a Initial support for Hailo-8L
Added file for Hailo-8L detector including dockerfile, h8l.mk, h8l.hcl, hailo8l.py, ci.yml and ssd_mobilenat_v1.hef as the inference network.

Added files to help with the installation of Hailo-8L dependences like generate_wheel_conf.py, requirements-wheel-h8l.txt and modified setup.py to try and work with any hardware.

Updated docs to reflect Initial Hailo-8L support including oject_detectors.md,  hardware.md and installation.md.
2024-07-13 16:46:22 +01:00

115 lines
4.0 KiB
Python

import os
import json
from setuptools import setup, find_packages
from setuptools.command.install import install as _install
from wheel.bdist_wheel import bdist_wheel as orig_bdist_wheel
class NonPurePythonBDistWheel(orig_bdist_wheel):
"""Makes the wheel platform-dependent so it can be based on the _pyhailort architecture"""
def finalize_options(self):
orig_bdist_wheel.finalize_options(self)
self.root_is_pure = False
def _get_arch():
conf_file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json")
with open(conf_file_path, "r") as conf_file:
content = json.load(conf_file)
return content['arch']
def _get_system():
conf_file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json")
with open(conf_file_path, "r") as conf_file:
content = json.load(conf_file)
return content['system']
def _get_abi():
conf_file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json")
with open(conf_file_path, "r") as conf_file:
content = json.load(conf_file)
return content['abi']
def _get_hailort_lib_path():
lib_filename = f"libhailort.so"
lib_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), f"hailo_platform/pyhailort/{lib_filename}")
if os.path.exists(lib_path):
print(f"Found libhailort shared library at: {lib_path}")
else:
print(f"Error: libhailort shared library not found at: {lib_path}")
raise FileNotFoundError(f"libhailort shared library not found at: {lib_path}")
return lib_path
def _get_pyhailort_lib_path():
conf_file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json")
if not os.path.isfile(conf_file_path):
raise FileNotFoundError(f"Configuration file not found: {conf_file_path}")
with open(conf_file_path, "r") as conf_file:
content = json.load(conf_file)
py_version = content['py_version']
arch = content['arch']
system = content['system']
extension = content['extension']
abi = content['abi']
# Construct the filename directly
lib_filename = f"_pyhailort.cpython-{py_version.split('cp')[1]}-{arch}-{system}-{abi}.{extension}"
lib_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), f"hailo_platform/pyhailort/{lib_filename}")
if os.path.exists(lib_path):
print(f"Found _pyhailort shared library at: {lib_path}")
else:
print(f"Error: _pyhailort shared library not found at: {lib_path}")
raise FileNotFoundError(f"_pyhailort shared library not found at: {lib_path}")
return lib_path
def _get_package_paths():
packages = []
pyhailort_lib = _get_pyhailort_lib_path()
hailort_lib = _get_hailort_lib_path()
if pyhailort_lib:
packages.append(pyhailort_lib)
if hailort_lib:
packages.append(hailort_lib)
packages.append(os.path.abspath("hailo_tutorials/notebooks/*"))
packages.append(os.path.abspath("hailo_tutorials/hefs/*"))
return packages
if __name__ == "__main__":
setup(
author="Hailo team",
author_email="contact@hailo.ai",
cmdclass={
"bdist_wheel": NonPurePythonBDistWheel,
},
description="HailoRT",
entry_points={
"console_scripts": [
"hailo=hailo_platform.tools.hailocli.main:main",
]
},
install_requires=[
"argcomplete",
"contextlib2",
"future",
"netaddr",
"netifaces",
"verboselogs",
"numpy==1.23.3",
],
name="hailort",
package_data={
"hailo_platform": _get_package_paths(),
},
packages=find_packages(),
platforms=[
"linux_x86_64",
"linux_aarch64",
"win_amd64",
],
url="https://hailo.ai/",
version="4.17.0",
zip_safe=False,
)