distutils problem windows xp python 2.4.2

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ajikoe@gmail.com

    #1

    distutils problem windows xp python 2.4.2

    Hello I tried to combine c++ and python together.
    So I follow from this website:


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

    if (!PyArg_ParseTu ple(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

  • Scott David Daniels

    #2
    Re: distutils problem windows xp python 2.4.2

    ajikoe@gmail.co m wrote:[color=blue]
    > 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
    >[/color]
    You might take a look at:



    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_msvccompi ler

    --Scott David Daniels
    scott.daniels@a cm.org

    Comment

    • ajikoe@gmail.com

      #3
      Re: distutils problem windows xp python 2.4.2

      Hello Scott,

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

      Thanks,
      pujo

      Comment

      • Scott David Daniels

        #4
        Re: distutils problem windows xp python 2.4.2

        ajikoe@gmail.co m wrote:[color=blue]
        > It didn't work with visual studio 5. .Net framework 2.0
        > Do you have any suggestions?[/color]

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

        --Scott David Daniels
        scott.daniels@a cm.org

        Comment

        • ajikoe@gmail.com

          #5
          Re: distutils problem windows xp python 2.4.2

          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.msvcc ompiler 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.msvcc ompiler 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.msvcc ompiler and retry:'

          import distutils.msvcc ompiler

          class BatReader(objec t):
          def __init__(self, batch_filename) :
          self.source = open(batch_file name, 'rU')

          def getsets(self):
          '''Get all command lines which are "SET" commands.'''
          self.source.see k(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(di stutils.msvccom piler.MSVCCompi ler):
          _patho = BatReader(r'C:\ Program Files\Microsoft Visual Studio
          8\VC\bin\vcvars 32.bat') # or vcvars32.bat or ...
          def get_msvc_paths( self, path, platform='x86') :
          if path == 'library': path = 'lib'
          return self._patho.pat hs(path)

          distutils.msvcc ompiler.MSVCCom piler = MSVCCompiler
          # OK, patched it, now go try again.

          Yours,
          pujo

          Comment

          • Scott David Daniels

            #6
            Re: distutils problem windows xp python 2.4.2

            ajikoe@gmail.co m wrote:
            ....[color=blue]
            > *** Failed: error: The .NET Framework SDK needs to be installed before
            > building extensions for Python.[/color]
            ....
            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:


            --Scott David Daniels
            scott.daniels@a cm.org

            Comment

            • ajikoe@gmail.com

              #7
              Re: distutils problem windows xp python 2.4.2

              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

              Comment

              Working...