Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including static data in setup.py (setuptools)

I am currently coding setup.py using setuptools. And I want to copy the static data (which is not a Python module) to site-packages.

The thing is, the current folder hierarchy is structured like the following:

setup.py
src
    Pure Python Module
skeleton
    example
        __init__.py
    resources
        static
            error.css
            example.css
            logo_shadow.png
        template
            error.html
            example.html
    server.tmplt

I want to copy the skeleton directory to site-packages WHILE maintaining the folder structure/hierarchy, but how should I do this?

like image 816
cumul Avatar asked Jun 26 '12 08:06

cumul


1 Answers

I solved the problem by processing the static files separately, not using setuptools.

from sys import argv
try:
    if argv[1] == 'install':
        from os.path import join
        from distutils.sysconfig import get_python_lib
        from shutil import copytree
        OrigSkeleton = join('src', 'skeleton')
        DestSkeleton = join(get_python_lib(), 'cumulus', 'skeleton')
        copytree(OrigSkeleton, DestSkeleton)

except IndexError: pass
like image 116
cumul Avatar answered Oct 20 '22 05:10

cumul