https://github.com/metacall/embedding-python-example
An example of embedding Python into C/C++ using MetaCall.
https://github.com/metacall/embedding-python-example
c cmake cpp embedding python
Last synced: 2 months ago
JSON representation
An example of embedding Python into C/C++ using MetaCall.
- Host: GitHub
- URL: https://github.com/metacall/embedding-python-example
- Owner: metacall
- License: apache-2.0
- Created: 2020-04-16T09:41:06.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-02-21T07:42:19.000Z (over 1 year ago)
- Last Synced: 2025-12-28T19:03:11.338Z (6 months ago)
- Topics: c, cmake, cpp, embedding, python
- Language: C
- Homepage: https://metacall.io
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MetaCall Embedding Python Example
This example shows how to embed Python into C/C++ source code. The instructions are focused on Linux but it can be ported to other platforms easily.
## Dependencies
For building this example you need Python 3 to be installed in the system (including the dev dependencies). For debian based distros:
```bash
sudo apt-get install -y --no-install-recommends python3 python3-dev
```
## Build
Build the project, MetaCall dependency may require root permissions in order to be installed in the system.
```bash
git clone https://github.com/metacall/embedding-python-example.git
mkdir embedding-python-example/build && cd embedding-python-example/build
cmake ..
cmake --build . --target install
```
## Run
From project root directory, run the following commands:
```bash
export LOADER_LIBRARY_PATH="/usr/local/lib"
export LOADER_SCRIPT_PATH="`pwd`"
embedding_python_example
```
## Docker
Building and running with Docker:
```bash
docker build --build-arg DISABLE_CACHE=`date +%s` -t metacall/embedding_python_example .
docker run --rm -it metacall/embedding_python_example
```