Python打包的時(shí)候默認(rèn)是將.py文件全部打包
但是有時(shí)候我們需要把non-py文件打包,比如說json文件
有個(gè)機(jī)制可以讓我們做到:
The mechanism that provides this is the MANIFEST.in file. This is relatively quite simple: MANIFEST.in is really just a list of relative file paths specifying files or globs to include.:
include README.rst
include docs/*.txt
include funniest/data.json
為了讓上面的能夠work,我們需要在setup.py里面講include_package_data=True添加上
In order for these files to be copied at install time to the package’s folder inside site-packages, you’ll need to supply include_package_data=True to the setup() function.
參考:http://python-packaging.readthedocs.io/en/latest/non-code-files.html