'Unable to build libraries using cython?

I am trying to build a python code for numerical applications, and has written a cython segment for a particular bottleneck section of the code. However, when I try to build the extension, it return the following error

error: could not create 'plank/routines/overlap.cpython-38-x86_64-linux-gnu.so': No such file or directory

The setup.py file looks like this

from setuptools import setup, find_packages
from setuptools.extension import Extension
from Cython.Build import cythonize
import numpy 
import os 

os.environ["CPPFLAGS"]  =   os.getenv("CPPFLAGS", "") + "-I" + numpy.get_include()

routines    =   [Extension('plank.routines.overlap',['./overlap.pyx'])]

setup(
        name                =   'plank',
        version             =   '1.0.0',
        packages            =   find_packages(),
        license             =   'BSD-3',
        python_requires     =   ">=3.4",
        install_requires    =   ['cython', 'numpy', 'scipy'],
        ext_modules         =   cythonize(routines, compiler_directives  = {'linetrace': True, 'language_level':'3'}),
        include_dirs        =   [numpy.get_include()]        
        )

The overlap.pyx file looks like this

import cython   as  cython
import numpy    as  np
cimport numpy   as  np 
from scipy.special  import comb as comb
from scipy.special  import factorial2 as fact2
from libc.math      cimport exp, pow

@cython.cdivision(True)
@cython.boundscheck(False)
@cython.wraparound(False)
cdef double overlapgtos(double center1, double exponent1, int shell1, \
                        double center2, double exponent2, int shell2, \
                        double gcenter):
    cdef double overlap    =   0.0
    cdef int counter1, counter2
    cdef double ss  =   0.0
    for counter1 in range(0,shell1+1):
        for counter2 in range(0,shell2+1):
            if ((counter1+counter2)%2 == 0):
                ss  =   comb(shell1,counter1,exact=True)   
                ss  *=  comb(shell2,counter2,exact=True)
                ss  *=  fact2(counter1+counter2-1)
                ss  /=  pow(2.0*(exponent1+exponent2),0.5*(counter1+counter2))
                ss  *=  pow(gcenter-center1,shell1-counter1)
                ss  *=  pow(gcenter-center2,shell2-counter2)
                overlap +=  ss

    return overlap

Am I missing something? I can confirm that the cython code works fine in the native python form. This led me to guess that the error is probably from the setup.py section. Any advices is much appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source