[swift-dev] Bridging Python Packages to Swift

Jose Cheyo Jimenez cheyo at masters3d.com
Sat Jul 2 16:41:22 CDT 2016


Hi Muhammad,

I am not an expert either but here is what I would do if I were you. 

Go look at xamarin/ mono open source project to see how they bind objc and Java libraries to c#. Once you understand that then you would need a version of python (cpython or another typed Python version) that you are able to expose to swift (probably using llvm). I believe there are a bunch of projects that expose libraries like .net, c++ to python but I am not familiar with projects going the other way around. 

Another way could be to figure out a way to expose the python script to c. (Python to c source to source translation possibly ). Swift is able to import c code but it is not pretty; you would have to build a nice wrapper around it using swift. 

Needless to say, I think that is a lot of work that people just won't do. If I needed a python library in swift, I would just rewrite it in swift. 

There are probably other ways. Good luck.   

> On Jul 2, 2016, at 12:17 PM, Muhammad Tahir Vali via swift-dev <swift-dev at swift.org> wrote:
> 
> Hey everyone,
> 
> I lack the experience the rest of the people in this list probably have being an undergraduate student but I would love to participate in this language because I see its potential.
> 
> With that being said, one of the biggest advantages python has is its immersive number of packages that is appealing to anyone that writes scripts. Swift is evolving into a scripting language as well but it lacks the libraries python has. 
> 
> I suppose its worth bridging python packages with swift until Swift is grown up to take over the world :D
> 
> Can anyone help me figure out how thats done ?  
> 
> -- 
> Best Regards,
> 
> Muhammad T. Vali
> _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160702/0680685f/attachment.html>


More information about the swift-dev mailing list