Python 用C扩展模块运行tox

Python 用C扩展模块运行tox,python,tox,Python,Tox,我是个毒物检测的新手。我有一个python包,它有一个为python2.7编写的C扩展模块。网络告诉我我需要用“tox-wheel”来处理这个案子。然而,我无法让“tox--wheel”找到我的C源代码。有人能帮我一下吗 我的模块可以使用python setup.py build很好地编译。然而,“tox--wheel”中的gcc抱怨说找不到我的C源代码。缺少什么配置?提前多谢 我的setup.py如下所示: 导入操作系统 delos.link 从setuptools导入设置、扩展,查找\u包

我是个毒物检测的新手。我有一个python包,它有一个为python2.7编写的C扩展模块。网络告诉我我需要用“tox-wheel”来处理这个案子。然而,我无法让“tox--wheel”找到我的C源代码。有人能帮我一下吗

我的模块可以使用python setup.py build很好地编译。然而,“tox--wheel”中的gcc抱怨说找不到我的C源代码。缺少什么配置?提前多谢

我的setup.py如下所示:

导入操作系统
delos.link
从setuptools导入设置、扩展,查找\u包
module1=扩展名(“HelloWorld”,
sources=['HelloWorld.c'],
include_dirs=['/usr/lib64/python2.7/site packages/numpy/core/include/'],
额外的编译参数=['-std=c99','-Wno error=vla'])
安装程序(名称='HelloWorld',
版本='0.1',
description='Hello World',
包_数据={'':['*.h','*.c']},
ext_模块=[module1])
我的tox.ini如下所示:

[tox]
环境清单=
py27
[测试]
车轮=真
basepython=py27:python2.7
副总裁=
皮特斯特
努比
changedir={envdir}
命令=
{envpython}{toxinidir}/runtests.py--mode=full{posargs:}
错误消息如下所示:

py27运行测试前:pythonhasheed='2083224069'
py27运行测试:命令[1]|/home/user/helloworld release/.tox/py27/bin/python/home/user/helloworld release/setup.py bdist\u
运转的车轮
运行构建
运行build_ext
构建“\u HelloWorld\u py”扩展
gcc-pthread-fno严格别名-O2-g-pipe-Wall-Wp,-D_-FORTIFY_SOURCE=2-feexceptions-fstack protector strong--param=ssp buffer size=4-grecord gcc switches-m64-mtune=generic-D_GNU_-SOURCE-fPIC-fwrapv-DNDEBUG-O2-g-pipe-Wall-Wp,-D_FORTIFY_SOURCE=2-feexceptions-fstack protector strong--param=ssp buffer size=4-grecord gcc switches-m64-mtune=generic-D_GNU_SOURCE-fPIC-fwrapv-fPIC-I/usr/lib64/python2.7/site-packages/numpy/core/include/-I/usr/include/python2.7-c HelloWorld.c-c-build/temp.linux-x86_64-2.7/2.7/HelloWorld.o-std=c99-Wno错误
gcc:error:HelloWorld.c:没有这样的文件或目录
gcc:致命错误:没有输入文件
编译终止。
错误:命令“gcc”失败,退出状态为4
错误:命令/home/user/helloworld release/.tox/py27/bin/python/home/user/helloworld release/setup.py bdist_wheel的调用错误(已退出,代码为1)
错误:在dist目录中找不到发行版。请检查setup.py,例如:
python setup.py bdist_wheel

删除
changedir={envdir}
。它将当前目录更改为
.tox/py27
,因此安装脚本中的
hello.c
将解析为不存在的
.tox/py27/hello.c

如果需要更改工作目录,可以在安装脚本中使用绝对路径:

import os
from setuptools import setup, Extension, find_packages


rootdir = os.path.normpath(os.path.join(__file__, os.pardir))
module1 = Extension('_HelloWorld_py',
                    sources = [os.path.join(rootdir, 'HelloWorld.c')],
                    ...)

setup(...)

您直接使用了
python setup.py build
,它(AFAIK)与
python setup.py bdist_wheel
不同,您是否尝试过直接运行它?“python setup.py bdist_wheel”也起作用。按照hoefling的建议删除“changedir={envdir}”解决了我的问题。非常感谢!成功了。对于这样一个非主流的问题,我不希望得到快速的回答。很高兴我能帮上忙!