所以我正在制作 setuptool 包。
要在包中包含额外的数据文件,我需要在data_file
里面指定参数setup()
。
代码示例:
datadir = os.path.join('share','data')
datafiles = [(datadir, [f for f in glob.glob(os.path.join(datadir, '*'))])]
import metainfo # a file with relevant information
setup(
name = 'yourpackage',
version = metainfo.version,
maintainer = metainfo.maintainer,
maintainer_email = metainfo.maintainer_email,
author = metainfo.authors,
author_email = metainfo.authors,
description = metainfo.description,
keywords = metainfo.keywords,
long_description = metainfo.long_description,
# package installation
packages = find_packages('src'),
package_dir = package_dir,
data_files = datafiles,
}
datafile
本例中的变量将包含这样的数据
[('share/data', ['share/data/addon.xml.tmplt', 'share/data/default.py.tmplt'])]
但是,我的示例不会递归地列出文件夹和包含文件。
我需要作为参数 folder_path 并返回元组列表的函数:
[
('share/data', ['share/data/addon.xml.tmplt', 'share/data/default.py.tmplt']),
('share/data/inside', ['share/data/inside/file.iside', 'share/data/inside/file2.inside']),
.........
]