I have a new library that has to include a lot of subfolders of small datafiles, and I\'m trying to add them as package data. Imagine I have my library as so:
If you don't have any problem with getting your setup.py code dirty use distutils.dir_util.copy_tree
.
The whole problem is how to exclude files from it.
Heres some the code:
import os.path
from distutils import dir_util
from distutils import sysconfig
from distutils.core import setup
__packagename__ = 'x'
setup(
name = __packagename__,
packages = [__packagename__],
)
destination_path = sysconfig.get_python_lib()
package_path = os.path.join(destination_path, __packagename__)
dir_util.copy_tree(__packagename__, package_path, update=1, preserve_mode=0)
Some Notes:
setup(...)
but use copy_tree()
to extend the directory you want into the path of installation.