Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1346 Must include different Python header on Mac as of 10.9

open
nobody
None
5
2014-01-14
2013-10-23
Avi Drissman
No

As of Mac OS X 10.9, #include <Python.h> doesn't work; you need #include <Python Python.h="">.

There are nasty hacks out there (see https://github.com/pmccormick/scout/blob/master/lldb/scripts/Python/edit-swig-python-wrapper-file.py ), but the simplest is to just change pyruntime.swg.

Before:

%insert(runtime) %{
/ Python.h has to appear first /

include <Python.h>

%}

After:

%insert(runtime) %{
/ Python.h has to appear first /

if defined(APPLE)

include <Python Python.h="">

else

include <Python.h>

endif

%}

Related

Bugs: #1346

Discussion

  • Avi Drissman
    Avi Drissman
    2013-10-23

    Gah! Let's try again.

    As of Mac OS X 10.9,

    #include <Python.h>
    

    doesn't work; you need

    #include <Python/Python.h>
    

    There are nasty hacks out there (see https://github.com/pmccormick/scout/blob/master/lldb/scripts/Python/edit-swig-python-wrapper-file.py ), but the simplest is to just change pyruntime.swg.

    Before:

    %insert(runtime) %{
    /* Python.h has to appear first */
    #include <Python.h>
    %}
    

    After:

    %insert(runtime) %{
    /* Python.h has to appear first */
    #if defined(__APPLE__)
    # include <Python/Python.h>
    #else
    # include <Python.h>
    #endif
    %}
    
     
  • William Fulton
    William Fulton
    2014-01-14

    Can you modify that macro to detect the correct version of OSX, otherwise this will break versions prior to 10.9. Does it work with both of the apple compilers (gcc and clang) ?

     
    • Avi Drissman
      Avi Drissman
      2014-01-14

      We made this change for Chrome, and this works on 10.6 through 10.9, no version check required. Chrome only uses Clang, so while I think this will work in GCC I don't know for sure.

      Avi

      On Jan 14, 2014, at 11:56, "William Fulton" wsfulton@users.sf.net wrote:

      Can you modify that macro to detect the correct version of OSX, otherwise this will break versions prior to 10.9. Does it work with both of the apple compilers (gcc and clang) ?

      [bugs:#1346] Must include different Python header on Mac as of 10.9

      Status: open
      Created: Wed Oct 23, 2013 07:05 PM UTC by Avi Drissman
      Last Updated: Wed Oct 23, 2013 07:11 PM UTC
      Owner: nobody

      As of Mac OS X 10.9, #include doesn't work; you need #include Python.h>.

      There are nasty hacks out there (see https://github.com/pmccormick/scout/blob/master/lldb/scripts/Python/edit-swig-python-wrapper-file.py ), but the simplest is to just change pyruntime.swg.

      Before:

      %insert(runtime) %{
      / Python.h has to appear first /

      include

      %}

      After:

      %insert(runtime) %{
      / Python.h has to appear first /

      if defined(APPLE)

      include Python.h>

      else

      include

      endif

      %}

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/swig/bugs/1346/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #1346

      Attachments