Python 自定义模块安装不会复制静态文件

Python custom module installalation won't copy static files

嗨,我正在开发一个 python 模块,当我使用 python setup.py sdist bdist_egg 创建安装包时,所有文件都包含在 zip 文件中,但是当我 运行 python setup.py install 除了静态文件外,所有文件都被复制。 完整项目正在进行中:

https://github.com/efirvida/python-gearbox

我的setup.py

from setuptools import setup, find_packages
version = '0.1.0a'
setup(
    name='python-gearbox',
    version=version,
    author='Eduardo M. Firvida Donestevez',
    packages=find_packages(),
    include_data_package=True,
    author_email='efirvida@gmail.com',
    description='Python library for gear transmission design',
    requires=['numpy', 'scipy'],
    url='https://github.com/efirvida/python-gearbox',
    download_url='https://github.com/efirvida/python-gearbox/archive/master.zip',
    keywords=['gearbox', 'gear', 'agma', 'iso', 'gear transmission', 'engineering'],
    platforms='any',
    license='MIT',
    zip_safe=False,
    classifiers=['Intended Audience :: Developers',
             'Intended Audience :: Manufacturing',
             'Intended Audience :: Science/Research',
             'Natural Language :: English',
             'Programming Language :: Python',
             'Programming Language :: Python :: 2.7',
             'Topic :: Scientific/Engineering',
             'Topic :: Scientific/Engineering :: Human Machine Interfaces',
             'Topic :: Software Development',
             'Topic :: Software Development :: Libraries',
             'Topic :: Software Development :: Libraries :: Application Frameworks'
             ]
)

我想我明白了。在您的 setup.py 更改中

 include_data_package=True,

进入:

 include_package_data=True

如果您在执行 python setup.py install 时查看日志,您会发现线索:

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: 
UserWarning: Unknown distribution option: 'include_data_package'

此外,我还对MANIFEST.in做了一些修改,使其更清晰:

include Makefile CHANGES LICENSE AUTHORS README 
recursive-include gearbox/doc/source *.rst
recursive-include gearbox/export/templates *
recursive-exclude gearbox *.pyc