-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
67 lines (51 loc) · 2.04 KB
/
setup.py
File metadata and controls
67 lines (51 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""Setup.py to ensure hwcomponents._version_scheme is importable during build."""
import sys
import os
from pathlib import Path
# Add paths to ensure hwcomponents can be imported
current_dir = Path(__file__).parent.absolute()
if str(current_dir) not in sys.path:
sys.path.insert(0, str(current_dir))
# Try to find hwcomponents in parent directories (for submodule case)
parent_dir = current_dir.parent.parent
hwcomponents_dir = parent_dir / "hwcomponents"
if hwcomponents_dir.exists() and str(parent_dir) not in sys.path:
sys.path.insert(0, str(parent_dir))
from setuptools import setup
from setuptools.command.build import build
import subprocess
try:
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel
class PlatformBdistWheel(_bdist_wheel):
"""Tag wheel as platform-specific since it contains a compiled binary."""
def finalize_options(self):
super().finalize_options()
self.root_is_pure = False
def get_tag(self):
_, _, plat = super().get_tag()
return "py3", "none", plat
except ImportError:
PlatformBdistWheel = None
class CustomBuildCommand(build):
"""Custom build command that runs make build before the normal build process."""
def run(self):
try:
print("Running 'make build'...")
subprocess.check_call(
["make", "build"], cwd=os.path.dirname(os.path.realpath(__file__))
)
print("'make build' completed successfully")
except subprocess.CalledProcessError as e:
print(f"Error running 'make build': {e}")
sys.exit(1)
except FileNotFoundError:
print("Warning: 'make' command not found. Skipping build step.")
except Exception as e:
print(f"Unexpected error running 'make build': {e}")
sys.exit(1)
# Call the parent build command
super().run()
cmdclass = {"build": CustomBuildCommand}
if PlatformBdistWheel is not None:
cmdclass["bdist_wheel"] = PlatformBdistWheel
setup(cmdclass=cmdclass)