4
여러 개의 .pyx 파일을 실행 패키지 (.DLL)로 변환하기 위해 Cython을 사용하고 싶습니다.Cython과 distutils
distutils를 통해 여러 .pyx에서 단일 Windows DLL을 만드는 방법은 무엇입니까? 사용
샘플 :
sub1.pyx :
cimport sub1
class A():
def test(self, val):
print "A", val
sub1.pxd :
cdef class A:
cpdef test(self,val)
sub2.pyx :
cimport sub2
class B():
def test(self):
return 5
sub2.pxd :
cdef class B:
cpdef test(self)
초기화 평 :
cimport sub1
cimport sub2
import sub1
import sub2
setup.py :
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("sub", ["__init__.pyx", "sub1.pyx", "sub2.pyx"])]
setup(
name = 'Hello world app',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules
)
오류 :
sub1.obj : error LNK2005: ___pyx_module_is_main_sub already defined in __init__.obj
sub1.obj : error LNK2005: _initsub already defined in __init__.obj
sub2.obj : error LNK2005: ___pyx_module_is_main_sub already defined in __init__.obj
sub2.obj : error LNK2005: _initsub already defined in __init__.obj
Creating library build\temp.win32-2.7\Release\sub.lib and object build\temp.win32-2.7\Release\sub.exp
C:\temp\ctest\sub\sub.pyd : fatal error LNK1169: one or more multiply defined symbols found
은 당신이 정말로 자신의 문제를 해결하는 다양한 방법을 제공하고 있습니다 사용 후
AND, OR : 은 아마도 당신은 두 줄 아래로는 "SRC/myModule.pyx"파일을 추가 할 수 있습니다 이미 준 응답을 편집 하시겠습니까? 편집중인 경우이 게시물을 정리하고 보관하려는 답변 아래의 "편집"링크를 사용하십시오. –
문제는 Opera 11.62에서 SO가 올바르게 작동하지 않는다는 것입니다. 게시물 편집에서 줄 바꾸기를 사용하려면 캐리지 리턴 키를 사용할 수 없습니다. –
그러나 이것은 모든 pyx 파일을 하나의 모듈로 처리 할 것입니다 (즉, 모든 심볼을 하나의 네임 스페이스에 넣으십시오)? –