setup() and C extensions

7stud bbxx789_05ss at yahoo.com
Tue Apr 10 02:02:22 EDT 2007


Hi,

I can't find any documentation on the setup() function in the
distutils.core module; specifically I want to know what the 'name'
argument does.  In some examples in the python docs, they use the name
argument like this:
----
from distutils.core import setup, Extension

module1 = Extension('demo',
                    sources = ['demo.c'])

setup (name = 'PackageName',
       version = '1.0',
       description = 'This is a demo package',
       ext_modules = [module1])
----
http://python.org/doc/current/ext/building.html#building

So it looks like the 'name' argument should be a package name.
However, when I compile an extension module using that format, I can
import the module using the syntax:

import module1

I don't have to use PackageName.module1.

On the other hand, in another example in the python docs, they do
this:
---
from distutils.core import setup, Extension

setup(name='foo',
      version='1.0',
      ext_modules=[Extension('foo', ['foo.c'])],
      )
----
http://python.org/doc/current/dist/describing-extensions.html

In that example, the name argument matches the module name in the
Extension constructor.  A similar example by Alex Martelli can be
found at:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66509

So what is the name argument in setup() used for?




More information about the Python-list mailing list