Skip to content

supertigim/EmbeddingPython3inCppwithCMake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Embedding Python3 in C++ with CMake

This project includes several examples of how to embed Python in C++ with CMake. Please be sure that this project was only built and tested on MacOS.

Environments

  • MacOS 12.0.1
  • Miniconda 4.12.0
  • CMake 3.22.3

How to build

Miniconda or Anaconda is required.

(base)% conda create -n ep python=3  
(base)% conda activate ep  
(ep)% pip install numpy  
# before installing gcc, Xcode was already installed which was not sure to affect compilation of the source code. 
(ep)% brew install git cmake gcc

(ep)% git clone https://github.com/supertigim/EmbeddingPython3inCppwithCMake.git
(ep)% cd EmbeddingPython3inCppwithCMake

(ep)% sh ./build_all.sh
# python related logs when running cmake 
Python_FOUND:TRUE
Python_VERSION:3.10.4
Python_Development_FOUND:TRUE
Python_LIBRARIES:/usr/local/Caskroom/miniconda/base/envs/ep/lib/libpython3.10.dylib
Python_INCLUDE_DIRS:/usr/local/Caskroom/miniconda/base/envs/ep/include/python3.10

Then, go to ./build directory and run embedding-python-ex1 ~ 8

Reference

License

MIT

About

Embedding Python3 in your C++ application

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published