我有一个具有这种结构的项目:
SomeProject/
bin/
CHANGES.txt
docs/
LICENSE.txt
MANIFEST.in
README.txt
setup.py
someproject/
__init__.py
location.py
utils.py
static/
javascript/
somescript.js
“setup.py”如下:
#!/usr/bin/env python
import someproject
from os.path import exists
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup, find_packages
setup(
name='django-some-project',
version=someproject.__version__,
maintainer='Some maintainer',
maintainer_email='some@manteiner.com',
packages=find_packages(),
include_package_data=True,
scripts=[],
url='https://github.com/xxx/some-project',
license='LICENSE',
description='Some project description.',
long_description=open('README.markdown').read() if exists("README.markdown") else "",
install_requires=[
"Django >= 1.4.0"
],
)
然后,当我使用以下命令上传它时:
python setup.py sdist upload
似乎没问题,但是包中没有“静态”文件夹和“javascript”子文件夹。我的“setup.py”的灵感来自于具有类似结构的github.com/maraujop/django-crispy-forms。有关上传此子文件夹有什么问题的提示吗?
答案 0 :(得分:4)
您应该能够通过编辑MANIFEST.in
文件将这些文件添加到源分发中,以添加如下行:
recursive-include someproject/static *.js
或只是:
include someproject/static/javascript/*.js
这足以让文件包含在源代码发行版中。如果您使用的setuptools include_package_data
选项不足以安装文件,您可以要求在setup.py
中明确安装这些文件:
package_data={'someproject': ['static/javascript/*.js']},
答案 1 :(得分:3)
使用以下
packages = ['.','templates','static','docs'],
package_data={'templates':['*'],'static':['*'],'docs':['*'],},