Integrating Python and Threading Building Blocks, Part 2

By Kevin Farnham (108 posts) on January 25, 2008 at 9:08 am

In my last post, I installed the Boost C++ libraries onto my Windows machine, and verified that the installation was successful. Now it's time to get Boost.Python operational, so I can get closer to my objective of creating a Threading Building Blocks application that is run using a Python user interface.

The Boost installer created Python-related subdirectories on my system, but a search for a boost_python.dll file returned no results. So, there was work to do. First I had to install Python itself, since I didn't yet have it on my quad-core Windows system. That was, as expected, straightforward, using the Windows installer that's available on the Python.org home page. The version I installed is Python 2.5.1.

Boost.Python build and test

The "Boost.Python Build and Test HOWTO" provides instructions for getting Boost.Python up and running. First I had to have bjam, the Boost build driver. This is available in the downloads tab of the Boost project on Sourceforge.net. I selected the prebuilt version 3.1.16 for Windows. However, I soon realized that in my original Boost install included bjam.exe, stored in my c:\Program Files\boost\boost_1_34_1\bin directory, so the download from Sourceforge was unneeded.

The next step is to navigate (using my Visual Studio command prompt) into the

libs\python\example\quickstart

directory beneath the main directory where I installed Boost. Once there, I executed this command:

bjam toolset=msvc --verbose-test test

The result was a very long chain of messages telling me that a lot of code was being compiled, the bulk of it related to Python. In many places the message "No errors detected" appeared, and I saw no indication in the output that anything had failed. So, according to Section 3.3 in the Boost.Python HOWTO document ("3.3 In Case Everything Seemed to Work") it was time for me to:

Rejoice! If you're new to Boost.Python, at this point it might be a good idea to ignore build issues for a while and concentrate on learning the library by going through the tutorial and perhaps some of the reference documentation, trying out what you've learned about the API by modifying the quickstart project.

The resulting files

This sounded fine, but first I wanted to take a look at what all those compile operations produced. The only new file in my current working directory (libs\python\example\quickstart) was test_extending.pyc. I launched a UWIN shell and used the Unix file command to see what kind of file this was:

$ file test_extending.pyc
test_extending.pyc:   Compiled Python File

That makes sense! There was also a new bin subdirectory, which contained the following three directories:

msvc8.0
test_embed.test
test_ext.test

The msvc8.0 directory looks like a Visual C++ build directory: it has a debug subdirectory, which has a threading-multi subdirectory, which includes a large set of embedding.* files of various types (including *.obj, *.pdb, *.lib, *.exp, and more).

The test_embed.test and test_ext.test directories each have their own msvc8.0 subdirectory, and each msvc8.0 subdirectory has a debug subdirectory with a threading-multi subdirectory. But in these cases, the threading-multi directories each have just three files. In the case of the test_ext.test directory tree, the three files in threading-multi are:

test_ext
test_ext.output
test_ext.test

These files are identified by the Unix file command as being "dos command script" files, which means we can look at them in a text editor. When you do this, the files certainly don't look like "dos command script" files. test_ext looks like a log file for some of the testing that occurred when I executed the bjam statement to build Boost.Python. test_ext.output is exactly the same as test_ext. test_ext.test is a single line: passed.

Conclusion

At this point, it looks like I've got a working Boost.Python system. Now I just need to learn how to use what I've got to create the Python/TBB application that is the objective of this exercise. With some programming luck, I'll be able to fully explain how to accomplish that in my next post.

Kevin Farnham, O'Reilly Media, TBB Open Source Community, Freenode IRC #tbb, TBB Mailing Lists

Download TBB

Categories: Multicore, Open Source, Threading Building Blocks

Comments (7) Comments RSS Feed

By Ray Zed Blog on January 25th, 2008 at 5:16 pm
links from Technoratiunknown: In my last post, I installed the Boost C++ libraries onto my Windows machine, and verified that the installation was successful. Now it’s time to get Boost.Python operational, so I can get closer to my objective of creating a Threading

By Software - Information about Software on January 25th, 2008 at 5:25 pm
links from TechnoratiAgnitum BLOGwrote an interesting post today on Here’s a quick excerpt In my last post, I installed the Boost C++ libraries onto my Windows machine, and verified that the installation was successful. Now it’s time to get Boost.Python operational, so I can get

By Page is loading, please wait! on January 25th, 2008 at 5:45 pm
links from TechnoratiIntegrating Python and Threading Building Blocks, Part 2 January 25th, 2008 at 11:08am Under UncategorizedAgnitum BLOGwrote an interesting post today on Here’s a quick excerpt In my last post, I installed the Boost C++ libraries onto my Windows machine, and verified that the installation was successful. Now it’s time to get Boost.Python operational, so I can get

By C Programming Language on January 26th, 2008 at 8:14 am
links from TechnoratiIn my last post, I installed the Boost C++ libraries onto my Windows machine, and verified that the installation was successful. Now it’s time to get Boost.Python operational, so I can get closer to my objective of creating a Threading …read more

By Intel® Software Network Blogs » Integrating Python and Threading Building Blocks, Part 3 on January 28th, 2008 at 9:30 am
[...] directory to a new location, and modifying the boost-build.jam and Jamroot files appropriately. See Part 2 of this blog series for [...]

By Блоги Intel® Software Network » Top 5 ISN Blogs в январе on January 29th, 2008 at 1:28 pm
[...] Python, и выбирает Boost.Python как обертку для C++ библиотек. Во второй и третьей частях автор продолжает экспериментировать [...]

By /var/log/leepro on January 30th, 2008 at 6:19 am
links from TechnoratiIntegrating Python and Threading Building Blocks, Part 2Intel TBB(Threading Building Blocks


What do you think?

Name (required)

Email (required; will not be displayed on this page)

Your URL (optional)

Comments (required)