Python 打包include non-py file
程序员文章站
2024-03-20 20:56:58
...
Python打包的时候默认是将.py文件全部打包
但是有时候我们需要把non-py文件打包,比如说json文件
有个机制可以让我们做到:
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
推荐阅读
-
Python 打包include non-py file
-
python setup.py install 报错fatal error: Python.h: No such file or directory include Python.h
-
fatal error: Python.h: No such file or directory #include “Python.h“
-
mysql-python 安装错误: Cannot open include file: 'config-win.h': No such file or directory
-
mysql-python 安装错误: Cannot open include file: 'config-win.h': No such file or directory