Cython外部库

时间:2016-01-30 00:50:07

标签: python wrapper cython

所以我试图包含steam api库,我无法弄清楚如何在setup.py中执行此操作。

目前我有:

from distutils.core import setup    
from distutils.extension import Extension    
from Cython.Build import cythonize    
from Cython.Distutils import build_ext


extensions = cythonize([
    Extension("test", ["test.pyx"],
              library = ['steam_api'])
    ])


setup(
  name = 'Teste',
  cmdclass = {'build_ext': build_ext},
  packages=[],
  ext_modules = extensions
)

显然不起作用,因为我在构建时得到了这个:

steamtypes.h:107:15: error: variably modified 'Salt_t' at file scope


typedef uint8 Salt_t[ k_cubSaltSize ];
               ^
steamtypes.h:123:1: error: initializer element is not constant
 const GID_t k_TxnIDNil = k_GIDNil;

等等...

Test.pyx:

from libcpp cimport bool

cdef extern from "steam_api_flat_test.h":
bool SteamAPI_ISteamUser_BLoggedOn(ssize_t instancePtr);

1 个答案:

答案 0 :(得分:2)

错误喜欢

steamclientpublic.h:465:1: error: unknown type name 'class'
 class CSteamID

表示需要C ++编译器,可以在 setup.py 中指定

Extension("test", ["test.pyx"],
          language="c++",
          library = ['steam_api'])
    ])