Python distutils, как получить компилятор, который будет используемым?

Запустите дерево зависимостей mvn, и вы сможете увидеть дерево зависимостей вашего проекта. Затем попытайтесь выяснить, какие пакеты этой зависимости и удаляют ненужные вам.

27
задан kynan 18 December 2012 в 00:20
поделиться

3 ответа

импорт distutils.ccompiler

compiler_name = distutils.ccompiler.get_default_compiler ()

0
ответ дан attwad 28 November 2019 в 05:31
поделиться

You can subclass the distutils.command.build_ext.build_ext command.

Once build_ext.finalize_options() method has been called, the compiler type is stored in self.compiler.compiler_type as a string (the same as the one passed to the build_ext's --compiler option, e.g. 'mingw32', 'gcc', etc...).

7
ответ дан 28 November 2019 в 05:31
поделиться
#This should work pretty good
def compilerName():
  import re
  import distutils.ccompiler
  comp = distutils.ccompiler.get_default_compiler()
  getnext = False

  for a in sys.argv[2:]:
    if getnext:
      comp = a
      getnext = False
      continue
    #separated by space
    if a == '--compiler'  or  re.search('^-[a-z]*c$', a):
      getnext = True
      continue
    #without space
    m = re.search('^--compiler=(.+)', a)
    if m == None:
      m = re.search('^-[a-z]*c(.+)', a)
    if m:
      comp = m.group(1)

  return comp


print "Using compiler " + '"' + compilerName() + '"'
2
ответ дан 28 November 2019 в 05:31
поделиться
Другие вопросы по тегам:

Похожие вопросы: