2008-10-30 3 views
32

설치 후 (easy_install'ing 중이거나 python setup.py를 설치할 때) 실행되는 setup.py에 후크를 추가하고 싶습니다.easy_install/setuptools/distutils에 설치 후 스크립트를 어떻게 추가합니까?

내 프로젝트에서 PySmell, 나는 Vim과 Emacs를위한 몇 가지 지원 파일을 가지고있다. 사용자가 PySmell을 일반적인 방법으로 설치할 때,이 파일들은 실제 달걀에 복사되고, 사용자는 그 파일들을 물고기로 뽑아내어 .vim 또는 .emacs 디렉토리에 넣어야합니다. 내가 원하는 것은 사용자, 설치 후,이 파일을 복사 할 곳을 물어 보는 것, 심지어는 파일의 위치를 ​​출력하는 메시지뿐 아니라 파일로 무엇을해야 하는지를 묻는 것입니다.

가장 좋은 방법은 무엇입니까?

감사

내 setup.py 지금과 같습니다

#!/usr/bin/env python 
# -*- coding: UTF-8 -*- 
from setuptools import setup 

version = __import__('pysmell.pysmell').pysmell.__version__ 

setup(
    name='pysmell', 
    version = version, 
    description = 'An autocompletion library for Python', 
    author = 'Orestis Markou', 
    author_email = '[email protected]', 
    packages = ['pysmell'], 
    entry_points = { 
     'console_scripts': [ 'pysmell = pysmell.pysmell:main' ] 
    }, 
    data_files = [ 
     ('vim', ['pysmell.vim']), 
     ('emacs', ['pysmell.el']), 
    ], 
    include_package_data = True, 
    keywords = 'vim autocomplete', 
    url = 'http://code.google.com/p/pysmell', 
    long_description = 
"""\ 
PySmell is a python IDE completion helper. 

It tries to statically analyze Python source code, without executing it, 
and generates information about a project's structure that IDE tools can 
use. 

The first target is Vim, because that's what I'm using and because its 
completion mechanism is very straightforward, but it's not limited to it. 
""", 
    classifiers = [ 
     'Development Status :: 5 - Production/Stable', 
     'Environment :: Console', 
     'Intended Audience :: Developers', 
     'License :: OSI Approved :: BSD License', 
     'Operating System :: OS Independent', 
     'Programming Language :: Python', 
     'Topic :: Software Development', 
     'Topic :: Utilities', 
     'Topic :: Text Editors', 
    ] 


) 

편집 : easy_install을 함께

from setuptools.command.install import install as _install 

class install(_install): 
    def run(self): 
     _install.run(self) 
     print post_install_message 

setup(
    cmdclass={'install': install}, 
    ... 

없음 운 : 여기

python setup.py install을 보여줍니다없는 스텁입니다 아직 경로.

+2

'setuptools.install.install : run()'을 명시 적으로 호출하면'install_requires' 설정 인수가 해결되지 않고 다른 방법으로 작동하는 것처럼 보입니다. – astronaut

+1

@astronaut use 'do_egg_install', 여기에 설명 된대로 : http://stackoverflow.com/questions/21915469/python-setuptools-install-requires-is-ignored-when-overrid-cmdclass –

답변

7

사용자가 패키지를 설치하는 방법에 따라 다릅니다. 실제로 사용자가 "setup.py install"을 실행하는 경우, 설치 명령 (install_vim)에 다른 하위 명령을 추가하면됩니다. run() 메서드는 원하는 위치에 원하는 파일을 복사합니다. 하위 명령을 install.sub_commands에 추가하고 명령을 setup()에 전달할 수 있습니다.

바이너리에 설치 후 스크립트를 사용하려면 작성중인 바이너리 유형에 따라 다릅니다. 예를 들어 bdist_rpm, bdist_wininst 및 bdist_msi는 기본 패키지 형식이 설치 후 스크립트를 지원하기 때문에 설치 후 스크립트를 지원합니다.

bdist_egg 설계하여 설치 후 메커니즘을 지원하지 않습니다 : A와

http://bugs.python.org/setuptools/issue41

+2

"설치 명령에 다른 하위 명령을 추가하면 (예 : install_vim) "그리고 어떻게 그 일을합니까? –

+0

이것에 대한 어떤 업데이 트? – MavWolverine

+2

답을 보려면 ** 위의 _question_ **의 하단을보십시오. (@ limp-chimp, @ maverick-wolverine) –

0

해결 방법 프로젝트는 압축을 푼 디렉토리로 설치 될 수 있도록, 당신은 false로 zip_ok 옵션을 설정할 수 있습니다 , 사용자가 편집기 설정 파일을 쉽게 찾을 수 있습니다.

distutils2에서는 사용자 정의 디렉토리를 비롯하여 더 많은 디렉토리에 설치하고 후크 설치 전/후크를 수행 할 수 있습니다.

관련 문제