distutils ignores changes to setup.py when building an extension?

时间秒杀一切 提交于 2019-12-22 07:42:36

问题


I have a setup.py file that builds an extension. If I change one of the source files, distutils recognizes this and rebuilds the extension, showing all the compile / link commands.

However, if the only thing I change is setup.py (I'm fiddling trying to make library dependencies work), then it doesn't seem to rebuild (e.g., none of the compile/link commands show up). I've tested this by removing one of the source files in the line

sources = ['foo.c', 'bar.c' ...]

and when I pip install -e . or python setup.py install, it still creates a new file for the extension, but it must be a version cached somewhere, since it shouldn't compile.

How do I clear this cache? I have tried

python setup.py clean --all

or using the --ignore-installed and --no-cache-dir flags when doing pip install -e .

The only way I have found to make it rebuild is if I add garbage in a source file, triggering a rebuild and error, remove the garbage, and pip install -e . again...


回答1:


  1. Just delete under site-packages path any file related to it, you may find sometimes more than one version or some files packaged as zip files or run the following command python setup.py clean --all.
  2. Recompile and install again.

But I will recommend to use python setup.py develop so you don't need to reinstall it with every change, you will be able to frequently edit your code and not have to re-install it again. python setup.py install is used to install typically a ready to use third-party packages.

Check here to better understand python packaging.

Summary:

python setup.py clean --all
python setup.py develop



回答2:


I needed to run

python setup.py clean --all
python setup.py develop

Thanks to DhiaTN for getting me there.



来源:https://stackoverflow.com/questions/34928001/distutils-ignores-changes-to-setup-py-when-building-an-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!