Python setup.py includes .json files in egg
I want to package .json files as well as a python egg file.
For example: boto package has endpoints.json file. But when I run python setup.py bdist_egg it doesn't include the json file in the egg. How can I include a Json file in an egg?
How do I include a * .json file in an egg?
Below is the setup.py code
from setuptools import setup, find_packages, Extension
setup(
name='X-py-backend',
version='tip',
description='X Python backend tools',
author='meme',
packages=find_packages('python'),
package_dir={'': 'python'},
data_files=[('boto', ['python/boto/endpoints.json'])],
namespace_packages = ['br'],
zip_safe=True,
)
setup(
name='X-py-backend',
version='tip',
packages=find_packages('protobuf/target/python'),
package_dir={'': 'protobuf/target/python'},
namespace_packages = ['br'],
zip_safe=True,
)
source to share
You only need to specify the file in the parameter data_files
. Here's an example.
setup(
name='X-py-backend',
version='tip',
description='XXX Python backend tools',
author='meme',
packages=find_packages('python'),
package_dir={'': 'python'},
data_files=[('boto', ['boto/*.json'])]
namespace_packages = ['br'],
zip_safe=True
)
You can see the details here. https://docs.python.org/2/distutils/setupscript.html#installing-additional-files
Another way to do this is to use files MANIFEST.in
. you need to create a file MANIFEST.in
at the root of your project. Here's an example.
include python/boto/endpoints.json
See more here https://docs.python.org/2/distutils/sourcedist.html#manifest-template
source to share