[Scipy-svn] r5320 - trunk/scipy/weave
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Jan 4 06:24:01 EST 2009
Author: cdavid
Date: 2009-01-04 05:23:56 -0600 (Sun, 04 Jan 2009)
New Revision: 5320
Modified:
trunk/scipy/weave/build_tools.py
trunk/scipy/weave/platform_info.py
Log:
Do not use popen* in weave anymore.
Modified: trunk/scipy/weave/build_tools.py
===================================================================
--- trunk/scipy/weave/build_tools.py 2009-01-04 11:23:42 UTC (rev 5319)
+++ trunk/scipy/weave/build_tools.py 2009-01-04 11:23:56 UTC (rev 5320)
@@ -23,6 +23,7 @@
import tempfile
import exceptions
import commands
+import subprocess
import platform_info
@@ -341,11 +342,11 @@
Does this return correct value on win98???
"""
result = 0
- cmd = '%s -v' % name
+ cmd = [str(name), '-v']
try:
- w,r=os.popen4(cmd)
- w.close()
- str_result = r.read()
+ p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, close_fds=True)
+ str_result = p.stdout.read()
#print str_result
if 'Reading specs' in str_result:
result = 1
@@ -362,9 +363,9 @@
"""
result = 0
try:
- w,r=os.popen4('cl')
- w.close()
- str_result = r.read()
+ p = subprocess.Popen(['cl'], shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, close_fds=True)
+ str_result = p.stdout.read()
#print str_result
if 'Microsoft' in str_result:
result = 1
@@ -379,9 +380,9 @@
if os.name == 'nt':
def run_command(command):
""" not sure how to get exit status on nt. """
- in_pipe,out_pipe = os.popen4(command)
- in_pipe.close()
- text = out_pipe.read()
+ p = subprocess.Popen(['cl'], shell=True, stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT, close_fds=True)
+ text = p.stdout.read()
return 0, text
else:
run_command = commands.getstatusoutput
@@ -457,9 +458,9 @@
# 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, close_fds=True)
+ out_string = p.stdout.read()
result = re.search('(\d+\.\d+)',out_string)
if result:
self.gcc_version = StrictVersion(result.group(1))
Modified: trunk/scipy/weave/platform_info.py
===================================================================
--- trunk/scipy/weave/platform_info.py 2009-01-04 11:23:42 UTC (rev 5319)
+++ trunk/scipy/weave/platform_info.py 2009-01-04 11:23:56 UTC (rev 5320)
@@ -5,7 +5,7 @@
multiple platforms share the same file system.
"""
-import os, sys
+import os, sys, subprocess
import distutils
from distutils.sysconfig import customize_compiler
@@ -169,9 +169,9 @@
result = 0
cmd = '%s -v' % name
try:
- w,r=os.popen4(cmd)
- w.close()
- str_result = r.read()
+ p = subprocess.Popen([str(name), '-v'], shell=True, close_fds=True,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ str_result = p.stdout.read()
if 'Reading specs' in str_result:
result = 1
except:
@@ -187,9 +187,9 @@
"""
result = 0
try:
- w,r=os.popen4('cl')
- w.close()
- str_result = r.read()
+ p = subprocess.Popen(['cl'], shell=True, close_fds=True,
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ str_result = p.stdout.read()
if 'Microsoft' in str_result:
result = 1
except:
More information about the Scipy-svn
mailing list