
In article <20000201090005.C17402@cnri.reston.va.us>, Greg Ward <gward@cnri.reston.va.us> writes
On 31 January 2000, Robin Becker said:
it seems that not all of the directories obtained from the keys are actually rock solid eg they are part of the devstudio customisables.
I'm fairly sure that you could add all of the Path dirs to the path set Include=all the directories in Include Dirs (; sep) set Lib=all in the lib dirs (; sep)
and then cl.exe etc are supposed to work.
???
I don't follow. Are `Include' and `Lib' environment variables that you want me to set? If you could just supply a new patch to msvccompiler.py, I think we'd save a lot of bouncing back and forth.
Thanks --
Greg ...
OK this patch works for me with none of the vcvars things set. I tried building Numeric and it works modulo complaints about missing arrayfns.def I don't have that so the dll hasn't got an entry point. *** msvccompiler.py.org Mon Jan 17 21:57:18 2000 --- msvccompiler.py Tue Feb 01 16:11:20 2000 *************** *** 10,19 **** --- 10,104 ---- import os import sys + import string from distutils.errors import * from distutils.ccompiler import \ CCompiler, gen_preprocess_options, gen_lib_options + def _devstudio_versions(): + "Get a list of devstudio versions" + try: + import win32api + import win32con + except ImportError: + return None + + K = 'Software\\Microsoft\\Devstudio' + L = [] + for base in (win32con.HKEY_CLASSES_ROOT,win32con.HKEY_LOCAL_MACHINE,win32con.HKEY_CURRENT_USER,win32con.HKEY_USERS): + try: + k = win32api.RegOpenKeyEx(base,K) + i = 0 + while 1: + try: + p = win32api.RegEnumKey(k,i) + if p[0] in '123456789' and p not in L: + L.append(p) + except win32api.error: + break + i = i + 1 + except win32api.error: + pass + L.sort() + return L + + def _msvc_get_paths(path, vNum='6.0', platform='x86'): + "Get a devstudio path (include, lib or path)" + try: + import win32api + import win32con + except ImportError: + return None + + L = [] + if path=='lib': path= 'Library' + path = string.upper(path + ' Dirs') + K = 'Software\\Microsoft\\Devstudio\\%s\\Build System\\Components\\Platforms\\Win32 (%s)\\Directories' \ + % (vNum,platform) + for base in (win32con.HKEY_CLASSES_ROOT,win32con.HKEY_LOCAL_MACHINE,win32con.HKEY_CURRENT_USER,win32con.HKEY_USERS): + try: + k = win32api.RegOpenKeyEx(base,K) + i = 0 + while 1: + try: + (p,v,t) = win32api.RegEnumValue(k,i) + if string.upper(p)==path: + V = string.split(v,';') + for v in V: + if v=='' or v in L: continue + L.append(v) + break + i = i + 1 + except win32api.error: + break + except win32api.error: + pass + return L + + def _find_exe(exe): + for v in _devstudio_versions(): + for p in _msvc_get_paths('bin',v): + fn=os.path.join(os.path.abspath(p),exe) + if os.path.isfile(fn): return fn + + #didn't find it; try existing path + try: + for p in string.split(os.environ['Path'],';'): + fn=os.path.join(os.path.abspath(p),exe) + if os.path.isfile(fn): return fn + except: + pass + return exe #last desperate hope + + def _find_SET(n): + for v in _devstudio_versions(): + p=_msvc_get_paths(n,v) + if p!=[]: return p + return [] + + def _do_SET(n): + p=_find_SET(n) + if p!=[]: os.environ[n]=string.join(p,';') class MSVCCompiler (CCompiler) : """Concrete class that implements an interface to Microsoft Visual C++, *************** *** 34,41 **** self.add_library ( "python" + sys.version[0] + sys.version[2] ) self.add_library_dir( os.path.join( sys.exec_prefix, 'libs' ) ) ! self.cc = "cl.exe" ! self.link = "link.exe" self.preprocess_options = None self.compile_options = [ '/nologo', '/Ox', '/MD' ] --- 119,135 ---- self.add_library ( "python" + sys.version[0] + sys.version[2] ) self.add_library_dir( os.path.join( sys.exec_prefix, 'libs' ) ) ! self.cc = _find_exe("cl.exe") ! self.link = _find_exe("link.exe") ! _do_SET('lib') ! _do_SET('include') ! path=_find_SET('path') ! try: ! for p in string.split(os.environ['path'],';'): ! path.append(p) ! except KeyError: ! pass ! os.environ['path'] = string.join(path,';') self.preprocess_options = None self.compile_options = [ '/nologo', '/Ox', '/MD' ] -- Robin Becker