Simple examples for how to call C code from Python, and vice versa.
In order to build the extensions for your system, you may need to install additional tools.
-
RedHat variants
$ sudo yum install python python-devel
-
Debian variants
$ sudo apt-get install python python-dev
-
SUSE variants
$ sudo zypper install python python-devel
(In progress)
(In progress)
Make sure you have the prerequisites installed, and run the following:
$ python setup.py build_ext --inplace && python setup.py clean
This will produce a hello.so
binary. Simply add that to your PYTHONPATH and
you can try it out:
$ python
>>> import hello
>>> hello.hello()
Hello, World!
>>> hello.hello("Your Name")
Hello, Your Name!
>>>
Blogs, documentation, and other sources that helped explain how this all works.