The setup script is the centre of all activity in building, distributing, andinstalling modules using the Distutils. The main purpose of the setup script isto describe your module distribution to the Distutils, so that the variouscommands that operate on your modules do the right thing. As we saw in sectionA Simple Example above, the setup script consists mainly of a call tosetup(), and most information supplied to the Distutils by the moduledeveloper is supplied as keyword arguments to setup().
Setup Akey 1.5.2
Note that any pathnames (files or directories) supplied in the setup scriptshould be written using the Unix convention, i.e. slash-separated. TheDistutils will take care of converting this platform-neutral representation intowhatever is appropriate on your current platform before actually using thepathname. This makes your setup script portable across operating systems, whichof course is one of the major goals of the Distutils. In this spirit, allpathnames in this document are slash-separated.
The packages option tells the Distutils to process (build, distribute,install, etc.) all pure Python modules found in each package mentioned in thepackages list. In order to do this, of course, there has to be acorrespondence between package names and directories in the filesystem. Thedefault correspondence is the most obvious one, i.e. package distutils isfound in the directory distutils relative to the distribution root.Thus, when you say packages = ['foo'] in your setup script, you arepromising that the Distutils will find a file foo/__init__.py (whichmight be spelled differently on your system, but you get the idea) relative tothe directory where your setup script lives. If you break this promise, theDistutils will issue a warning but still process the broken package anyway.
in your setup script. The keys to this dictionary are package names, and anempty package name stands for the root package. The values are directory namesrelative to your distribution root. In this case, when you say packages =['foo'], you are promising that the file lib/foo/__init__.py exists.
All of this is done through another keyword argument to setup(), theext_modules option. ext_modules is just a list ofExtension instances, each of which describes asingle extension module.Suppose your distribution includes a single extension, called foo andimplemented by foo.c. If no additional instructions to thecompiler/linker are needed, describing this extension is quite simple:
Dependencies on other Python modules and packages can be specified by supplyingthe requires keyword argument to setup(). The value must be a list ofstrings. Each string specifies a package that is required, and optionally whatversions are sufficient.
Now that we can specify dependencies, we also need to be able to specify what weprovide that other distributions can require. This is done using the provideskeyword argument to setup(). The value for this keyword is a list ofstrings, each of which names a Python module or package, and optionallyidentifies the version. If the version is not specified, it is assumed to matchthat of the distribution.
Package data can be added to packages using the package_data keywordargument to the setup() function. The value must be a mapping frompackage name to a list of relative path names that should be copied into thepackage. The paths are interpreted as relative to the directory containing thepackage (information from the package_dir mapping is used if appropriate);that is, the files are expected to be part of the package in the sourcedirectories. They may contain glob patterns as well.
Each file name in files is interpreted relative to the setup.pyscript at the top of the package source distribution. Note that you canspecify the directory where the data files will be installed, but you cannotrename the data files themselves. 2ff7e9595c
Comments