Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to compile c-extensions under WinXP?

1 view
Skip to first unread message

sev...@sophia.dtp.fmph.uniba.sk

unread,
Nov 4, 2005, 5:25:44 AM11/4/05
to pytho...@python.org
What should I do to be able to compile C-extensions (with python 2.4,
winXP)? I get an error message, approximately "The .NET Framework SDK
needs to be installed"; I tried to get something from the Microsoft web
site, but maybe not the right version (or didn't set some variables),
since the error remains. Could you please help me (it will need some
patience with a computer newbie)?

Gerhard Häring

unread,
Nov 4, 2005, 6:47:00 AM11/4/05
to pytho...@python.org

I managed to do it with the instructions at

http://www.vrplumber.com/programming/mstoolkit/

-- Gerhard

Steve Holden

unread,
Nov 4, 2005, 7:00:43 AM11/4/05
to pytho...@python.org
sev...@sophia.dtp.fmph.uniba.sk wrote:
> What should I do to be able to compile C-extensions (with python 2.4,
> winXP)? I get an error message, approximately "The .NET Framework SDK
> needs to be installed"; I tried to get something from the Microsoft web
> site, but maybe not the right version (or didn't set some variables),
> since the error remains. Could you please help me (it will need some
> patience with a computer newbie)?
>
See

http://www.vrplumber.com/programming/mstoolkit

and say thanks to Mike Farmer.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/

Peter Notebaert

unread,
Nov 5, 2005, 10:46:07 AM11/5/05
to

<sev...@sophia.dtp.fmph.uniba.sk> wrote in message
news:mailman.111.11311010...@python.org...

You need the Microsoft .NET Visual Studio environment. A stripped and free
version is available at http://msdn.microsoft.com/visualc/vctoolkit2003/
However I am not sure if everything will work with this stripped version.

Peter


Steve Holden

unread,
Nov 5, 2005, 11:21:39 AM11/5/05
to pytho...@python.org
Steve Holden wrote:

> sev...@sophia.dtp.fmph.uniba.sk wrote:
>
>>What should I do to be able to compile C-extensions (with python 2.4,
>>winXP)? I get an error message, approximately "The .NET Framework SDK
>>needs to be installed"; I tried to get something from the Microsoft web
>>site, but maybe not the right version (or didn't set some variables),
>>since the error remains. Could you please help me (it will need some
>>patience with a computer newbie)?
>>
>
> See
>
> http://www.vrplumber.com/programming/mstoolkit
>
> and say thanks to Mike Farmer.
>

That's Mike Fletcher [sorry, Mike].

Scott David Daniels

unread,
Nov 8, 2005, 4:33:35 PM11/8/05
to mcfl...@vrplumber.com
Steve Holden wrote:
> sev...@sophia.dtp.fmph.uniba.sk wrote:
>
>> What should I do to be able to compile C-extensions (with python 2.4,
>> winXP)? I get an error message, approximately "The .NET Framework SDK
>> needs to be installed"; I tried to get something from the Microsoft
>> web site, but maybe not the right version (or didn't set some
>> variables), since the error remains. Could you please help me (it will
>> need some patience with a computer newbie)?
>>
> See
>
> http://www.vrplumber.com/programming/mstoolkit
>
> regards
> Steve

I just got the following to work for me, maybe it will work for you.
I had some hassles with trying to get the patches to work and wanted a
technique which did not involve messing with the distribution.
It has the advantage of not actually writing into the main Python files.
You still need the free tools Mr. Fletcher links to, and a copy of
the "v7.bat" file that he talks about making (here I show it as in
C:/bin/v7.bat).

Here's an example setup:


__version__ = '0.3'

from distutils.core import setup, Extension

for attempts in range(2):
try:
setup(name='simple', version='0.9',
ext_modules=[Extension('simple', ['simple.c'])])
except SystemExit, e:
print '*** Failed:', e.args[0]
else:
break # Successful (avoid the retry)


print 'Attempting to patch distutils.msvccompiler and retry:'

<<patching code>>


=============
Patching code can either be a (properly indented) literal copy of the
following code, or you can simply write the following into a file
named "patch_msvc.py" and use "import patch_msvc" for patching code.


import distutils.msvccompiler

class BatReader(object):
def __init__(self, batch_filename):
self.source = open(batch_filename, 'rU')

def getsets(self):
'''Get all command lines which are "SET" commands.'''
self.source.seek(0)
for line in self.source:
try: command, rest = line.split(None, 1)
except ValueError: continue # Set a=b splits fine
if command.lower() == 'set':
try: key, value = rest.split('=', 1)
except ValueError: continue # breaking a=b;c;d
elif command.lower() == 'path':
key, value = command, rest #path x == set path=x
yield key, value.rstrip()

def paths(self, pathkey):
'''Find the file paths using our getsets methods.'''
keyed = pathkey.upper()
for key, paths in self.getsets():
if key.upper() == keyed:
elements = paths.split(';')
if elements[-1].upper() == keyed.join('%%'):
return elements[: -1]
return elements

class MSVCCompiler(distutils.msvccompiler.MSVCCompiler):
_patho = BatReader(r'C:\bin\vc7.bat') # or vcvars32.bat or ...
def get_msvc_paths(self, path, platform='x86'):
if path == 'library': path = 'lib'
return self._patho.paths(path)

distutils.msvccompiler.MSVCCompiler = MSVCCompiler
# OK, patched it, now go try again.

--
-Scott David Daniels
scott....@acm.org

0 new messages