Skip to content

Instantly share code, notes, and snippets.

@clbarnes
Created March 10, 2016 16:54
Show Gist options
  • Save clbarnes/1fcb02fe8578a55d487d to your computer and use it in GitHub Desktop.
Save clbarnes/1fcb02fe8578a55d487d to your computer and use it in GitHub Desktop.
Incorporating non-python files (config, data etc.) when installing your python library with setuptools
"""
And here's the easiest way to get that file in modules installed in this way.
"""
import os
import sys
DATAFILE_PATH = os.path.abspath('path_to_something')
"""
setuptools doesn't like non-python files and won't install them. Developers sometimes do, and often put them in the correct place where required. This is how to get an example such file, './data/my.data' to be included when you run setup.py.
"""
from setuptools import setup
setup(
...
data_files=[
(
'data', # the directory in which you want to install the data file, relative to the installation prefix
['data/my.data'] # the location of the files to install, relative to setup.py
)
],
...
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment