Skip to content

Commit b218548

Browse files
makes cpu-benchmark optimal and adds uv.lock for reproducible builds with uv package manager. This enables WfCommons to be installed on Windows where make and g++ are not typically available by default.
1 parent f1091e5 commit b218548

2 files changed

Lines changed: 1528 additions & 8 deletions

File tree

setup.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,41 @@
1010

1111
import sys
1212
import subprocess
13+
import os
1314

1415
from setuptools import setup, find_packages
1516
from setuptools.command.build_ext import build_ext
1617

1718
class Build(build_ext):
18-
"""Customized setuptools build command - builds protos on build."""
19+
"""Customized setuptools build command - builds cpu-benchmark on build."""
1920

2021
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")
2532
super().run()
2633

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+
2740
setup(
2841
packages=find_packages(),
2942
include_package_data=True,
3043
has_ext_modules=lambda: True,
3144
cmdclass={
3245
'build_ext': Build,
3346
},
34-
data_files=[
35-
('bin', ['bin/cpu-benchmark'])
36-
],
47+
data_files=data_files,
3748
scripts=[
3849
'bin/wfbench'
3950
],

0 commit comments

Comments
 (0)