473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

distutils problem windows xp python 2.4.2

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

Dec 4 '05 #1
6 2321
aj****@gmail.com wrote:
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....2?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
sc***********@acm.org
Dec 4 '05 #2
Hello Scott,

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

Thanks,
pujo

Dec 4 '05 #3
aj****@gmail.com wrote:
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
sc***********@acm.org
Dec 4 '05 #4
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

Dec 5 '05 #5
aj****@gmail.com wrote:
....
*** 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
sc***********@acm.org
Dec 5 '05 #6
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

Dec 6 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew Gregory | last post by:
In Python 2.2, I compiled some C++ code on Windows (MinGW compiler) to create an extension using distutils and the following setup.py file: from distutils.core import setup, Extension setup...
1
by: Peter Schmiedeskamp | last post by:
Hello, I'm writing in regard to the distutils package for python. I regularly repackage installers for silent/automated distribution on numerous Windows PCs throughout an enterprise. Sites such...
5
by: Lonnie Princehouse | last post by:
I'm in a situation where I need to distribute several interdependent Python packages. There are good reasons not to combine them all into one package. Distutils doesn't seem to be able to bundle...
15
by: Colin J. Williams | last post by:
The distutils download page has: -------------------------------------------------------- Current stable release The current stable release is Distutils 1.0.2; you can download it as: *...
5
by: Fuzzyman | last post by:
Python 2.4 is built with Microsoft Visiual C++ 7. This means that it uses msvcr7.dll, which *isn't* a standard part of the windows operating system. This means that if you build a windows installer...
0
by: Glenn Pierce | last post by:
Hi I have a question about writing a portable setup.py script for distutils. I have a directory structure like this. FreeImage/ |----------Source/ | |------ FreeImage.h |...
1
by: George van den Driessche | last post by:
Hi folks, I'm looking at packaging a project I'm working on using distutils. The project is for Windows and contains a COM server which needs registration, so the installer needs to be a little...
9
by: jtravs | last post by:
Hi all, I suspect that I'm doing something stupid, I would like some other opinions though. I'm getting started with ctypes and am trying to use distutils to help build my module. At the moment...
7
by: vedrandekovic | last post by:
Hello again, Is there any patch for python "distutils", for this ImportError: cannot import name log Regards, Vedran
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.