GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - zpoint/Boost-Python-Examples: Implementation of C++ Boost Python Examples, With python3.5+ support

BranchesTags
Open more actions menu

Latest commit

 

History

26 Commits
26 Commits

Folders and files

NameName
Last commit message
Last commit date
Examples
Examples
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 

Repository files navigation

Boost Python Examples


  • C++ Boost

C++ Boost Python

  • Installation
    • Ubuntu
    • Mac
  • Demo
    • python3 hello_ext example
    • python2 hello_ext example
  • Examples
    • hello_ext

    • class_hello

    • class_member

    • class_property

    • inheritance

    • class_virtual

    • class_virtual_nopure

    • operators

    • special_operators

    • call_policies

    • overloading

    • Object Interface

      • basic_interface
      • derived_object_types
      • extracting_c++_objects
      • enums
      • reference_count
    • embedding

    • iterators

    • exception_translation

Boost Installation with python3 support
  • OS Ubuntu 16.10

  • From source

    • Download the latest version here

    • Description of user-config.jam please refer to here

        tar -xzvf boost_1_65_1.tar.gz
        cd boost_1_65_1
      
        # sudo find / -name "python3.5m" # If you don't know where python3.5m is
        # which python3 # If you don't know your python3 install directory
        echo "using mpi ;
        using gcc :  : g++ ;
        using python : 3.5 : /usr/bin/python3 : /usr/include/python3.5m : /usr/local/lib ;" > ~/user-config.jam
      
        ./bootstrap.sh --with-python=/usr/bin/python3 --with-python-version=3.5 --with-python-root=/usr/local/lib/python3.5 --prefix=/usr/local
        sudo ./b2 install -a --with=all
        sudo ldconfig
      
  • From apt

    sudo apt-get install libboost-all-dev
    # link libboost_python3.so
    sudo find / -name "libboost_python-py35.so"
    # cd to where you find it
    cd /usr/lib/x86_64-linux-gnu/
    sudo ln -s libboost_python-py35.so libboost_python3.so
    
  • OS Mac

      brew install boost-python --with-python3
      # if your python version or lib path is different from mine, please change
      # INCLUDE_PATH and LIBPYTHON_PATH in makefile
    
      # INCLUDE_PATH:
      # shold be the path contains "pyconfig.h", below two command can help you find the path
      # sudo find / -name "pyconfig.h"
      # python3 -c "import sys; print('\n'.join(sys.path))"
    
      # LIBPYTHON_PATH:
      # on mac, with version python3.6, lib name is: libpython3.6.dylib
      # sudo find / -name "libpython3.6"
    
Demo
  • If you install from source, and you change the prefix path when install, you need also change the BOOST_INC and BOOST_LIB in makefile
  • My default python version is python3.5 on Ubuntu, python3.6 on Mac, if you want to use with python 2.7, change "PYTHON_VERSION" in makefile
python3 hello_ext
git clone https://github.com/zpoint/Boost-Python-Examples.git
cd Boost-Python-Examples/Examples/hello_ext
make

python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import hello_ext
>>> hello_ext.greet()
'hello, world'
python2 hello_ext
git clone https://github.com/zpoint/Boost-Python-Examples.git
cd Boost-Python-Examples/Examples/hello_ext
vim makefile # change the first line "PYTHON_VERSION = None" to "PYTHON_VERSION = 2.7"
make

python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import hello_ext
>>> hello_ext.greet()
'hello, world'

About

Implementation of C++ Boost Python Examples, With python3.5+ support

Topics

boostcpp11python

Resources

Readme
Activity

Stars

38 stars

Watchers

1 watching

Forks

13 forks
Report repository

Releases

Packages

Used by

Contributors

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.