使用setup.cfg在Python软件包中包含数据文件夹
我有以下SETUP.CFG文件,我想发布到PYPI的通常项目,应该使用数据文件夹运输,在我的情况下,RU_CORE_NEWS_SM-3.1.0。 (我正在使用setUptools):
[metadata]
name = test-project-name
version = 0.6.0
[options]
packages = find:
python_requires = >=3.6
include_package_data = True
install_requires =
spacy==3.1.3
beautifulsoup4
[options.package_data]
test_project_name/ru_core_news_sm-3.1.0 = *.*
这是我的目录结构
base_project_name/
├── test_project_name
│ ├── __init__.py
│ ├── a.py
│ └── ru_core_news_sm-3.1.0
├── pyproject.toml
├── MANIFEST.in
└── setup.cfg
中有一个:
recursive-include test_project_name/ru_core_news_sm-3.1.0 *.*
我正在通过执行pip install path/to/base_project_name
来测试安装
,我在清单 数据文件夹中的所有文件,但只有一些文件,我不知道为什么。
这些是基本文件夹中的文件:
这就是我使用pip到其他位置(两个项目都使用VENV)的“测试”时剩下的:
?
I have the following setup.cfg file, a usual project I want to publish to pypi and which should be shipped with a data folder, in my case ru_core_news_sm-3.1.0. (I am using setuptools):
[metadata]
name = test-project-name
version = 0.6.0
[options]
packages = find:
python_requires = >=3.6
include_package_data = True
install_requires =
spacy==3.1.3
beautifulsoup4
[options.package_data]
test_project_name/ru_core_news_sm-3.1.0 = *.*
This is my directory structure
base_project_name/
├── test_project_name
│ ├── __init__.py
│ ├── a.py
│ └── ru_core_news_sm-3.1.0
├── pyproject.toml
├── MANIFEST.in
└── setup.cfg
and I have this in my MANIFEST.in:
recursive-include test_project_name/ru_core_news_sm-3.1.0 *.*
I am testing the install by executing pip install path/to/base_project_name
However, this does not get me all files in the data folder, but only some of them, and I don't know why.
These are the files in the base folder:
and this is what remains when I have "test installed" it using pip to some other location (both projects use venv):
What could be the reason?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从 Setuptools 62.3.0 开始,您现在可以使用递归通配符(
“ **”
),将(sub)目录递归。这样,您可以在其中包含包含所有文件夹和文件的整个文件夹。例如,当使用
pyproject.toml
文件时,这就是您递归包含两个文件夹的方式:但是您也只能在文件夹和所有子文件夹中包含某些文件类型。如果要包含所有markdown(
.md
)文件,例如:使用
setup.py.py
或setup.cfg
时,它也应起作用。参见细节。
Starting with Setuptools 62.3.0, you can now use recursive wildcards (
"**"
) to include a (sub)directory recursively. This way you can include whole folders with all their folders and files in it.For example, when using a
pyproject.toml
file, this is how you include two folders recursively:But you can also only include certain file-types, in a folder and all subfolders. If you want to include all markdown (
.md
) files for example:It should also work when using
setup.py
orsetup.cfg
.See https://github.com/pypa/setuptools/pull/3309 for the details.
我发现问题:您不应使用
*。*
包括所有文件,而是简单地*
。因为有时文件没有结尾,然后将被忽略。取决于文件(subest.in):或(setup.cfg)
I found the problem: You should not use
*.*
to include all files, but instead simply*
. Because sometimes files don't have an ending, which will then get ignored. Depending on the file (MANIFEST.in):or (setup.cfg)