Reputation: 9469
The task is simple: I have a file with extension other than py
, which needs to be distributed with the package. For the purpose of this example, let's call it .config.json
.
I tried putting it in MANIFEST.in
as include .config.json
- this had no effect.
I tried package_data={'': ['.config.json']}
- this has no effect either.
I also tried data_files=[('', '.config.json')]
- this breaks with unrelated error: error: can't copy '.': doesn't exist or not a regular file
Short of just writing a build command myself, I cannot find anything I could do to make this work. And, yes, I've seen tons of similar questions on SO, on GitHub in bug trackers, etc. I know that both setuptools
and distutils
are essentially hopelessly broken, but maybe there is some sensible way to make this work? I cannot believe that something this simple hadn't been solved yet...
As requested, setup.py
:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
setup(
name='project_name',
version='0.1.0',
description='Project Name in Caps',
author='My Company',
author_email=','.join(
'{}@domain.com'.format(name) for name in
list_of_names
),
url='https://somewhere',
packages=find_packages(),
# package_data={
# '': ['.config.json'],
# },
# data_files=[('', '.config.json')],
install_requires=[
'pytest >= 3.4.2',
...
],
)
Upvotes: 2
Views: 2423
Reputation: 22994
data_files
is what you want, but you need to ensure that the filename is enclosed in a list:
data_files=[('', ['.config.json'])],
That works for me when I run your setup.py
.
Upvotes: 1
Reputation: 94397
In `setup.py:
package_data={'package': ['../.config.json']}
The problem with this approach is that the egg will install .config.json
into site-packages/
which is hardly what you want and certainly not what users expect of packages.
PS. MANIFEST.in
didn't help because it's only for source distribution (python setup.py sdist
).
Upvotes: 1