|
10 | 10 |
|
11 | 11 | import sys |
12 | 12 | import subprocess |
| 13 | +import os |
13 | 14 |
|
14 | 15 | from setuptools import setup, find_packages |
15 | 16 | from setuptools.command.build_ext import build_ext |
16 | 17 |
|
17 | 18 | class Build(build_ext): |
18 | | - """Customized setuptools build command - builds protos on build.""" |
| 19 | + """Customized setuptools build command - builds cpu-benchmark on build.""" |
19 | 20 |
|
20 | 21 | def run(self): |
21 | | - protoc_command = ["make"] |
22 | | - if subprocess.call(protoc_command) != 0: |
23 | | - sys.stderr.write("Error: 'make' is not installed. Please install 'make' and try again.\n") |
24 | | - sys.exit(-1) |
| 22 | + # Try to build the cpu-benchmark, but make it optional |
| 23 | + # This allows installation on Windows where make/g++ may not be available |
| 24 | + try: |
| 25 | + result = subprocess.call(["make"], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL) |
| 26 | + if result != 0: |
| 27 | + sys.stderr.write("Warning: 'make' build failed. cpu-benchmark will not be available.\n") |
| 28 | + sys.stderr.write("This is expected on Windows. To build cpu-benchmark, install make and g++.\n") |
| 29 | + except (FileNotFoundError, OSError): |
| 30 | + sys.stderr.write("Warning: 'make' is not installed. cpu-benchmark will not be available.\n") |
| 31 | + sys.stderr.write("This is expected on Windows. To build cpu-benchmark, install make and g++.\n") |
25 | 32 | super().run() |
26 | 33 |
|
| 34 | +# Conditionally include cpu-benchmark if it exists |
| 35 | +data_files = [] |
| 36 | +cpu_benchmark_path = 'bin/cpu-benchmark' |
| 37 | +if os.path.exists(cpu_benchmark_path): |
| 38 | + data_files.append(('bin', [cpu_benchmark_path])) |
| 39 | + |
27 | 40 | setup( |
28 | 41 | packages=find_packages(), |
29 | 42 | include_package_data=True, |
30 | 43 | has_ext_modules=lambda: True, |
31 | 44 | cmdclass={ |
32 | 45 | 'build_ext': Build, |
33 | 46 | }, |
34 | | - data_files=[ |
35 | | - ('bin', ['bin/cpu-benchmark']) |
36 | | - ], |
| 47 | + data_files=data_files, |
37 | 48 | scripts=[ |
38 | 49 | 'bin/wfbench' |
39 | 50 | ], |
|
0 commit comments