如何在setup.py中正确定义package_data?

时间:2012-11-08 11:28:30

标签: python packaging setup.py

我有这个项目:

.
├── django_mysetup
│   ├── __init__.py
│   ├── template-basket
│   │   └── apple
│   │       ├── app_template
│   │       │   ├── forms.py
│   │       │   ├── __init__.py
│   │       │   ├── models.py
│   │       │   ├── tests.py
│   │       │   └── views.py
│   │       └── project_template
│   │           ├── manage.py
│   │           └── project_name
│   │               ├── __init__.py
│   │               ├── settings.py
│   │               ├── urls.py
│   │               └── wsgi.py
│   └── templates
│       ├── example_direct.html
│       ├── example.html
│       └── stylesheets
│           ├── base.css
│           ├── layout.css
│           └── skeleton.css
├── MANIFEST.in
├── README.rst
└── setup.py

这是 setup.py 文件:

from distutils.core import setup

setup(
    name='Django_mysetup',
    py_modules=['django_mysetup'],
    entry_points={
    'console_scripts': ['django_mysetup = django_mysetup:main', ],},
    description='A Personalised Django startproject and startapp setup script.',
    long_description=open('README.rst').read(),
    packages=['django_mysetup'],
    package_data={'django_mysetup': ['templates/*', 'templates/stylesheets/*',
      'template-basket/apple/app_template/*', 
      'template-basket/apple/project_template/*', 
      'template-basket/apple/project_template/project_name/*',
      'template-basket/apple/project_template/manage.py'
      ]}
)

这是 MANIFEST.in 文件(MANIFEST代模板)

include README.rst
recursive-include template-basket *
recursive-include templates *

当我将python setup.py sdistpip install文件发送到我的virtualenv时,我明白了:

*.tar.gz

问题出在error: can't copy 'Django-mysetup/templates/stylesheets': doesn't exist or not a regular file

如何调整我的package_data脚本,以便在我的虚拟环境中安装setup.pytemplate-basket目录及其所有内容? (最好是我不需要在这些目录中写下每个文件,只是顶部的dir名称。)

0 个答案:

没有答案