I apologise in advance if this is an old topic. I'm new to Cython and am probably overlooking something basic, but I haven't been able to find help elsewhere.
I have a short Python module I wish to Cythonise:
# Define Jumble
def Jumble(TestList[], SequenceX):
TLen = len(TestList)
J = 0
for I in range(TLen):
J = (J + int(SequenceX[I:I+6])) % TLen
TestList[I], TestList[J] = TestList[J], TestList[I]
return TestList
# Define De-Jumble
def DeJumble(TestList, SequenceX):
TLen = len(TestList)
J = 0
for I in range(TLen):
J = (J + int(SequenceX[I:I+6])) % TLen
for I in reversed(range(TLen)):
TestList[I], TestList[J] = TestList[J], TestList[I]
J = (J - int(SequenceX[I:I+6])) % TLen
return TestList
(TestList is a list of integers and SequenceX is a text string of numbers.)
I create a basic
setup.py file:
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("JumDe.pyx")
)
and run
python3 setup.py build_ext --inplace from Terminal. It produces a .so file (albeit with a lot of warning messages) and I can successfully import it and use it in my main program, with a noticeable speed increase.
When I rename the module with a
.pyx suffix, change the setup file and run it again, up comes this error message:
Traceback (most recent call last):
File "setup.py", line 5, in <module>
ext_modules = cythonize("JumDe.pyx")
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Cython/Build/Dependencies.py", line 754, in cythonize
aliases=aliases)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Cython/Build/Dependencies.py", line 649, in create_extension_list
for file in nonempty(extended_iglob(filepattern), "'%s' doesn't match any files" % filepattern):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Cython/Build/Dependencies.py", line 103, in nonempty
raise ValueError(error_msg)
ValueError: 'JumDe.pyx' doesn't match any files
This happens whether I put C type declarations in the module or not. So what am I overlooking?
Using Python 3.4.3, Cython 0.22.1, Mac OS X 10.10.4