Skip to content

Commit 9f93811

Browse files
committed
Added a dummy target.
1 parent 6fa716c commit 9f93811

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

setup.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
import datetime
2424

2525
try:
26-
cmakeVersion = subprocess.check_output(["cmake", "--version"])
26+
cmakeVersion = subprocess.call(["cmake", "--version"])
2727
except Exception as e:
28+
print(e)
2829
print("[ERROR] cmake is not found. Please install cmake.")
2930
quit(-1)
3031

@@ -57,7 +58,15 @@
5758
class CMakeExtension(Extension):
5859
def __init__(self, name, **kwargs):
5960
# 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()
6170

6271
class TestCommand(Command):
6372
user_options = []
@@ -162,6 +171,6 @@ def build_cmake(self, ext):
162171
, os.path.join('chemUtil', 'rainbow2.pkl')
163172
]
164173
},
165-
ext_modules=[CMakeExtension('pymoose', optional=True)],
174+
ext_modules=[CMakeExtension('dummy', optional=True)],
166175
cmdclass={'build_ext': build_ext, 'test': TestCommand},
167176
)

0 commit comments

Comments
 (0)