distutils problem windows xp python 2.4.2

A

ajikoe

Hello I tried to combine c++ and python together.
So I follow from this website:
http://kortis.to/radix/python_ext/

I have this code:
# prmodule.c
static PyObject *pr_isprime(PyObject *self, PyObject *args){
int n, input;

if (!PyArg_ParseTuple(args, "i", &input))
return NULL;

if (input < 1) {
return Py_BuildValue("i", 0);
}

n = input - 1;

while (n > 1){
if (input%n == 0) return Py_BuildValue("i", 0);;
n--;
}

return Py_BuildValue("i", 1);
}

static PyMethodDef PrMethods[] = {
{"isprime", pr_isprime, METH_VARARGS, "Check if prime."},
{NULL, NULL, 0, NULL}
};

void initpr(void){
(void) Py_InitModule("pr", PrMethods);
}



and my setup.py file:
from distutils.core import setup, Extension
module = Extension('pr', sources = ['prmodule.c'])
setup(name = 'Pr test', version = '1.0', ext_modules = [module])

------------------------------------
If I run setup build
I've got the following error message
running build
running build_ext
error: The .NET Framework SDK needs to be installed before building
extensions for Python.

I use visual Studio 2005.

Thanks,
pujo
 
S

Scott David Daniels

Hello I tried to combine c++ and python together.
So I follow from this website:
http://kortis.to/radix/python_ext/
....
and my setup.py file:
from distutils.core import setup, Extension
module = Extension('pr', sources = ['prmodule.c'])
setup(name = 'Pr test', version = '1.0', ext_modules = [module])

------------------------------------
If I run setup build
I've got the following error message
running build
running build_ext
error: The .NET Framework SDK needs to be installed before building
extensions for Python.

I use visual Studio 2005.

Thanks,
pujo
You might take a look at:

http://groups.google.com/group/comp.lang.python/msg/2341e3ac80ae5052?dmode=source

it provides code to change your setup code to:
from distutils.core import setup, Extension
module = Extension('pr', sources = ['prmodule.c'])

for attempts in range(2):
try:
setup(name='Pr test',
version='1.0',
ext_modules=[module])
except SystemExit, e: pass # Failure. Patch and try again
else: break # Successful run, no need to retry.

print '*** Apparently a failure:', e.args[0]
print '*** Patching and trying again'
import patch_msvccompiler

--Scott David Daniels
(e-mail address removed)
 
A

ajikoe

Hello Scott,

It didn't work with visual studio 5. .Net framework 2.0
Do you have any suggestions?

Thanks,
pujo
 
S

Scott David Daniels

It didn't work with visual studio 5. .Net framework 2.0
Do you have any suggestions?

"It didn't work" is not very diagnosable.

--Scott David Daniels
(e-mail address removed)
 
A

ajikoe

Hello,

It give the same error result:
D:\testprogram\distutils problem>setup build
running build
running build_ext
*** Failed: error: The .NET Framework SDK needs to be installed before
building extensions for Python.
Attempting to patch distutils.msvccompiler and retry:
running build
running build_ext
*** Failed: error: The .NET Framework SDK needs to be installed before
building extensions for Python.
Attempting to patch distutils.msvccompiler and retry:

This is inside my setup.py
#from distutils.core import setup, Extension
#
#module = Extension('pr', sources = ['prmodule.c'])
#setup(name = 'Pr test', version = '1.0', ext_modules = [module])
#

__version__ = '0.3'

from distutils.core import setup, Extension

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


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

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:\Program Files\Microsoft Visual Studio
8\VC\bin\vcvars32.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.

Yours,
pujo
 
S

Scott David Daniels

*** Failed: error: The .NET Framework SDK needs to be installed before
building extensions for Python.
....
It is so much easier with the actual error messages.

Ah-ha -- you installed the compiler but not the .NET Framework.
You have more downloading and installing to do.

See, for example:
http://www.vrplumber.com/programming/mstoolkit/

--Scott David Daniels
(e-mail address removed)
 
A

ajikoe

Hello,

I have .net framework 2.0 because I' already able to run visual studio
express 2005.
Should I install .net framework 1.1 and also ms toolkit ?

Sincerely Yours,
pujo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top