I figured this out, but the process isn't pleasant.
There are 3 problems with the PyWin32 installer:
- It reads your python install location out of the registry.
- Is assumes that your lib directory is a child of the directory containing python.exe
- It dumps 3 dlls to %WINDIR%\system32
So if you're running 64 bit python 2.7 on 64 bit windows or 32 on 32 and your virtual environment is in c:\scratch\env1\ the process looks like this:
- Copy python.exe and pythonw.exe from c:\scratch\env1\scripts to c:\scratch\env1
- Update the value "(default)" in the registry key HKLM\SOFTWARE\Python\PythonCore\2.7\InstallPath\ to "c:\scratch\env1\" (make sure you record the old value.)
- From the command line, where you've activated the virtual environment, install PyWin32 by running the installer.exe directly. Do not use easy_install.
- Set the InstallPath registry key back to the original value
- Delete python.exe and pythonw.exe from c:\scratch\env1\
- move pythoncom27.dll, pywintypes27.dll and pythoncomloader27.dll from %WINDIR%\system32\ to c:\scratch\env1\ (do not move python27.dll or you'll regret it)
This works well enough to run django-mssql in the virtual environment without having pywin32 installed outside of the virtual environment.