是否有解释这个问题的文档或网页,或者像教程一样的东西?
一般来说,你不需要任何额外的设置脚本来构建分发。SciPy需要额外的设置脚本主要是为了减少子包特定样板配置代码的数量。SciPy子包中的设置脚本主要用于在构建整个分发时进行配置准备 - 构建和打包仍然是从根设置脚本完成的。如NumPy Distutils - 用户指南所述:
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)