This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: The function cygwinccompiler.is_cygwingcc leads to FileNotFoundError under Windows 7
Type: behavior Stage: resolved
Components: Distutils Versions: Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Aaron.Meurer, asmeurer, dstufft, eric.araujo, paugier, steve.dower
Priority: normal Keywords:

Created on 2014-06-21 14:35 by paugier, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg221177 - (view) Author: PierreAugier (paugier) Date: 2014-06-21 14:35
Under Windows 7, with Python 3.4.1 |Anaconda 2.0.1 (64-bit), calling the function cygwinccompiler.is_cygwingcc of the distutils package leads to a FileNotFoundError.

I solved the problem for me by adding the argument shell=True in l. 404 of cygwinccompiler.py:

out_string = check_output(['gcc', '-dumpmachine'], shell=True)
msg227492 - (view) Author: Aaron Meurer (Aaron.Meurer) Date: 2014-09-24 22:50
The issue is that that the Anaconda gcc on Windows is a bat file, so it can't find it. Another fix would be to use find_executable. This is because Anaconda has patched find_executalbe (which it also would be good to get backported)

diff --git Lib/distutils/spawn.py Lib/distutils/spawn.py
index b1c5a44..4703f00 100644
--- Lib/distutils/spawn.py
+++ Lib/distutils/spawn.py
@@ -156,17 +156,16 @@ def find_executable(executable, path=None):
         path = os.environ['PATH']

     paths = path.split(os.pathsep)
-    base, ext = os.path.splitext(executable)
-
-    if (sys.platform == 'win32') and (ext != '.exe'):
-        executable = executable + '.exe'
-
-    if not os.path.isfile(executable):
-        for p in paths:
-            f = os.path.join(p, executable)
-            if os.path.isfile(f):
-                # the file exists, we have a shot at spawn working
-                return f
-        return None
-    else:
-        return executable
+
+    for ext in '.exe', '.bat', '':
+        newexe = executable + ext
+
+        if os.path.isfile(newexe):
+            return newexe
+        else:
+            for p in paths:
+                f = os.path.join(p, newexe)
+                if os.path.isfile(f):
+                    # the file exists, we have a shot at spawn working
+                    return f
+    return None
msg386393 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:26
Distutils is now deprecated (see PEP 632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils.

If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools
msg386455 - (view) Author: Aaron Meurer (asmeurer) Date: 2021-02-03 20:12
Is find_executable() going to be extracted from distutils to somewhere else? It's one of those functions that is useful outside of packaging, and indeed, I've seen it imported in quite a few codes that aren't related to packaging. If so, the patch I mentioned could still be relevant for it (if it hasn't been fixed already).
msg386459 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 21:44
shutil.which is the supported replacement for that function.
History
Date User Action Args
2022-04-11 14:58:05adminsetgithub: 66020
2021-02-03 21:44:38steve.dowersetmessages: + msg386459
2021-02-03 20:12:04asmeurersetnosy: + asmeurer
messages: + msg386455
2021-02-03 18:26:35steve.dowersetstatus: open -> closed

nosy: + steve.dower
messages: + msg386393

resolution: out of date
stage: resolved
2014-09-24 22:50:58Aaron.Meurersetmessages: + msg227492
2014-06-23 16:35:23Aaron.Meurersetnosy: + Aaron.Meurer
2014-06-21 14:35:56paugiercreate