RE: [Distutils] Why doesn't distutils respect the INCLUDE/LIB en vironment variable (MSVC)?
From: M.-A. Lemburg [mailto:mal@lemburg.com]
I don't know about the convention for looking up parameters on Windows: do env vars override settings in the registry or the other way around ?
I just checked. It's actually worse than I thought. The environment variables are the *only* thing that affect the command-line tools. The registry is purely for the IDE, I guess. So what distutils is doing, rather than being unhelpful, is actually wrong... It *is* possible to install Visual C++ in such a way that the environment variables are not set by default, leaving the user to run a BAT file to set them up before the command line tools are usable. It's possible that the distutils approach is to cater for such users, by registering the appropriate variables even if VCVARS32.BAT has not been run.
Depending on what the standard procedure is on Windows, I'd suggest to either prepend or append the env var settings to the LIB/INCLUDE values found through the registry.
Based on the above, I'd suggest not grubbing through the registry at all - just leave things as the user has them. Or to handle the case where the user hasn't set the environment variables, maybe check whether INCLUDE is set - if not, either prompt the user (probably better, as VCVARS32.BAT definitely does the right thing), or grub through the registry in that case only. A bare minimum patch (which just leaves the vars if set, otherwise works as at present) could be (UNTESTED): --- msvccompiler.py.orig Thu Apr 19 10:24:24 2001 +++ msvccompiler.py Mon Jul 16 14:02:05 2001 @@ -155,8 +155,11 @@ def set_path_env_var (name, version_number): """Set environment variable 'name' to an MSVC path type value obtained from 'get_msvc_paths()'. This is equivalent to a SET command prior - to execution of spawned commands.""" + to execution of spawned commands. If the environment variable is + already set, leave it alone.""" + if os.environ.has_key(name) + return p = get_msvc_paths (name, version_number) if p: os.environ[name] = string.join (p,';') Paul.
participants (1)
-
Moore, Paul