我有一个这种结构的项目:
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.有关上传此子文件夹有什么问题的提示吗?
解决方法:
您应该能够通过编辑MANIFEST.in文件将这些文件添加到源分发中,以添加如下行:
recursive-include someproject/static *.js
要不就:
include someproject/static/javascript/*.js
这足以将文件包含在源代码发行版中.如果你使用的setuptools include_package_data选项不足以安装文件,你可以要求在setup.py中明确安装这些文件:
package_data={'someproject': ['static/javascript/*.js']},