8

Environment:

  • Mac OS X 10.8.5
  • Apache 2.2.26
  • Homebrew Python 3.3.3

Problem:

I am trying to install mod_wsgi but first need to determine if Python was configured and compiled with the '--enable-shared' option.

Questions:

  1. How can I determine if Homebrew installed Python with the '--enable-shared' option?
  2. If it was not installed, what is the correct way to install it?

Thank you!

fire_water
  • 1,380
  • 1
  • 19
  • 33
  • 1
    http://stackoverflow.com/questions/10192758/how-to-get-a-list-of-options-that-python-was-compiled-with - This works with python 3. – Ian Laird Apr 21 '14 at 16:36
  • 1
    The ``--enable-shared`` option will not be relevant if Python was installed as a MacOS X style framework. – Graham Dumpleton Apr 21 '14 at 22:46

2 Answers2

11

From the python repl:

import sysconfig
sysconfig.get_config_vars('Py_ENABLE_SHARED')
Ian Laird
  • 442
  • 3
  • 9
  • thanks! 'print(sysconfig.get_config_vars('Py_ENABLE_SHARED'))' returned 'SyntaxError: invalid syntax' but just 'sysconfig.get_config_vars('Py_ENABLE_SHARED')' returned '[0]', which I'm assuming means false / "this feature is not enabled". – fire_water Apr 21 '14 at 18:08
  • Correct, it is a boolean return so, you are correct. The feature is not enabled. I will fix the syntax error. – Ian Laird Apr 21 '14 at 20:26
0

A bit better is to use

import sysconfig
sysconfig.get_config_var('Py_ENABLE_SHARED')

This returns the integer value 0 or 1 directly. The plural form is used to get multiple values or a whole dict if no argument is given, see https://docs.python.org/3/library/sysconfig.html?highlight=get_config_vars#sysconfig.get_config_vars

Christian Tismer
  • 1,305
  • 14
  • 16