Create dynamic library (.so file) from Python code
16,774
This should help.
Also you can do both ways i.e. extend python by writing library in C and call it from Python code OR code functions in C that could be called from Python.
The standard term used (conceptually and help googling is "Python bindings"
Official reference from python docs
General reference - Integrating python with other languages
Author by
Mauren
Experienced software engineer, with a strong background in Java development.
Updated on June 15, 2022Comments
-
Mauren almost 2 years
Suppose I have a library written in Python that I'd like to call from a C software. Is there any way I can compile this Python code to a .so file?
-
user13107 almost 6 yearsCould you answer a related question stackoverflow.com/questions/50459248/…
-
fkl almost 6 yearssure - getting page not found for the link??
-
ilias iliadis over 4 yearsThe question is very-very clear. I am not sure why this shows up as an answer at all. The first (assumed as the main) link starts with «There are several ways to call code written in C from Python» which is the exact opposite of the, included in the question, «I'd like to call from a C software». The rest is about «doing it both ways»!? (probably for some other question).
-
fkl over 4 yearsWhether one needs to call python to c or c to python, the requirement is to understand how "python bindings work" which is the first reference and which is why it latter talks about doing it either way. The next link "Official reference .." is indeed "Calling Python functions from C". Hope that helps