.../ ├──setup.py └──my_module └──data ├──a.dat ├──b.dat ├──...
.../ ├──site-packages └──my_module └──data ├──a.dat ├──b.dat ├──...
setup.py
import sys
import site
import glob
import os.path
from distutils.core import setup
# site-Get the path of the package directory
#* At the top of the list"C:\Python34"Seems to contain, so the last is site-Process it assuming that it is a package (Please let me know if there is a good way because it seems not certain)
sitedir = site.getsitepackages()[-1]
#Installation directory
installdir = os.path.join(sitedir, 'my_module')
#Get the root directory of the module you are installing from
# ※setup.Get with relative path from py
mydir = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), 'my_module')
#Get a list of data files
datafiles = glob.glob(os.path.join(mydir, 'data', '*.dat'))
setup(
...,
packages=['my_module'],
#Pass the installation directory and a list of files to install as tuples
data_files=[(os.path.join(installdir, 'data'), datafiles)]
)
Tutorial on Packaging and Distributing Projects — Python Packaging User Guide documentation python - setup.py not installing data files - Stack Overflow
Recommended Posts