Giter VIP home page Giter VIP logo

setuptools-golang-examples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

pombredanne

setuptools-golang-examples's Issues

Not sure how to orchestrate a more complex extension using external Go repo

I have a more complex extension I'm trying to write that has a fair amount of Python code and a Python C extension that wraps a library written in Go. The Python code and the Python C extension are in one repo, and the Go code is outside of that. I'm trying to figure out if it's possible to somehow merge the C extension code (c and h files) with the code from the Go library into one directory before building.

It's kind of an odd thing to do, but the purpose of the code in the Go repo is to build a c-shared library that can be used on its own. I'm just wrapping that C API in a Python module.

Example using CFFI instead of <Python.h>

I have created an example that uses setuptools-golang for compilation of the Go module, but then uses cffi to create the interface to Python.

This means that things like

// #include <Python.h>
// int PyArg_ParseTuple_ll(PyObject*, long*, long*);

are not required anymore. The only glue-code function on the Go-side is one that casts/wraps C arrays to Go slices and the actual function is using Go-native types.

The rest of the gluecode is written in Python and the cffi module compilation is written in Python, too.

Known issue: As of Go 1.6, passing C pointers to and from Go is more strict, producing panics in ArrayToSlice. Since I don't understand how that could be fixed the code currently needs to be run with GODEBUG=cgocheck=0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.