title: Importing cython function: AttributeError: 'module' object has no attribute 'fun'
body: <p>I have written a small <code>cython</code> code that is</p>
  
  <pre><code>#t3.pyx
  from libc.stdlib cimport atoi
  
  cdef int fun(char *s):
          return atoi(s)
  </code></pre>
  
  <p>the <code>setup.py</code> file is</p>
  
  <pre><code>from distutils.core import setup
  from Cython.Build import cythonize
  
  setup(ext_modules=cythonize("t3.pyx"))
  </code></pre>
  
  <p>I run <code>setup.py</code> using this command</p>
  
  <pre><code>python setup.py build_ext --inplace
  </code></pre>
  
  <p>This gives me </p>
  
  <pre><code>Compiling t3.pyx because it changed.
  Cythonizing t3.pyx
  running build_ext
  building 't3' extension
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-     prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-  strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c    t3.c -o build/temp.linux-x86_64-2.7/t3.o
  t3.c:556:12: warning: ‘__pyx_f_2t3_fun’ defined but not used [-Wunused-function]
   static int __pyx_f_2t3_fun(char *__pyx_v_s) {
          ^
  x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/t3.o -o /home/debesh/Documents/cython/t3/t3.so
  </code></pre>
  
  <p>When I run in the <code>python</code> interpreter it shows me</p>
  
  <pre><code>&gt;&gt;&gt; import t3
  &gt;&gt;&gt; t3.fun('1234')
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  AttributeError: 'module' object has no attribute 'fun'
  &gt;&gt;&gt; 
  </code></pre>