cython

Cython binary package compile issues

家住魔仙堡 提交于 2021-02-11 18:24:46
问题 I would like to compile a python3 package into a distributable binary form (without sourcecode) from within the x64 Native Tools Command Prompt for VS 2019 using python 3.6 (64bit). However, i have problems specifying the correct paths to the files the package should contain. The produced folder structure in the site-packages directory is all wrong and not what i expect from my source folder structure and my setup.py . It seems for me that the modules from the top level package are treated

Cython binary package compile issues

[亡魂溺海] 提交于 2021-02-11 18:24:13
问题 I would like to compile a python3 package into a distributable binary form (without sourcecode) from within the x64 Native Tools Command Prompt for VS 2019 using python 3.6 (64bit). However, i have problems specifying the correct paths to the files the package should contain. The produced folder structure in the site-packages directory is all wrong and not what i expect from my source folder structure and my setup.py . It seems for me that the modules from the top level package are treated

I got ModuleNotFoundError: No module named 'Cython' when trying to make Extension

白昼怎懂夜的黑 提交于 2021-02-11 16:55:12
问题 I'm trying to run this code : from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext ext_modules = [ Extension("sum", ["a123.pyx"])] setup( name = 'app', cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules ) and I got this Error : Traceback (most recent call last): File "compile.py", line 3, in <module> from Cython.Distutils import build_ext ImportError: No module named 'Cython' I'm using Conda and I add cython to it also I

I got ModuleNotFoundError: No module named 'Cython' when trying to make Extension

北城以北 提交于 2021-02-11 16:55:08
问题 I'm trying to run this code : from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext ext_modules = [ Extension("sum", ["a123.pyx"])] setup( name = 'app', cmdclass = {'build_ext': build_ext}, ext_modules = ext_modules ) and I got this Error : Traceback (most recent call last): File "compile.py", line 3, in <module> from Cython.Distutils import build_ext ImportError: No module named 'Cython' I'm using Conda and I add cython to it also I

Joblib Parallel + Cython hanging forever

只愿长相守 提交于 2021-02-10 15:44:12
问题 I have a very weird problem while creating a Python extension with Cython that uses joblib.Parallel . The following code works as expected: from joblib import Parallel, delayed from math import sqrt print(Parallel(n_jobs=4)(delayed(sqrt)(x) for x in range(4))) The following code hangs forever: from joblib import Parallel, delayed def mult(x): return x*3 print(Parallel(n_jobs=4)(delayed(mult)(x) for x in range(4))) I have no clues why. I use the following setup.py : from distutils.core import

Joblib Parallel + Cython hanging forever

好久不见. 提交于 2021-02-10 15:41:32
问题 I have a very weird problem while creating a Python extension with Cython that uses joblib.Parallel . The following code works as expected: from joblib import Parallel, delayed from math import sqrt print(Parallel(n_jobs=4)(delayed(sqrt)(x) for x in range(4))) The following code hangs forever: from joblib import Parallel, delayed def mult(x): return x*3 print(Parallel(n_jobs=4)(delayed(mult)(x) for x in range(4))) I have no clues why. I use the following setup.py : from distutils.core import

Cython wrapping a class that uses another library

十年热恋 提交于 2021-02-10 14:57:18
问题 I've got some C++ code dbscan.cpp and dbscan.h that work great standalone. Now I'm trying to wrap it in Cython. I'm not sure how to do this correctly, and I'm impeded by limited knowledge about compilers and linkers and libraries and makefiles. Here's PyDBSCAN_lib.pyx : # distutils: language = c++ # distutils: sources = dbscan.cpp from libcpp.vector cimport vector from libcpp.string cimport string from libcpp cimport bool cdef extern from "dbscan.h": cdef cppclass DBSCAN: #DBSCAN(int minPts,

Cython wrapping a class that uses another library

偶尔善良 提交于 2021-02-10 14:57:05
问题 I've got some C++ code dbscan.cpp and dbscan.h that work great standalone. Now I'm trying to wrap it in Cython. I'm not sure how to do this correctly, and I'm impeded by limited knowledge about compilers and linkers and libraries and makefiles. Here's PyDBSCAN_lib.pyx : # distutils: language = c++ # distutils: sources = dbscan.cpp from libcpp.vector cimport vector from libcpp.string cimport string from libcpp cimport bool cdef extern from "dbscan.h": cdef cppclass DBSCAN: #DBSCAN(int minPts,

Cython: prange is repeating not parallelizing

…衆ロ難τιáo~ 提交于 2021-02-10 04:13:35
问题 I have the following simple Cython function for a parallel reduction: # cython: boundscheck = False # cython: initializedcheck = False # cython: wraparound = False # cython: cdivision = True # cython: language_level = 3 from cython.parallel import parallel, prange cpdef double simple_reduction(int n, int num_threads): cdef int i cdef int sum = 0 for i in prange(n, nogil=True, num_threads=num_threads): sum += 1 return sum Which horrifyingly returns the following: In [3]: simple_reduction(n=10,

Cython: prange is repeating not parallelizing

守給你的承諾、 提交于 2021-02-10 04:07:36
问题 I have the following simple Cython function for a parallel reduction: # cython: boundscheck = False # cython: initializedcheck = False # cython: wraparound = False # cython: cdivision = True # cython: language_level = 3 from cython.parallel import parallel, prange cpdef double simple_reduction(int n, int num_threads): cdef int i cdef int sum = 0 for i in prange(n, nogil=True, num_threads=num_threads): sum += 1 return sum Which horrifyingly returns the following: In [3]: simple_reduction(n=10,