我正在编写一个Python包,其中包含一些Cython代码。我用virtualenv。我写的时候,它编译得很好
$ source activate
$ python setup.py build_ext --inplace
但是,当我尝试安装这个软件包时,它开始消耗内存,直到我的计算机挂起(或者我之前终止了进程)。更具体地说,当我尝试:
^{pr2}$我认为下面的[https://github.com/docker/docker/issues/10025][1]可能是问题的根源。基本上,在上面提到的问题中,它说了以下几点
I can replicate this issue. The above resolution does not suggest that changing Python versions fixed anything. It's the writing of files by setuptools that's causing it, though I don't know why. Sometimes it hangs for me when writing dependency_links.txt and sometimes SOURCES.txt. Will see if I can investigate further.
...
Haha, ok, the issue is that you're calling setup.py from / and distutils does a listdir('.') from the calling directory, so I assume it's walking the entire filesystem. So I guess, don't do that. https://github.com/python/cpython/blob/master/Lib/distutils/filelist.py#L245
我知道发生了什么事,但我不知道怎么解决这个问题。在
可能有用的进一步信息。在setup.py
的内容下面
from setuptools import setup
from Cython.Build import cythonize
setup( name = 'ColoredHRG' ,
version = '0.1' ,
description = 'my package.' ,
url = 'BLA BLA' ,
author = 'BLA BLA' ,
author_email = 'BLA BLA' ,
license = 'GPL3' ,
packages = [ 'ColoredHRG' ] ,
ext_modules = cythonize( [ "ColoredHRG/ColoredHRG.pyx" ,
"ColoredHRG/Pool.pyx" ,
"ColoredHRG/MC.pyx" ,
"ColoredHRG/EXAMPLE_traveling_salesman.pyx" ,
"ColoredHRG/MC_ColoredHRG.pyx" ] ,
language = 'c++' ) ,
zip_safe = False )
编辑:修正错误的句子。在
编辑:添加了标志cython
我终于找到问题了。包的文件夹结构如下
另外,在文件夹
^{pr2}$examples
中,有一个软链接(我在Linux中)指向位于该位置的文件夹也就是说,软连接是
结果是,不知何故,这会导致distutils进入一个无限递归循环,吃掉我计算机的整个内存,然后挂起。在
我删除了软链接,现在一切正常。在
编辑:更正了打字错误。在
相关问题 更多 >
编程相关推荐