How to get error log of a disutils setup in Python

2020-06-16 01:57发布

I am new to Python. I have created some C/C++ extensions for Python and able to build those with the help of Python disutils setup script. But, I have to integrate this setup script to an existing build system. So, I wrote another script to call this setup script using run_setup() method.

distributionObj = run_setup("setup.py",["build_ext"])

Now, I want if any error occurs during the building of extension (Compiler, Linker or anything), I must be able to get the information along with the error string from the caller script to notify the build process.

Please provide me some suggestion.

4条回答
三岁会撩人
2楼-- · 2020-06-16 02:31

Passing the -v parameter to python setup.py build to increase verbosity usually works to get more detailed errors.

查看更多
ら.Afraid
3楼-- · 2020-06-16 02:40

The verbose option is not additive, it converts to a boolean. Thus no matter how many times you invoke the verbose option it will always be 1 and 1 always sets the level to INFO, which is the default anyway.

查看更多
爷的心禁止访问
4楼-- · 2020-06-16 02:42

distutils1 (first version) uses too a internal version of logging (a bit hardcoded, it is not using the standard logging module). I think that it is possible to set the verbosity level coding something like:

import distutils.log
distutils.log.set_verbosity(-1) # Disable logging in disutils
distutils.log.set_verbosity(distutils.log.DEBUG) # Set DEBUG level

All distutils's logging levels available:

DEBUG = 1
INFO = 2
WARN = 3
ERROR = 4
FATAL = 5

You can see the source code of the class "Log" of distutils for reference. Usually for Python 2.7 in /usr/lib/python2.7/distutils/log.py

查看更多
We Are One
5楼-- · 2020-06-16 02:50

Setting DISTUTILS_DEBUG=1 in the environment will cause debug logging.

查看更多
登录 后发表回答