Friday, 1 June 2018

Cython attemps to compile twice, and fails

I have a setup.py file that is very similar to the one shown here: https://stackoverflow.com/a/49866324/4080129. It looks like this:

from distutils.core import setup, Extension
from Cython.Build import cythonize
import numpy

sources = ["herdingspikes/detection_localisation/detect.pyx",
           "herdingspikes/detection_localisation/SpkDonline.cpp",
           "herdingspikes/detection_localisation/SpikeHandler.cpp",
           "herdingspikes/detection_localisation/ProcessSpikes.cpp",
           "herdingspikes/detection_localisation/FilterSpikes.cpp",
           "herdingspikes/detection_localisation/LocalizeSpikes.cpp"]

exts = [Extension(name='herdingspikes.detect',
                  sources=sources,
                  extra_compile_args=['-std=c++11', '-O3'],
                  include_dirs=[numpy.get_include()])]

setup(
    ext_modules=cythonize(exts),
    include_dirs=[numpy.get_include()]
)

There's a package with some pure-Python, and a submodule that contains Cython files. The setup.py is in the parent folder, not in the Cython one:

setup.py
herdingspikes/
    some_python.py
    detection_localisation/
        detect.pyx
        SpkDonline.cpp
        ...etc

Now, setup.py correctly compiles all the files module/submodule/file1.cpp etc. and saves the build to build/temp.linux-x86_64-3.6/module/submodule/file1.o . However, just after that, it tries to compile a file called file1.cpp, which doesn't exist (the correct one is module/submodule/file1.cpp, and has already been compiled).

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iherdingspikes/detection_localisation -I/disk/scratch/martino/Clustering/HS2/HS2venv/lib/python3.6/site-packages/numpy/core/include -I/disk/scratch/martino/Clustering/HS2/HS2venv/lib/python3.6/site-packages/numpy/core/include -I/disk/scratch/martino/Clustering/HS2/HS2venv/include -I/disk/scratch/miniconda/envs/my_default/include/python3.6m -c SpkDonline.cpp -o build/temp.linux-x86_64-3.6/SpkDonline.o -std=c++11 -O3
gcc: error: SpkDonline.cpp: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command 'gcc' failed with exit status 4

I'm very confused, this completely prevents my code from compiling...



from Cython attemps to compile twice, and fails

No comments:

Post a Comment