mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-13 06:35:24 +03:00
fix formatting according to ruff and removed unnecessary functions.
This commit is contained in:
parent
b60f4ff905
commit
658653a6a2
@ -1,23 +1,30 @@
|
|||||||
import os
|
|
||||||
import json
|
import json
|
||||||
import sys
|
import os
|
||||||
import platform
|
import platform
|
||||||
|
import sys
|
||||||
import sysconfig
|
import sysconfig
|
||||||
|
|
||||||
|
|
||||||
def extract_toolchain_info(compiler):
|
def extract_toolchain_info(compiler):
|
||||||
# Remove the "-gcc" or "-g++" suffix if present
|
# Remove the "-gcc" or "-g++" suffix if present
|
||||||
if compiler.endswith('-gcc') or compiler.endswith('-g++'):
|
if compiler.endswith("-gcc") or compiler.endswith("-g++"):
|
||||||
compiler = compiler.rsplit('-', 1)[0]
|
compiler = compiler.rsplit("-", 1)[0]
|
||||||
|
|
||||||
# Extract the toolchain and ABI part (e.g., "gnu")
|
# Extract the toolchain and ABI part (e.g., "gnu")
|
||||||
toolchain_parts = compiler.split('-')
|
toolchain_parts = compiler.split("-")
|
||||||
abi_conventions = next((part for part in toolchain_parts if part in ['gnu', 'musl', 'eabi', 'uclibc']), '')
|
abi_conventions = next(
|
||||||
|
(part for part in toolchain_parts if part in ["gnu", "musl", "eabi", "uclibc"]),
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
|
||||||
return abi_conventions
|
return abi_conventions
|
||||||
|
|
||||||
|
|
||||||
def generate_wheel_conf():
|
def generate_wheel_conf():
|
||||||
conf_file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json")
|
conf_file_path = os.path.join(
|
||||||
|
os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json"
|
||||||
|
)
|
||||||
|
|
||||||
# Extract current system and Python version information
|
# Extract current system and Python version information
|
||||||
py_version = f"cp{sys.version_info.major}{sys.version_info.minor}"
|
py_version = f"cp{sys.version_info.major}{sys.version_info.minor}"
|
||||||
arch = platform.machine()
|
arch = platform.machine()
|
||||||
@ -25,7 +32,7 @@ def generate_wheel_conf():
|
|||||||
libc_version = platform.libc_ver()[1]
|
libc_version = platform.libc_ver()[1]
|
||||||
|
|
||||||
# Get the compiler information
|
# Get the compiler information
|
||||||
compiler = sysconfig.get_config_var('CC')
|
compiler = sysconfig.get_config_var("CC")
|
||||||
abi_conventions = extract_toolchain_info(compiler)
|
abi_conventions = extract_toolchain_info(compiler)
|
||||||
|
|
||||||
# Create the new configuration data
|
# Create the new configuration data
|
||||||
@ -37,8 +44,8 @@ def generate_wheel_conf():
|
|||||||
"abi": abi_conventions,
|
"abi": abi_conventions,
|
||||||
"extension": {
|
"extension": {
|
||||||
"posix": "so",
|
"posix": "so",
|
||||||
"nt": "pyd" # Windows
|
"nt": "pyd", # Windows
|
||||||
}[os.name]
|
}[os.name],
|
||||||
}
|
}
|
||||||
|
|
||||||
# If the file exists, load the existing data
|
# If the file exists, load the existing data
|
||||||
@ -55,5 +62,6 @@ def generate_wheel_conf():
|
|||||||
with open(conf_file_path, "w") as conf_file:
|
with open(conf_file_path, "w") as conf_file:
|
||||||
json.dump(conf_data, conf_file, indent=4)
|
json.dump(conf_data, conf_file, indent=4)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
generate_wheel_conf()
|
generate_wheel_conf()
|
||||||
|
|||||||
@ -1,37 +1,24 @@
|
|||||||
import os
|
|
||||||
import json
|
import json
|
||||||
from setuptools import setup, find_packages
|
import os
|
||||||
from setuptools.command.install import install as _install
|
|
||||||
|
from setuptools import find_packages, setup
|
||||||
from wheel.bdist_wheel import bdist_wheel as orig_bdist_wheel
|
from wheel.bdist_wheel import bdist_wheel as orig_bdist_wheel
|
||||||
|
|
||||||
|
|
||||||
class NonPurePythonBDistWheel(orig_bdist_wheel):
|
class NonPurePythonBDistWheel(orig_bdist_wheel):
|
||||||
"""Makes the wheel platform-dependent so it can be based on the _pyhailort architecture"""
|
"""Makes the wheel platform-dependent so it can be based on the _pyhailort architecture"""
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
orig_bdist_wheel.finalize_options(self)
|
orig_bdist_wheel.finalize_options(self)
|
||||||
self.root_is_pure = False
|
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():
|
def _get_hailort_lib_path():
|
||||||
lib_filename = f"libhailort.so"
|
lib_filename = "libhailort.so"
|
||||||
lib_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), f"hailo_platform/pyhailort/{lib_filename}")
|
lib_path = os.path.join(
|
||||||
|
os.path.abspath(os.path.dirname(__file__)),
|
||||||
|
f"hailo_platform/pyhailort/{lib_filename}",
|
||||||
|
)
|
||||||
if os.path.exists(lib_path):
|
if os.path.exists(lib_path):
|
||||||
print(f"Found libhailort shared library at: {lib_path}")
|
print(f"Found libhailort shared library at: {lib_path}")
|
||||||
else:
|
else:
|
||||||
@ -39,35 +26,44 @@ def _get_hailort_lib_path():
|
|||||||
raise FileNotFoundError(f"libhailort shared library not found at: {lib_path}")
|
raise FileNotFoundError(f"libhailort shared library not found at: {lib_path}")
|
||||||
return lib_path
|
return lib_path
|
||||||
|
|
||||||
|
|
||||||
def _get_pyhailort_lib_path():
|
def _get_pyhailort_lib_path():
|
||||||
conf_file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json")
|
conf_file_path = os.path.join(
|
||||||
|
os.path.abspath(os.path.dirname(__file__)), "wheel_conf.json"
|
||||||
|
)
|
||||||
if not os.path.isfile(conf_file_path):
|
if not os.path.isfile(conf_file_path):
|
||||||
raise FileNotFoundError(f"Configuration file not found: {conf_file_path}")
|
raise FileNotFoundError(f"Configuration file not found: {conf_file_path}")
|
||||||
|
|
||||||
with open(conf_file_path, "r") as conf_file:
|
with open(conf_file_path, "r") as conf_file:
|
||||||
content = json.load(conf_file)
|
content = json.load(conf_file)
|
||||||
py_version = content['py_version']
|
py_version = content["py_version"]
|
||||||
arch = content['arch']
|
arch = content["arch"]
|
||||||
system = content['system']
|
system = content["system"]
|
||||||
extension = content['extension']
|
extension = content["extension"]
|
||||||
abi = content['abi']
|
abi = content["abi"]
|
||||||
|
|
||||||
# Construct the filename directly
|
# Construct the filename directly
|
||||||
lib_filename = f"_pyhailort.cpython-{py_version.split('cp')[1]}-{arch}-{system}-{abi}.{extension}"
|
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}")
|
lib_path = os.path.join(
|
||||||
|
os.path.abspath(os.path.dirname(__file__)),
|
||||||
|
f"hailo_platform/pyhailort/{lib_filename}",
|
||||||
|
)
|
||||||
|
|
||||||
if os.path.exists(lib_path):
|
if os.path.exists(lib_path):
|
||||||
print(f"Found _pyhailort shared library at: {lib_path}")
|
print(f"Found _pyhailort shared library at: {lib_path}")
|
||||||
else:
|
else:
|
||||||
print(f"Error: _pyhailort shared library not found at: {lib_path}")
|
print(f"Error: _pyhailort shared library not found at: {lib_path}")
|
||||||
raise FileNotFoundError(f"_pyhailort shared library not found at: {lib_path}")
|
raise FileNotFoundError(
|
||||||
|
f"_pyhailort shared library not found at: {lib_path}"
|
||||||
|
)
|
||||||
|
|
||||||
return lib_path
|
return lib_path
|
||||||
|
|
||||||
|
|
||||||
def _get_package_paths():
|
def _get_package_paths():
|
||||||
packages = []
|
packages = []
|
||||||
pyhailort_lib = _get_pyhailort_lib_path()
|
pyhailort_lib = _get_pyhailort_lib_path()
|
||||||
hailort_lib = _get_hailort_lib_path()
|
hailort_lib = _get_hailort_lib_path()
|
||||||
if pyhailort_lib:
|
if pyhailort_lib:
|
||||||
packages.append(pyhailort_lib)
|
packages.append(pyhailort_lib)
|
||||||
if hailort_lib:
|
if hailort_lib:
|
||||||
@ -76,6 +72,7 @@ def _get_package_paths():
|
|||||||
packages.append(os.path.abspath("hailo_tutorials/hefs/*"))
|
packages.append(os.path.abspath("hailo_tutorials/hefs/*"))
|
||||||
return packages
|
return packages
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
setup(
|
setup(
|
||||||
author="Hailo team",
|
author="Hailo team",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user