是否可以使用dist utils(setup.py)作为包数据的一部分包含子目录? [英] Is it possible to include subdirectories using dist utils (setup.py) as part of package data?
问题描述
基本上我的python软件包的设置如下:
Basically my python package is setup like:
module
\_examples
\_folder1
\_file1.py
\_file2.py
\_folder2
\_file1.py
\_file2.py
基本上我只想使用:
package_data = {
'module': ['examples/*'],
},
因为我的项目中总是有人在添加示例,所以我希望可以轻松地从我的应用程序中列出示例。我可以使它适用于示例中的任何FILE,但不能通过子目录向下递归。
because my project always has people adding examples and I want it to be easy to list them from within my application. I can get it work for any FILE within examples, but not re-curse down through sub-directories. Is this possible?
推荐答案
我相信您正在寻找的东西就是这样的 setup .py
,它将以递归方式找到项目中的任何程序包,并且还要确保将 __ init __。py
文件包括在所需每个程序包的子目录中。
I believe what you're looking for is something like this for you setup.py
, which will recursively find any packages in the project, also be sure and include __init__.py
files to subdirectories for each package you want.
from setuptools import setup, find_packages
setup(name='MySoftware',
packages=find_packages()
)
这篇关于是否可以使用dist utils(setup.py)作为包数据的一部分包含子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!