Python:如何在使用 setup.py install (distutil) 时强制覆盖文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19133831/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python: How to force overwriting of files when using setup.py install (distutil)
提问by Jürgen Fuchsberger
I am using distutil
to install my python code using
我正在使用distutil
安装我的python代码
python setup.py install
python setup.py install
I run into problems when I want to install an older branch of my code over a new one:
setup.py install
won't overwrite older files. A work around is touching (touch <filename>
) all files so they are forced to be newer than those installed, but this is pretty ugly.
当我想将代码的旧分支安装到新分支上时遇到问题:
setup.py install
不会覆盖旧文件。一种解决方法是接触 ( touch <filename>
) 所有文件,因此它们被迫比安装的文件更新,但这非常难看。
What I am looking for is an option to force overwriting of all files, eg. something like
我正在寻找的是强制覆盖所有文件的选项,例如。就像是
python setup.py --force install
python setup.py --force install
Any Ideas?
有任何想法吗?
Thanks, Juergen
谢谢,尤尔根
采纳答案by Aaron Curtis
The Python developers had the same idea, they just put the option after the command:
Python 开发者也有同样的想法,他们只是在命令后面加上选项:
python setup.py install --force
The distutils documentation doesn't mention the --force option specifically, but you can find it by using the --help option:
distutils 文档没有特别提到 --force 选项,但您可以使用 --help 选项找到它:
python setup.py --help install
回答by u8830193
go to the setup.py directory,and I simply use
转到 setup.py 目录,我只是使用
pip install .
,it works for me
,这个对我有用