rag*_*lmz 6 python error-logging pip setuptools
我正在使用 setuptools 打包代码,以便可以使用
cd project_name && pip install .
Run Code Online (Sandbox Code Playgroud)
在安装过程中,我想警告用户有关预先存在的配置文件并在系统上打印一些安装后说明。例如
/etc/project_name/project.conf exists. Not copying default config file.
Run Code Online (Sandbox Code Playgroud)
我尝试使用print
,logging.warning()
但在使用 pip 安装时仍然没有出现警告。我有一种感觉,我错过了一些明显的东西。
我们正在尝试在 Redhat 系列上支持 3.0 > python >= 2.6 >= el6 和 Ubuntu >= 14.04LTS
如果您查看 pip 源代码,在负责运行安装脚本的函数中call_subprocess
(此处为源代码),它说:
def call_subprocess(cmd, show_stdout=True, cwd=None, ...
...
# The obvious thing that affects output is the show_stdout=
# kwarg. show_stdout=True means, let the subprocess write directly to our
# stdout. Even though it is nominally the default, it is almost never used
# inside pip (and should not be used in new code without a very good
# reason); as of 2016-02-22 it is only used in a few places inside the VCS
# wrapper code. Ideally we should get rid of it entirely, because it
# creates a lot of complexity here for a rarely used feature.
#
# Most places in pip set show_stdout=False. What this means is:
# - We connect the child stdout to a pipe, which we read.
# - By default, we hide the output but show a spinner -- unless the
# subprocess exits with an error, in which case we show the output.
# - If the --verbose option was passed (= loglevel is DEBUG), then we show
# the output unconditionally. (But in this case we don't want to show
# the output a second time if it turns out that there was an error.)
Run Code Online (Sandbox Code Playgroud)
简而言之,只有在以下情况下您才能看到输出:
-v
详细标志调用 pip 归档时间: |
|
查看次数: |
1526 次 |
最近记录: |