[Numpy-svn] r6292 - trunk/numpy/distutils

numpy-svn@scip... numpy-svn@scip...
Sun Jan 4 05:08:21 CST 2009


Author: cdavid
Date: 2009-01-04 05:08:16 -0600 (Sun, 04 Jan 2009)
New Revision: 6292

Modified:
   trunk/numpy/distutils/lib2def.py
   trunk/numpy/distutils/mingw32ccompiler.py
   trunk/numpy/distutils/misc_util.py
Log:
Do not use popen* but subprocess.Popen instead.

Modified: trunk/numpy/distutils/lib2def.py
===================================================================
--- trunk/numpy/distutils/lib2def.py	2009-01-04 10:57:39 UTC (rev 6291)
+++ trunk/numpy/distutils/lib2def.py	2009-01-04 11:08:16 UTC (rev 6292)
@@ -1,6 +1,7 @@
 import re
 import sys
 import os
+import subprocess
 
 __doc__ = """This module generates a DEF file from the symbols in
 an MSVC-compiled DLL import library.  It correctly discriminates between
@@ -59,13 +60,13 @@
         deffile = None
     return libfile, deffile
 
-def getnm(nm_cmd = 'nm -Cs python%s.lib' % py_ver):
+def getnm(nm_cmd = ['nm', '-Cs', 'python%s.lib' % py_ver]):
     """Returns the output of nm_cmd via a pipe.
 
 nm_output = getnam(nm_cmd = 'nm -Cs py_lib')"""
-    f = os.popen(nm_cmd)
-    nm_output = f.read()
-    f.close()
+    f = subprocess.Popen(nm_cmd, shell=True, stdout=subprocess.PIPE)
+    nm_output = f.stdout.read()
+    f.stdout.close()
     return nm_output
 
 def parse_nm(nm_output):
@@ -107,7 +108,7 @@
         deffile = sys.stdout
     else:
         deffile = open(deffile, 'w')
-    nm_cmd = '%s %s' % (DEFAULT_NM, libfile)
+    nm_cmd = [str(DEFAULT_NM), str(libfile)]
     nm_output = getnm(nm_cmd)
     dlist, flist = parse_nm(nm_output)
     output_def(dlist, flist, DEF_HEADER, deffile)

Modified: trunk/numpy/distutils/mingw32ccompiler.py
===================================================================
--- trunk/numpy/distutils/mingw32ccompiler.py	2009-01-04 10:57:39 UTC (rev 6291)
+++ trunk/numpy/distutils/mingw32ccompiler.py	2009-01-04 11:08:16 UTC (rev 6292)
@@ -9,6 +9,7 @@
 """
 
 import os
+import subprocess
 import sys
 import log
 
@@ -50,9 +51,10 @@
         # get_versions methods regex
         if self.gcc_version is None:
             import re
-            out = os.popen('gcc -dumpversion','r')
-            out_string = out.read()
-            out.close()
+            p = subprocess.Popen(['gcc', '-dumpversion'], shell=True,
+                                 stdout=subprocess.PIPE)
+            out_string = p.stdout.read()
+            p.stdout.close()
             result = re.search('(\d+\.\d+)',out_string)
             if result:
                 self.gcc_version = StrictVersion(result.group(1))

Modified: trunk/numpy/distutils/misc_util.py
===================================================================
--- trunk/numpy/distutils/misc_util.py	2009-01-04 10:57:39 UTC (rev 6291)
+++ trunk/numpy/distutils/misc_util.py	2009-01-04 11:08:16 UTC (rev 6292)
@@ -6,6 +6,7 @@
 import glob
 import atexit
 import tempfile
+import subprocess
 
 try:
     set
@@ -1340,7 +1341,10 @@
         revision = None
         m = None
         try:
-            sin, sout = os.popen4('svnversion')
+            p = subprocess.Popen(['svnversion'], shell=True,
+                    stdout=subprocess.PIPE, stderr=STDOUT,
+                    close_fds=True)
+            sout = p.stdout
             m = re.match(r'(?P<revision>\d+)', sout.read())
         except:
             pass



More information about the Numpy-svn mailing list