[Patches] [ python-Patches-780821 ] More robust MSVC6 finder

SourceForge.net noreply at sourceforge.net
Thu Nov 13 15:12:44 EST 2003


Patches item #780821, was opened at 2003-07-31 12:50
Message generated for change (Comment added) made by pmagwene
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=780821&group_id=5470

Category: Distutils and setup.py
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Garth T Kidd (gtk)
Assigned to: Jeremy Hylton (jhylton)
Summary: More robust MSVC6 finder

Initial Comment:
My VS6 install on XP didn't set the 
r"Software\Microsoft\Devstudio\6.0\Build System" 
registry key relied upon by distutils.msvccompiler to find 
the compiler and linker executable. 

As a backup to the registry paths, this patch looks up 
the MSVCDIR environment variable and ensures its 
basename is appropriate for the Python build version: 

            if self.__version == 6: 
                matchbase = 'vc98'
            elif self.__version == 7: 
                matchbase = 'vc7'

Works fine on my machine, so long as I run 
VCVARS32.BAT, and fails appropriately if I ran the wrong 
VCVARS32.BAT by mistake (I have Visual Studio Net 
2003 also installed). 

The patch should be applied to distutils/msvccompiler.py.

----------------------------------------------------------------------

Comment By: Paul Magwene (pmagwene)
Date: 2003-11-13 20:12

Message:
Logged In: YES 
user_id=23286

The reliance on registry keys (and ignoring other environment variables) can also cause other headaches.  Here's a problem I ran into on a stock Python 2.3 when trying to compile extensions using VC6:

I'm using STLport instead of the buggy STL implementation that ships with VC6.  To have the STL headers included I put the STL directory at the beginning of the INCLUDE search path in VCVARS32.BAT *and* by setting the appropriate values in the environment variables.  

With these settings, when I built my Python C++ extension by hand everything worked hunky-dory.  However when I tried to use distutils it kept including the old header files.  It took me a good 20 minutes of head scratching to realize that distutils was ignoring my environment variables and preferentially grabbing whatever INCLUDE directory was specified in the registry key (even if I ran VCVARS32.bat before compiling). Once I set the registry variable by hand, everything worked ok.

Perhaps distutils can be configured to look for environment settings *before* searching out whatever is buried in the registry?

--Paul M.

----------------------------------------------------------------------

Comment By: Murray Steele (murraysteele)
Date: 2003-10-21 11:10

Message:
Logged In: YES 
user_id=891425

Having come across this problem myself, it seems that MSVC 6
doesn't create the r"Software\Microsoft\Devstudio\6.0\Build
System" registry keys until *after* you run the actual
Visual Studio IDE.  So just doing a plain install and never
running the IDE isn't enough.

This isn't much of a fix, just some kind of documentation
incase it bites some other fumbling developer in the future.

Someone somewhere else
(http://sourceforge.net/tracker/?func=detail&atid=105470&aid=451285&group_id=5470)
 suggested using the Environment Variables as well as the
registry keys in distutils to check for compiler
correctness.  Seems like a plan to me. 

And there is some more chat about this problem here
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=614770&group_id=5470

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2003-08-01 07:16

Message:
Logged In: YES 
user_id=21627

I'm curious, though, how you installed VS6 without getting
the registry settings. Doesn't this mean your installation
of VS6 is broken?

----------------------------------------------------------------------

Comment By: Garth T Kidd (gtk)
Date: 2003-08-01 04:06

Message:
Logged In: YES 
user_id=59803

WARNING: the first patch contains a typo. s/nstring/string/ 
and you'll be fine. New version attached. 

----------------------------------------------------------------------

Comment By: Jeremy Hylton (jhylton)
Date: 2003-07-31 22:09

Message:
Logged In: YES 
user_id=31392

I've desired the same functionality in the past.


----------------------------------------------------------------------

Comment By: Garth T Kidd (gtk)
Date: 2003-07-31 12:52

Message:
Logged In: YES 
user_id=59803

Whups. The patch didn't attach. 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=780821&group_id=5470



More information about the Patches mailing list