8

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?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
cumul
  • 105
  • 8

1 Answers1

2

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
asmeurer
  • 86,894
  • 26
  • 169
  • 240
cumul
  • 105
  • 8
  • It's better to use `distutils.dir_util.copy_tree`, as it overwrites it if it's already there. See http://stackoverflow.com/a/12686557/161801. – asmeurer Jul 05 '13 at 16:44