Cython 外部库
Cython external library
所以我正在尝试包含 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);
错误点赞
steamclientpublic.h:465:1: error: unknown type name 'class'
class CSteamID
表示需要C++编译器,可以在setup.py
中指定
Extension("test", ["test.pyx"],
language="c++",
library = ['steam_api'])
])
所以我正在尝试包含 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);
错误点赞
steamclientpublic.h:465:1: error: unknown type name 'class'
class CSteamID
表示需要C++编译器,可以在setup.py
中指定Extension("test", ["test.pyx"],
language="c++",
library = ['steam_api'])
])