我希望能够在我的 setup.py 中添加一个钩子,它将在安装后运行(在 easy_install'ing 或 python setup.py 安装时)。
在我的项目PySmell中,我有一些 Vim 和 Emacs 的支持文件。当用户以通常的方式安装 PySmell 时,这些文件会被复制到实际的 egg 中,用户必须将它们取出并将它们放在他的 .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 = 'orestis@orestis.gr',
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',
]
)
编辑:
这是一个演示的存根python setup.py 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},
...
easy_install 路线还没有运气。