summaryrefslogtreecommitdiff
path: root/libs/python/example/tutorial
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-06-25 22:59:01 +0000
committer <>2013-09-27 11:49:28 +0000
commit8c4528713d907ee2cfd3bfcbbad272c749867f84 (patch)
treec09e2ce80f47b90c85cc720f5139089ad9c8cfff /libs/python/example/tutorial
downloadboost-tarball-baserock/morph.tar.gz
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_54_0.tar.bz2.boost_1_54_0baserock/morph
Diffstat (limited to 'libs/python/example/tutorial')
-rw-r--r--libs/python/example/tutorial/Jamroot48
-rw-r--r--libs/python/example/tutorial/hello.cpp20
-rwxr-xr-xlibs/python/example/tutorial/hello.py7
3 files changed, 75 insertions, 0 deletions
diff --git a/libs/python/example/tutorial/Jamroot b/libs/python/example/tutorial/Jamroot
new file mode 100644
index 000000000..1a70cb91a
--- /dev/null
+++ b/libs/python/example/tutorial/Jamroot
@@ -0,0 +1,48 @@
+# Copyright David Abrahams 2006. Distributed under the Boost
+# Software License, Version 1.0. (See accompanying
+# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+import python ;
+
+if ! [ python.configured ]
+{
+ ECHO "notice: no Python configured in user-config.jam" ;
+ ECHO "notice: will use default configuration" ;
+ using python ;
+}
+
+# Specify the path to the Boost project. If you move this project,
+# adjust this path to refer to the Boost root directory.
+use-project boost
+ : ../../../.. ;
+
+# Set up the project-wide requirements that everything uses the
+# boost_python library from the project whose global ID is
+# /boost/python.
+project
+ : requirements <library>/boost/python//boost_python ;
+
+# Declare the three extension modules. You can specify multiple
+# source files after the colon separated by spaces.
+python-extension hello_ext : hello.cpp ;
+
+# Put the extension and Boost.Python DLL in the current directory, so
+# that running script by hand works.
+install convenient_copy
+ : hello_ext
+ : <install-dependencies>on <install-type>SHARED_LIB <install-type>PYTHON_EXTENSION
+ <location>.
+ ;
+
+# A little "rule" (function) to clean up the syntax of declaring tests
+# of these extension modules.
+local rule run-test ( test-name : sources + )
+{
+ import testing ;
+ testing.make-test run-pyd : $(sources) : : $(test-name) ;
+}
+
+# Declare test targets
+run-test hello : hello_ext hello.py ;
+
+
diff --git a/libs/python/example/tutorial/hello.cpp b/libs/python/example/tutorial/hello.cpp
new file mode 100644
index 000000000..d5114312b
--- /dev/null
+++ b/libs/python/example/tutorial/hello.cpp
@@ -0,0 +1,20 @@
+// Copyright Joel de Guzman 2002-2004. Distributed under the Boost
+// Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt
+// or copy at http://www.boost.org/LICENSE_1_0.txt)
+// Hello World Example from the tutorial
+// [Joel de Guzman 10/9/2002]
+
+#include <boost/python/module.hpp>
+#include <boost/python/def.hpp>
+
+char const* greet()
+{
+ return "hello, world";
+}
+
+BOOST_PYTHON_MODULE(hello_ext)
+{
+ using namespace boost::python;
+ def("greet", greet);
+}
+
diff --git a/libs/python/example/tutorial/hello.py b/libs/python/example/tutorial/hello.py
new file mode 100755
index 000000000..d18b1c535
--- /dev/null
+++ b/libs/python/example/tutorial/hello.py
@@ -0,0 +1,7 @@
+# Copyright Joel de Guzman 2002-2007. Distributed under the Boost
+# Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt
+# or copy at http://www.boost.org/LICENSE_1_0.txt)
+# Hello World Example from the tutorial
+
+import hello_ext
+print hello_ext.greet()