相关疑难解决方法(0)

Cython尝试编译两次,然后失败

我有一个setup.py与此处显示的文件非常相似的文件:https://stackoverflow.com/a/49866324/4080129.它看起来像这样:

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

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

exts = [Extension(name='hs.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()]
)
Run Code Online (Sandbox Code Playgroud)

有一个包含一些纯Python的包,以及一个包含Cython文件的子模块.该setup.py是在父文件夹,而不是在用Cython之一:

setup.py
hs/
    some_python.py
    detection_localisation/
        detect.pyx
        SpkDonline.cpp
        ...etc
Run Code Online (Sandbox Code Playgroud)

现在,setup.py正确编译所有文件module/submodule/file1.cpp等,并将构建保存到build/temp.linux-x86_64-3.6/module/submodule/file1.o.然而,就在此之后,它尝试编译一个名为的文件file1.cpp,该文件不存在(正确的文件module/submodule/file1.cpp已被编译).

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Ihs/detection_localisation -I/disk/scratch/mart/Clustering/HS2/HS2venv/lib/python3.6/site-packages/numpy/core/include -I/disk/scratch/mart/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: …
Run Code Online (Sandbox Code Playgroud)

python compilation cython setup.py

11
推荐指数
1
解决办法
207
查看次数

带有 cython 扩展名的“python setup.py sdist”:.pyx”与任何文件都不匹配

我正在维护一个 python 包,其中包含基于 cython 的 c 扩展。源代码在github上:https: //github.com/vlkit/vlkit

这是我的setup.py

import os
from setuptools import setup, find_packages
from distutils.core import Extension

try:
    import numpy
except ImportError:  # We do not have numpy installed
    os.system("pip install numpy")

try:
    from Cython.Build import cythonize
except ImportError:  # We do not have Cython installed
    os.system("pip install Cython")

import numpy
from Cython.Build import cythonize

__version__ = "0.1.0-b3"

exts = [Extension(name='vltools.nms.nms_ext',
                  sources=["vltools/nms/nms_ext.pyx"],
                  include_dirs=[numpy.get_include()])
        ]

setup(name='vltools',
  version=__version__,
  description='vision and learning tools',
  url='https://github.com/vltools/vltools',
  author_email='a@b.c',
  license='MIT',
  packages=find_packages(), …
Run Code Online (Sandbox Code Playgroud)

python pip setuptools cython

5
推荐指数
1
解决办法
3986
查看次数

标签 统计

cython ×2

python ×2

compilation ×1

pip ×1

setup.py ×1

setuptools ×1