Me gustaría poder agregar un gancho a mi setup.py que se ejecutará después de la instalación (ya sea al instalar easy_installing o al instalar python setup.py).¿Cómo puedo agregar scripts posteriores a la instalación en easy_install/setuptools/distutils?
En mi proyecto, PySmell, tengo algunos archivos de soporte para Vim y Emacs. Cuando un usuario instala PySmell de la manera habitual, estos archivos se copian en el huevo real, y el usuario debe pescarlos y colocarlos en sus directorios .vim o .emacs. Lo que quiero es preguntar al usuario, después de la instalación, dónde le gustaría que se copiaran estos archivos, o incluso solo un mensaje que imprima la ubicación de los archivos y qué debería hacer con ellos.
¿Cuál es la mejor manera de hacerlo?
Gracias
Mi setup.py se ve así:
#!/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 = 'o[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',
]
)
EDIT:
Aquí hay un trozo que demuestra la 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},
...
No hubo suerte con el easy_install ruta aún.
Acabo de enterarme de que la invocación 'setuptools.install.install: run()' explícitamente no resuelve el argumento de instalación 'install_requires' y parece que funciona de manera diferente cuando haces eso – astronaut
@astronaut use 'do_egg_install', como se describe aquí: http://stackoverflow.com/questions/21915469/python-setuptools-install-requires-is-ignored-when-overriding-cmdclass –