Reputation: 601
I saw that scipy had setup.py files inside its sub packages. What do these setup.py files do? Is it used to build the sub packages?
Is there any documentation or a webpage where this is explained or like a tutorial?
Upvotes: 3
Views: 678
Reputation: 66331
Generally speaking, you don't need any additional setup scripts to build the distribution. SciPy requires additional setup scripts mainly to reduce the amount of subpackage-specific boilerplate configuration code. The setup scripts in SciPy subpackages are mainly used for configuration preparation when building the whole distribution - the building and packaging still being done from the root setup script. As described in NumPy Distutils - Users Guide:
Requirements for SciPy packages
SciPy consists of Python packages, called SciPy packages, that are available to Python users via the
scipy
namespace. Each SciPy package may contain other SciPy packages. And so on. Therefore, the SciPy directory tree is a tree of packages with arbitrary depth and width. Any SciPy package may depend on NumPy packages but the dependence on other SciPy packages should be kept minimal or zero.A SciPy package contains, in addition to its sources, the following files and directories:
setup.py
--- building script__init__.py
--- package initializertests/
--- directory of unittestsTheir contents are described below.
The
setup.py
fileIn order to add a Python package to SciPy, its build script (
setup.py
) must meet certain requirements. The most important requirement is that the package define aconfiguration(parent_package='',top_path=None)
function which returns a dictionary suitable for passing tonumpy.distutils.core.setup(..)
. To simplify the construction of this dictionary,numpy.distutils.misc_util
provides theConfiguration
class, described below.SciPy pure Python package example
Below is an example of a minimal
setup.py
file for a pure SciPy package#!/usr/bin/env python def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('mypackage',parent_package,top_path) return config if __name__ == "__main__": from numpy.distutils.core import setup #setup(**configuration(top_path='').todict()) setup(configuration=configuration)
Upvotes: 1