简体   繁体   中英

Cython external library

So I'm trying to include steam api library and I can't figure out how to do that in setup.py.

Currently I have:

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
)

Obviously isn't working because I get this when building:

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;

Etc...

Test.pyx:

from libcpp cimport bool

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

Errors likes

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

indicate that C++ compiler is needed, which can be specified in setup.py

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM