2014-03-25 4 views
1

distutils를 사용하는 python 패키지가 있습니다. 나는 중 하나를 수행 할 setup.py를 구성하고자하는 다음distutils로 이전 패키지 설치 덮어 쓰는 것을 피하는 방법

  • 패키지의 이전에 설치된 버전을 감지하고 진행하기 전에 이전에 설치된 버전을 제거하는 오류를
  • 제공 인상 설치

어떤 힌트가 있습니까? distutils.command.install의 사용자 정의 하위 클래스가 필요할 것이지만 documentation은 약간 간결합니다.

답변

0

좋아, 여기 내 대답이다. 바라건대 다른 누군가가 더 좋은 계획을 가지고 있기를 바랍니다. Install.install_libbase가 올바른 위치인지 또는 내 시스템에서 올바른지 정확히 알지 못합니다.

import distutils.command.install 

class Install(distutils.command.install.install): 
    def run(self): 
     name = self.config_vars['dist_name'] 
     if name in os.listdir(self.install_libbase): 
      raise Exception("It appears another version of %s is already " 
          "installed at %s; remove this before installing." 
          % (name, self.install_libbase)) 
     print("Installing to %s" % self.install_libbase) 
     return distutils.command.install.install.run(self) 

setup(cmdclass={'install': Install}) 
관련 문제