|
23 | 23 | import datetime |
24 | 24 |
|
25 | 25 | try: |
26 | | - cmakeVersion = subprocess.check_output(["cmake", "--version"]) |
| 26 | + cmakeVersion = subprocess.call(["cmake", "--version"]) |
27 | 27 | except Exception as e: |
| 28 | + print(e) |
28 | 29 | print("[ERROR] cmake is not found. Please install cmake.") |
29 | 30 | quit(-1) |
30 | 31 |
|
|
57 | 58 | class CMakeExtension(Extension): |
58 | 59 | def __init__(self, name, **kwargs): |
59 | 60 | # don't invoke the original build_ext for this special extension |
60 | | - Extension.__init__(self, name, sources=[], **kwargs) |
| 61 | + import tempfile |
| 62 | + # Create a temp file to create a dummy target. This build raises an |
| 63 | + # exception because sources are empty. With python3 we can fix it by |
| 64 | + # passing `optional=True` to the argument. With python2 there is no |
| 65 | + # getaway from it. |
| 66 | + f = tempfile.NamedTemporaryFile(suffix='.cpp', delete=False) |
| 67 | + f.write('int main() { return 1; }') |
| 68 | + Extension.__init__(self, name, sources=[f.name], **kwargs) |
| 69 | + f.close() |
61 | 70 |
|
62 | 71 | class TestCommand(Command): |
63 | 72 | user_options = [] |
@@ -162,6 +171,6 @@ def build_cmake(self, ext): |
162 | 171 | , os.path.join('chemUtil', 'rainbow2.pkl') |
163 | 172 | ] |
164 | 173 | }, |
165 | | - ext_modules=[CMakeExtension('pymoose', optional=True)], |
| 174 | + ext_modules=[CMakeExtension('dummy', optional=True)], |
166 | 175 | cmdclass={'build_ext': build_ext, 'test': TestCommand}, |
167 | 176 | ) |
0 commit comments