Skip to content

go-python/setuptools-golang

Repository files navigation

Build Status Coverage Status

setuptools-golang

A setuptools extension for building cpython extensions written in golang.

Requirements

This requires golang >= 1.5. It is currently tested against 1.6 and 1.7.

This requires python >= 2.7. It is currently tested against 2.7, 3.5, 3.6, and pypy.

Usage

Add setuptools-golang to the setup_requires in your setup.py and build_golang={'root': ...}. root refers to the root go import path of your project.

An extension must be a single file in the main go package (though the entire main package will be built into the extension). That package may import other code. You may have multiple extensions in your setup.py.

setup(
    ...
    build_golang={'root': 'github.com/user/project'},
    ext_modules=[Extension('example', ['example.go'])],
    setup_requires=['setuptools-golang'],
    ...
)

Writing cpython extensions in golang

Here's some examples

Common issues

undefined reference to `some_c_function'

Extension by default will bring along the go files listed, but won't bring along the related C files. Add the following to MANIFEST.in:

global-include *.c
global-include *.go

fatal: could not read Username for 'https://github.com':

You're probably trying to import from an external source which does not exist. Double check that your import is correct.

package github.com/a/b/c: /tmp/.../github.com/a/b exists but /tmp/.../github.com/a/b/.git does not - stale checkout?

You've probably mistyped an import. Double check that your import is correct.

About

A setuptools extension for building cpython extensions written in golang.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 58.9%
  • C 20.0%
  • Go 19.5%
  • Makefile 1.6%