如何在构建的发行版中包含setup.py

时间:2014-07-28 00:11:42

标签: python

我有一个典型的项目结构,如下所示:

EngineEmulator        
    ship
        engine
            emulator
            mapping
            __init__.py
        tests
            emulator
            mapping
            __init__.py           
        setup.py
        MANIFEST.in
        setup.cfg
        README.rst

我的setup.py看起来如下:

from setuptools import setup, find_packages
setup(
   name='Engine',
   version=1.0.0,
   description='Engine Project',      
   packages=find_packages(
   exclude=["*.tests", "*.tests.*", "tests.*", "tests"]),
   install_requires =['pycrypto', 
                      'kombu >=1.1.3'],
   author='Demo',
   author_email='demo@eliza.net'
   license='MIT',
   classifiers=[
    'Topic :: Demo Engine',
    'Development Status:: 3 - Iteration',
    'Programming Language :: Python -2.6'
]

我的setup.cfg如下所示:

[egg_info]
tag_build = .dev
tag_svn_revision = 1

[rotate]
#keep last 15 eggs, clean up order
match = .egg
keep = 15   

我的MANIFEST.in看起来如下:

include README.rst
include setup.py
recursive-include engine *

当我运行python setup.py bdist时,它生成的tar文件不包含setup.py文件。 当我运行pip install时,它会抱怨setup.py丢失了。 但是,当我执行python setup.py sdist时,它会生成具有setup.py的tar文件。 知道为什么吗?

1 个答案:

答案 0 :(得分:3)

Pip does not install Distutils dumb bdist format distributions。更通用的分发格式是sdist格式,通常可以“构建”以便与任何Python实例一起安装。 sdist通常会上传到PyPI,特别是对于纯Python分发,例如不包含需要目标系统上的编译器的C代码。当前版本的pip还可以安装wheels,这是一种智能bdist格式,可以包含纯Python分发或针对特定平台的不纯分发。

相关问题