MinGW support #36
MinGW support #36
Conversation
On windows the temp file cannot be opened a second time while it is still opened by python. Close the file in python before asking the compiler to read it. See https://docs.python.org/3.7/library/tempfile.html#tempfile.NamedTemporaryFile
| try: | ||
| compiler.compile([fname], extra_postargs=[flagname]) | ||
| except setuptools.distutils.errors.CompileError: | ||
| return False |
SylvainCorlay
Sep 19, 2018
Member
What is the reason for not deleting the temporary file and moving this out of the context manager?
What is the reason for not deleting the temporary file and moving this out of the context manager?
isuruf
Sep 19, 2018
Author
Contributor
On windows the temp file cannot be opened a second time while
it is still opened by python. Close the file in python before
asking the compiler to read it.
See https://docs.python.org/3.7/library/tempfile.html#tempfile.NamedTemporaryFile
On windows the temp file cannot be opened a second time while
it is still opened by python. Close the file in python before
asking the compiler to read it.
See https://docs.python.org/3.7/library/tempfile.html#tempfile.NamedTemporaryFile
SylvainCorlay
Sep 19, 2018
Member
Ok it makes sense.
Ok it makes sense.
wjakob
Sep 19, 2018
Member
But in this case, the file should be deleted later.
But in this case, the file should be deleted later.
isuruf
Sep 19, 2018
Author
Contributor
How about something like below, so that I don't have to worry about cleaning up stuff?
import tempfile, os
with tempfile.TemporaryDirectory() as d:
fname = os.path.join(d, 'main.cpp')
with open(fname, 'w') as f:
f.write('int main (int argc, char **argv) { return 0; }')
try:
compiler.compile([fname], extra_postargs=[flagname])
except setuptools.distutils.errors.CompileError:
return False
return True
How about something like below, so that I don't have to worry about cleaning up stuff?
import tempfile, os
with tempfile.TemporaryDirectory() as d:
fname = os.path.join(d, 'main.cpp')
with open(fname, 'w') as f:
f.write('int main (int argc, char **argv) { return 0; }')
try:
compiler.compile([fname], extra_postargs=[flagname])
except setuptools.distutils.errors.CompileError:
return False
return True
isuruf
Feb 20, 2019
Author
Contributor
TemporaryDirectory is not in py 2.7. Reverting to deleting the file
TemporaryDirectory is not in py 2.7. Reverting to deleting the file
|
Has anyone tried to build this in MinGW? I see the Appveyor VMs use MSVC and conda ... |
|
Just to let you guys know that on my mingw system the pybind11 minimal example compiles fine without this PR. |
Yes, but does it work with MinGW 5.x or 4.x series which defaults to C++98? |
|
@SylvainCorlay, can you review again? |
This reverts commit 6be7a0c.
|
This looks good to me. The build failures seem unrelated. |
|
Ping |
fe696bc
to
08a2f37
|
This is ready for review now. |
|
Rebased and merged in 187e874, can you double-check that it's okay? |
No description provided.