| setup (name = 'PackageName', |
| version = '1.0', |
| description = 'This is a demo package', |
| ext_modules = [module1]) |
| |
| |
| With this :file:`setup.py`, and a file :file:`demo.c`, running :: |
| |
n | python setup.py build |
n | python setup.py build |
| |
| will compile :file:`demo.c`, and produce an extension module named ``demo`` in |
| the :file:`build` directory. Depending on the system, the module file will end |
| up in a subdirectory :file:`build/lib.system`, and may have a name like |
| :file:`demo.so` or :file:`demo.pyd`. |
| |
| In the :file:`setup.py`, all execution is performed by calling the ``setup`` |
n | function. This takes a variable number of keyword arguments, of which the |
n | function. This takes a variable number of keyword arguments, of which the |
| example above uses only a subset. Specifically, the example specifies meta- |
| example above uses only a subset. Specifically, the example specifies |
| information to build packages, and it specifies the contents of the package. |
| meta-information to build packages, and it specifies the contents of the |
| Normally, a package will contain of addition modules, like Python source |
| package. Normally, a package will contain of addition modules, like Python |
| modules, documentation, subpackages, etc. Please refer to the distutils |
| source modules, documentation, subpackages, etc. Please refer to the distutils |
| documentation in Distributing Python Modules (XXX reference: ../dist/dist.html) |
| documentation in :ref:`distutils-index` to learn more about the features of |
| to learn more about the features of distutils; this section explains building |
| distutils; this section explains building extension modules only. |
| extension modules only. |
| |
| It is common to pre-compute arguments to :func:`setup`, to better structure the |
| driver script. In the example above, the\ ``ext_modules`` argument to |
| :func:`setup` is a list of extension modules, each of which is an instance of |
| the :class:`Extension`. In the example, the instance defines an extension named |
| ``demo`` which is build by compiling a single source file, :file:`demo.c`. |
| |
| In many cases, building an extension is more complex, since additional |
| library_dirs = ['/usr/local/lib'], |
| sources = ['demo.c']) |
| |
| setup (name = 'PackageName', |
| version = '1.0', |
| description = 'This is a demo package', |
| author = 'Martin v. Loewis', |
| author_email = 'martin@v.loewis.de', |
t | url = 'http://www.python.org/doc/current/ext/building.html', |
t | url = 'http://docs.python.org/extending/building', |
| long_description = ''' |
| This is really just a demo package. |
| ''', |
| ext_modules = [module1]) |
| |
| |
| In this example, :func:`setup` is called with additional meta-information, which |
| is recommended when distribution packages have to be built. For the extension |