|
24 | 24 | # and binaries. Use one of the gn build targets instead if you want |
25 | 25 | # to avoid poluting the source tree. |
26 | 26 |
|
27 | | -from setuptools import Extension, setup |
28 | 27 | from pathlib import Path |
| 28 | + |
29 | 29 | from pybind11 import get_include |
30 | 30 | from pybind11.setup_helpers import Pybind11Extension, build_ext |
| 31 | +from setuptools import setup |
31 | 32 | from version_generator import generate_loadgen_version_definitions |
32 | | -import subprocess |
33 | 33 |
|
34 | 34 | generated_version_source_filename = "generated/version_generated.cc" |
35 | 35 | generate_loadgen_version_definitions(generated_version_source_filename, ".") |
|
42 | 42 | "test_settings.h", |
43 | 43 | "issue_query_controller.h", |
44 | 44 | "early_stopping.h", |
45 | | - "query_dispatch_library.h" |
| 45 | + "query_dispatch_library.h", |
46 | 46 | ] |
47 | 47 |
|
48 | 48 | lib_headers = [ |
|
54 | 54 | "results.h", |
55 | 55 | "bindings/c_api.h", |
56 | 56 | "version_generator.py", |
57 | | - "mlperf_conf.h" |
| 57 | + "mlperf_conf.h", |
58 | 58 | ] |
59 | 59 |
|
60 | 60 | lib_sources = [ |
|
93 | 93 |
|
94 | 94 |
|
95 | 95 | try: |
96 | | - with open("mlperf.conf", 'r') as file: |
| 96 | + with open("mlperf.conf", "r") as file: |
97 | 97 | conf_contents = file.read() |
98 | 98 |
|
99 | 99 | # Escape backslashes and double quotes |
100 | | - conf_contents = conf_contents.replace('\\', '\\\\').replace('"', '\\"') |
| 100 | + conf_contents = conf_contents.replace("\\", "\\\\").replace('"', '\\"') |
101 | 101 |
|
102 | 102 | # Convert newlines |
103 | | - conf_contents = conf_contents.replace('\n', '\\n"\n"') |
| 103 | + conf_contents = conf_contents.replace("\n", '\\n"\n"') |
104 | 104 |
|
105 | 105 | formatted_content = f'const char* mlperf_conf =\n"{conf_contents}";\n' |
106 | 106 |
|
107 | | - with open("mlperf_conf.h", 'w') as header_file: |
| 107 | + with open("mlperf_conf.h", "w") as header_file: |
108 | 108 | header_file.write(formatted_content) |
109 | 109 |
|
110 | 110 | except IOError as e: |
|
113 | 113 | mlperf_loadgen_module = Pybind11Extension( |
114 | 114 | "mlperf_loadgen", |
115 | 115 | define_macros=[ |
116 | | - ("MAJOR_VERSION", |
117 | | - version_split[0]), |
118 | | - ("MINOR_VERSION", |
119 | | - version_split[1]) |
| 116 | + ("MAJOR_VERSION", version_split[0]), |
| 117 | + ("MINOR_VERSION", version_split[1]), |
120 | 118 | ], |
121 | 119 | include_dirs=[".", get_include()], |
122 | 120 | sources=mlperf_loadgen_sources, |
123 | 121 | depends=mlperf_loadgen_headers, |
| 122 | + extra_compile_args=["-std=c++14", "-O3"], |
124 | 123 | ) |
125 | 124 |
|
126 | | -setup(name="mlcommons_loadgen", |
127 | | - version=version, |
128 | | - description="MLPerf Inference LoadGen python bindings", |
129 | | - url="https://mlcommons.org/", |
130 | | - cmdclass={"build_ext": build_ext}, |
131 | | - ext_modules=[mlperf_loadgen_module], |
132 | | - packages=['mlcommons_loadgen'], |
133 | | - package_dir={'mlcommons_loadgen': '.'}, |
134 | | - include_package_data=True, |
135 | | - long_description=mlperf_long_description, |
136 | | - long_description_content_type='text/markdown') |
| 125 | +setup( |
| 126 | + name="mlcommons_loadgen", |
| 127 | + version=version, |
| 128 | + description="MLPerf Inference LoadGen python bindings", |
| 129 | + url="https://mlcommons.org/", |
| 130 | + cmdclass={"build_ext": build_ext}, |
| 131 | + ext_modules=[mlperf_loadgen_module], |
| 132 | + packages=["mlcommons_loadgen"], |
| 133 | + package_dir={"mlcommons_loadgen": "."}, |
| 134 | + include_package_data=True, |
| 135 | + long_description=mlperf_long_description, |
| 136 | + long_description_content_type="text/markdown", |
| 137 | +) |
0 commit comments