Python distutils,如何获取将要使用的编译器?

问题描述 投票:28回答:6

例如,我可以使用python setup.py build --compiler=msvcpython setup.py build --compiler=mingw32或仅使用python setup.py build,在这种情况下,将使用默认编译器(例如bcpp)。如何在setup.py中获取编译器名称(例如分别为msvcmingw32bcpp)?

UPD .:我不需要默认的编译器,我需要将要使用的[[actually]],但不一定是默认的编译器。到目前为止,我没有找到比解析sys.argv来查看是否存在--compiler...字符串更好的方法。

例如,我可以使用python setup.py build --compiler = msvc或python setup.py build --compiler = mingw32或仅使用python setup.py build,在这种情况下,默认编译器(例如bcpp)将是用过的。如何...
python compiler-construction installation distutils
6个回答
29
投票

7
投票

2
投票
import distutils.ccompiler

0
投票

0
投票
class BuildWithDLLs(build):

    # On Windows, we install the git2.dll too.
    def _get_dlls(self):
        # return a list of of (FQ-in-name, relative-out-name) tuples.
        ret = []
        bld_ext = self.distribution.get_command_obj('build_ext')
        compiler_type = bld_ext.compiler.compiler_type

0
投票
© www.soinside.com 2019 - 2024. All rights reserved.