Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I create a dll from a simple python code that could be call in VBA

I know this is a a very large question but I'll try to make it as simple as possible.

Assuming that my example.py only holds the following code:

def xsum(a,b):
    return a+b

How could I encapsulate this into a dll that would be callable without actually having python installed on the end-user computer. My goal is to use it in VBA.

I looked at py2exe that creates a .exe but I can't find a solution for a dll. any help would be appreciated. I use python 3.6

like image 710
Steven G Avatar asked Oct 29 '22 07:10

Steven G


1 Answers

Cython (http:cython.org) produces C code from python sources. This generated can be compiled into a dll and called from VBA

Read the section "Using Cython Declarations from C" in the documentation

http://www.google.com/search?q="Using+Cython+Declarations+from+C"+site:cython.org
like image 183
Conor Avatar answered Nov 15 '22 06:11

Conor