2017-09-08 9 views
0

나는 내 프로젝트 FlashText에 대한 setup.py 파일이 있습니다 : 파이썬 - 스핑크스가 설치되지 않은 경우 python-sphinx가 setup.py 파일에서 설치된 경우에만 BuildDoc을 작동시키는 방법은 무엇입니까?

from setuptools import setup, Command 
from sphinx.setup_command import BuildDoc 

setup(
    . 
    . 
    cmdclass={'test': PyTest, 'build_sphinx': BuildDoc}, 
) 

pip install flashtext

이 실패합니다. 누군가가 python-sphinx 다음 또한이 라이브러리를 설치할 수 있어야 설치되어 있지 않은 경우

내가 필요로 무엇
sudo apt-get install python-sphinx 

은 다음과 같습니다

ImportError: No module named sphinx.setup_command


Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-LI0I_O/flashtext/

는 문제가 해결됩니다. 어떻게 처리해야합니까? 예를 py.test에 대한

는 다음과 같이 처리됩니다

import subprocess 


class PyTest(Command): 
    user_options = [] 

    def initialize_options(self): 
     pass 

    def finalize_options(self): 
     pass 

    def run(self): 
     errno = subprocess.call(['py.test']) 
     raise SystemExit(errno) 

PS를 : 전체 코드는 GitHub의 https://github.com/vi3k6i5/flashtext

답변

1
cmdclass={'test': PyTest} 

try: 
    from sphinx.setup_command import BuildDoc 
    cmdclass['build_sphinx'] = BuildDoc 
except ImportError: 
    print('WARNING: sphinx not available, not building docs') 

setup(
    . 
    . 
    cmdclass=cmdclass 
) 
+0

이 굉장 볼 수 있습니다. 나는 이것을 추가하고 업데이트 할 것이다. 감사합니다 :) –

+0

감사. 문제를 해결했습니다. 테스트 및 확인 :) –