Boost python on mac os x lion with custom python

I am trying to get python boost to work with python custom library. I have a python source and build boost.python using:

./bootstrap.sh --with-python-root=../Python-2.7.2 --with-libraries=python

then ./b2

but when I try to use boost.python in my application, I get

Fatal Python error: Interpreter not initialized (version mismatch?)

When I call PyRun_SimpleString("import sys\nprint sys.version");, I get 2.7.2 as I expect (and the python version I build boost.python, not the system version.)

Is there something I am missing?

When I check in which libraries dylib is linked, I get the following:

libboost_python.dylib (compatibility version 0.0.0, current version 0.0.0)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.1)
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 52.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)`

In my target Xcode program, I include python from the arguments folder -with-python-root and the contents of boost / stage / lib,

Link libraries

+5
source share
3

boost python python, Mac-, , , .

...

$ /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Python 2.7.2 (default, Nov 17 2011, 00:52:26)    
$ sudo ./bootstrap.sh --with-libraries=python --with-python-root=/opt/local/Library/Frameworks/Python.framework/Versions/2.7
$ ./b2
$ cd /Users/YourName/Downloads/boost_1_48_0/libs/python/example/tutorial
$ ../../../../bjam 
...patience...
...patience...
...found 1577 targets...
...updating 12 targets...
common.mkdir bin
common.mkdir bin/darwin-4.2.1
common.mkdir bin/darwin-4.2.1/debug
darwin.compile.c++ bin/darwin-4.2.1/debug/hello.o
darwin.link.dll bin/darwin-4.2.1/debug/hello_ext.so
common.copy libboost_python.dylib
common.copy hello_ext.so
common.mkdir bin/hello.test
common.mkdir bin/hello.test/darwin-4.2.1
common.mkdir bin/hello.test/darwin-4.2.1/debug
capture-output bin/hello.test/darwin-4.2.1/debug/hello
**passed** bin/hello.test/darwin-4.2.1/debug/hello.test
...updated 12 targets...
$ ls
Jamroot         hello.cpp       hello_ext.so
bin         hello.py        libboost_python.dylib
$ python
Python 2.7.2 (default, Nov 17 2011, 00:52:26) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import hello_ext
>>> hello_ext.greet()
'hello, world'
>>> 

, , mac-, . , boost.python , 1.47 1.48.

$ port info boost
boost @1.47.0, Revision 2 (devel)
Variants:             debug, no_single, no_static, openmpi, python24, python25, python26, python27, python31, python32, regex_match_extra,
                      universal

Description:          Boost provides free portable peer-reviewed C++ libraries. The emphasis is on portable libraries which work well with
                      the C++ Standard Library.
Homepage:             http://www.boost.org

Library Dependencies: zlib, expat, bzip2, icu
Platforms:            darwin
License:              Boost-1.0
Maintainers:          adfernandes@macports.org

, , , :).

$echo $press-TAB

+3

, boost python python (2.7.0), python (2.7.2) - PyRun_SimpleString python, API Python .

project-config.jam ( boost build), , python boost-python, ( 2.7):

using python : 2.7 : /Library/Frameworks/Python.framework/Versions/2.7/ ;
+1

dylib . - --debug-configuration bjam include link:

./b2 -q --prefix=your_install_dir YOU_OTHER_OPTIONS --debug-configuration install

:

notice: [python-cfg] Configuring python...
notice: [python-cfg]   user-specified version: "2.7"
notice: [python-cfg]   user-specified cmd-or-prefix: "/Library/Frameworks/Python.framework/Versions/2.7"
notice: [python-cfg] Checking interpreter command "/Library/Frameworks/Python.framework/Versions/2.7/bin/python"...
notice: [python-cfg] running command '/Library/Frameworks/Python.framework/Versions/2.7/bin/python -c "from sys import *; print('version=%d.%d\nplatform=%s\nprefix=%s\nexec_prefix=%s\nexecutable=%s' % (version_info[0],version_info[1],platform,prefix,exec_prefix,executable))" 2>&1'
notice: [python-cfg] ...requested configuration matched!
notice: [python-cfg] Details of this Python configuration:
notice: [python-cfg]   interpreter command: "/Library/Frameworks/Python.framework/Versions/2.7/bin/python"
notice: [python-cfg]   include path: "/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7"
notice: [python-cfg]   library path: "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config" "/Library/Frameworks/Python.framework/Versions/2.7/lib"
notice: [python-cfg] framework directory is "/Library/Frameworks/Python.framework"

, , include (interpreter command, include path library path ).

, python-config usr/bin: python.org. , , .

, , , ​​ /usr/lib. ls -al /usr/lib/*python* /usr/lib/libpython2.7.dylib, python.org. , python.org , .

, . 1 , , , ...

0

All Articles