简体   繁体   English

为什么`setup.py install`不更新脚本文件?

[英]Why `setup.py install` does not update the script file?

In the setup.py file, I write like this: setup.py文件中,我这样写:

from distutils.core import setup
setup(
    # skip a lot of information here..
    scripts = ["chilin2/ChiLin2.py"],
)

I've setup my package successfully at first time. 我第一次成功安装了我的包裹。 After a while I update the line 209 of the script into this: 一段时间后,我将脚本的line 209更新为:

$ sed -n 209p chilin2/ChiLin2.py
        macs2_on_merged.param["control_opt"] = "-c " + macs2_on_merged.input["control"]

And then run setup.py again 然后再次运行setup.py

$ sudo python3 setup.py install
running install
running build
running build_py
running build_scripts
running install_lib
running install_scripts
changing mode of /usr/local/bin/ChiLin2.py to 755
running install_egg_info
Removing /usr/local/lib/python3.2/site-packages/chilin2-0.1-py3.2.egg-info
Writing /usr/local/lib/python3.2/site-packages/chilin2-0.1-py3.2.egg-info

However, I found that the script file hasn't been changed.. 但是,我发现脚本文件没有更改。

$ sed -n 209p /usr/local/bin/ChiLin2.py
        macs2_on_merged["control_opt"] = "-c " + macs2_on_merged.input["control"]

I tried setup.py clean and then setup.py install again, but that doesn't solve the problem. 我试过setup.py clean ,然后再次setup.py install ,但这不能解决问题。 Does anyone have ideas about this? 有人对此有想法吗?

( I found that the Chilin2.py in the package has an elder time stamp than that in system directory. Is that the reason that setup.py install doesn't update? Is there a way to solve this? ) (我发现软件包中的Chilin2.py的时间戳比系统目录中的时间戳Chilin2.py 。这是setup.py install未更新的原因吗?有没有解决的方法?)

try to uninstall this package and then reinstall it. 尝试卸载此软件包,然后重新安装。

pip can uninstall a package : pip可以卸载软件包:

pip uninstall *packagename*

I found that the Chilin2.py in the package has an elder time stamp than that in system directory. 我发现软件包中的Chilin2.py的时间戳比系统目录中的时间戳更早。

This is strange. 这很奇怪。 Can you reproduce the bug with these steps: 您可以通过以下步骤重现该错误:

  1. Create script. 创建脚本。
  2. setup.py install (with an --install or --user option to avoid sudo) setup.py install(带有--install或--user选项,以避免sudo)
  3. Edit script. 编辑脚本。
  4. setup.py install setup.py安装
  5. ?

If you did that (ie you edited the script after its first installation), I don't understand how the latest script can have a modification time that is older than the installed script. 如果您这样做了(即您在首次安装脚本后对其进行了编辑),那么我将无法理解最新脚本的修改时间比已安装的脚本要早。

Is that the reason that setup.py install doesn't update? 那是setup.py安装没有更新的原因吗?

Definitely: distutils compares file modification times to see if it needs to re-build (for scripts, the build phase consists of copying the files to a temp build dir and adjusting the shebangs). 绝对:distutils比较文件修改时间以查看是否需要重新构建(对于脚本,构建阶段包括将文件复制到临时构建目录并调整shebang)。

Is there a way to solve this? 有办法解决吗?

$ touch chilin2/ChiLin2.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM