Reputation: 6020
I would like to create an egg from two directories and want to include .config
and .log
files. The structure of the directories is the following:
MSKDataDownloader
|_______configs
|________sensors.config
MSKSubscriber
|_______doc
|________dependencies.log
Here's my setup.py
file:
from setuptools import setup, find_packages
setup(
name='MSKDataDownloader',
version='1.0.0',
description='Data Downloader',
packages=find_packages(),
include_package_data=True,
package_data={
'MSKDataDownloader': ['config/*.config'],
'MSKSubscriber': ['doc/*.log']
'MSKSubscriber': ['config/*.config']
}
)
What am I doing wrong? Why is it not including the .config
and .log
files in the egg.
Upvotes: 0
Views: 303
Reputation: 365767
The problem is that include_package_data=True
doesn't mean what you think it means (or what most reasonable people would think it means). The short version is, just get rid of it.
From the docs:
If set to
True
, this tellssetuptools
to automatically include any data files it finds inside your package directories that are specified by yourMANIFEST.in
file. For more information, see the section below on Including Data Files.
If you follow the link, you'll see that it in fact makes setuptools
ignore whatever you told it explicitly in package_data
, and instead look for every file mentioned in MANIFEST.in
and find it within your directory tree (or source control tree):
If using the
setuptools
-specificinclude_package_data
argument, files specified bypackage_data
will not be automatically added to the manifest unless they are listed in theMANIFEST.in
file.
And, since you don't have a MANIFEST.in
, this means you end up with nothing.
So, you want to do one of two things:
include_package_data=True
.MANIFEST.in
and remove package_data=…
.This is all complicated by the fact that there are lots of examples and blog posts and tutorials left over from the distribute
days1 that are just plain wrong for modern setuptools
. In fact, there are a whole lot more out-of-date and wrong posts out there than correct ones.
The obvious answer is to just only use the tutorials and examples from the PyPA on pypa.org… but unfortunately, they haven't get written tutorials that cover anywhere near everything that you need.
So, often, you pretty much much have to read old tutorials, then look up everything they tell you in the reference docs to see which parts are wrong.
1. IIRC, in distribute
, the include_package_data=True
would cause your extra files to get added to an sdist, just not to anything else. Which still sounds useless, right? Except that you could make your egg and other distributions depend on building the sdist then running a script that generates the MANIFEST.in
programmatically. Which was useful for… I forget, something to do with pulling version files from source control maybe?
Upvotes: 1