Including a data folder in a python package using setup.cfg

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:

Including a data folder in a python package using setup.cfg

and this is what remains when I have “test installed” it using pip to some other location (both projects use venv):

Including a data folder in a python package using setup.cfg

What could be the reason?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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):

recursive-include project_name/ru_core_news_sm-3.1.0 *

or (setup.cfg)

test_project_name/ru_core_news_sm-3.1.0 = *


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x