Created
March 10, 2016 16:54
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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