2012-06-26 2 views
8

현재 setuptools를 사용하여 setup.py를 코딩하고 있습니다. 그리고 파이썬 모듈이 아닌 정적 데이터를 사이트 패키지에 복사하려고합니다.setup.py (setuptools)에 정적 데이터 포함

건은 현재 폴더 계층 구조와 같은 구조로되어있는 다음의 폴더 구조/계층을 유지하면서

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 

내가 사이트 패키지 에 골격 디렉토리를 복사 할,하지만 어떻게 내가해야 이 작업을 수행?

답변

2

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 
+0

이미 존재하는 경우 덮어 쓰기 때문에'distutils.dir_util.copy_tree'를 사용하는 것이 좋습니다. http://stackoverflow.com/a/12686557/161801을 참조하십시오. – asmeurer