自定义pip安装命令未运行 [英] Custom pip install commands not running

查看:91
本文介绍了自定义pip安装命令未运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为正在编写的pip库运行一些预安装命令.我的安装文件如下:

I'm trying to run some pre-installation commands for a pip library I'm writing. My setup file looks like:

from setuptools import setup                                                        

from setuptools.command.install import install                                      

class CustomInstall(install):                                                       
    def run(self):                                                                  
        install.run(self)                                                           
        print "TEST"                                                           

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

基于调用"pip install"时运行自定义任务

但是,pip安装未打印"TEST".我在这里做错什么了吗?如何获取此setup.py文件以进行实际打印?

However, pip installing is not printing "TEST". Is there something wrong I'm doing here? How can I get this setup.py file to actually print?

更新:以下内容供您参考,确实会引发属性错误:

UPDATE: The following, FYI, does raise an Attribute error:

from setuptools import setup                                                        

from setuptools.command.install import install                                      

class CustomInstall(install):                                                       
    def run(self):                                                                  
        install.run(self)                                                           
        raise AttributeError                                                        

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

推荐答案

我在打印到sys.stdout的自定义安装类中遇到了类似的问题.就我而言,自定义命令实际上是在运行,但似乎输出已被pip过滤.

I've run into a similar issue with a custom install class that prints to sys.stdout. In my case, the custom command is actually run, but it appears that the output is being filtered by pip.

我相信这里会对此进行详细讨论: https://github.com/pypa/pip/issues/2732#issuecomment-97119093

I believe that this is discussed in some detail here: https://github.com/pypa/pip/issues/2732#issuecomment-97119093

这篇关于自定义pip安装命令未运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆