classification
Title: get_versions() in cygwinccomiler.py cannot return correct gcc version
Type: compile error Stage: resolved
Components: Windows Versions: Python 2.7
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: 3togo, iritkatriel
Priority: normal Keywords:

Created on 2014-05-12 16:09 by 3togo, last changed 2021-06-20 14:20 by iritkatriel. This issue is now closed.

Messages (4)
msg218327 - (view) Author: Joe Chan (3togo) Date: 2014-05-12 16:09
cannot return correct gcc version if the path name contains "space".
Suggest to change to:

$ diff -rupN cygwinccompiler.py.original cygwinccompiler.py
--- cygwinccompiler.py.original 2014-05-12 23:54:01.296303800 +0800
+++ cygwinccompiler.py  2014-05-12 23:59:57.429673400 +0800
@@ -418,14 +418,14 @@ def get_versions():

     gcc_exe = find_executable('gcc')
     if gcc_exe:
-        out = os.popen(gcc_exe + ' -dumpversion','r')
+        out = os.popen('"%s" -dumpversion'%gcc_exe,'r')
         out_string = out.read()
         out.close()
         result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
         if result:
             gcc_version = LooseVersion(result.group(1))
         else:
-            gcc_version = None
+            gcc_version = None
     else:
         gcc_version = None
     ld_exe = find_executable('ld')
msg218333 - (view) Author: Joe Chan (3togo) Date: 2014-05-12 16:27
better to parenthesis all three exes[gcc, ld and dllwrap] with "%s" to better support path names that contain non-alphanumeric characters.

$ diff -rupN cygwinccompiler.py.original cygwinccompiler.py
--- cygwinccompiler.py.original 2014-05-12 23:54:01.296303800 +0800
+++ cygwinccompiler.py  2014-05-13 00:24:08.754684500 +0800
@@ -418,19 +418,19 @@ def get_versions():

     gcc_exe = find_executable('gcc')
     if gcc_exe:
-        out = os.popen(gcc_exe + ' -dumpversion','r')
+        out = os.popen('"%s" -dumpversion'%gcc_exe,'r')
         out_string = out.read()
         out.close()
         result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
         if result:
             gcc_version = LooseVersion(result.group(1))
         else:
-            gcc_version = None
+            gcc_version = None
     else:
         gcc_version = None
     ld_exe = find_executable('ld')
     if ld_exe:
-        out = os.popen(ld_exe + ' -v','r')
+        out = os.popen('"%s" -v'%ld_exe,'r')
         out_string = out.read()
         out.close()
         result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
@@ -442,7 +442,7 @@ def get_versions():
         ld_version = None
     dllwrap_exe = find_executable('dllwrap')
     if dllwrap_exe:
-        out = os.popen(dllwrap_exe + ' --version','r')
+        out = os.popen('"%s" --version'%dllwrap_exe,'r')
         out_string = out.read()
         out.close()
         result = re.search(' (\d+\.\d+(\.\d+)*)',out_string)
msg218352 - (view) Author: Joe Chan (3togo) Date: 2014-05-12 19:05
To prevent system crashes, I have to exclude msvc runtime library

$ diff -rupN cygwinccompiler.py.original cygwinccompiler.py
--- cygwinccompiler.py.original 2014-05-12 23:54:01.296303800 +0800
+++ cygwinccompiler.py  2014-05-13 02:59:37.870414900 +0800
@@ -341,7 +341,7 @@ class Mingw32CCompiler (CygwinCCompiler)

         # Include the appropriate MSVC runtime library if Python was built
         # with MSVC 7.0 or later.
-        self.dll_libraries = get_msvcr()
+        #self.dll_libraries = get_msvcr()

     # __init__ ()

@@ -418,19 +418,19 @@ def get_versions():

     gcc_exe = find_executable('gcc')
     if gcc_exe:
-        out = os.popen(gcc_exe + ' -dumpversion','r')
+        out = os.popen('"%s" -dumpversion'%gcc_exe,'r')
         out_string = out.read()
         out.close()
         result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
         if result:
             gcc_version = LooseVersion(result.group(1))
         else:
-            gcc_version = None
+            gcc_version = None
     else:
         gcc_version = None
     ld_exe = find_executable('ld')
     if ld_exe:
-        out = os.popen(ld_exe + ' -v','r')
+        out = os.popen('"%s" -v'%ld_exe,'r')
         out_string = out.read()
         out.close()
         result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
@@ -442,7 +442,7 @@ def get_versions():
         ld_version = None
     dllwrap_exe = find_executable('dllwrap')
     if dllwrap_exe:
-        out = os.popen(dllwrap_exe + ' --version','r')
+        out = os.popen('"%s" --version'%dllwrap_exe,'r')
         out_string = out.read()
         out.close()
         result = re.search(' (\d+\.\d+(\.\d+)*)',out_string)
msg396171 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-06-20 14:20
Closing as this is part of distutils which is deprecated now.
History
Date User Action Args
2021-06-20 14:20:26iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg396171

resolution: out of date
stage: resolved
2014-05-12 19:05:233togosetmessages: + msg218352
2014-05-12 16:27:203togosetmessages: + msg218333
2014-05-12 16:09:003togocreate