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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 12:57:40  来源:igfitidea点击:

Python: How to force overwriting of files when using setup.py install (distutil)

pythoninstalldistutilsoverwrite

提问by Jürgen Fuchsberger

I am using distutilto 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 installwon'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

,这个对我有用