5
所以我正在做setuptool包。Setuptools。如何使包中包含額外的數據文件夾和所有文件夾
要在包中包含額外的數據文件,我需要在setup()
內指定data_file
參數。
代碼示例:在本例中
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']),
.........
]
您可以使用'[(root,glob.glob(root /**/*.*,recursive = True)]' – warownia1
@ warownia1:no,因爲這不會創建'(directorypath,list_of_files_in_directory)'元組*每個目錄*。 –