Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

In the setup.py file, I write like this:

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:

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

And then run setup.py again

$ 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. 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? )

like image 938
Hanfei Sun Avatar asked Mar 25 '13 13:03

Hanfei Sun


People also ask

Does pip install use setup py?

@joeforker, pip uses setup.py behind the scenes.

How do I upgrade setup py?

Step 1: Install the latest or current version of Python3 in Windows. Step 2: Now check if pip and python are correctly installed in your system using the following commands. Step 3: Upgrade pip to the latest version to avoid errors during installation.

How python setup py install?

Installing Python Packages with Setup.py To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.

Should I use requirements TXT or setup py?

The short answer is that requirements. txt is for listing package requirements only. setup.py on the other hand is more like an installation script. If you don't plan on installing the python code, typically you would only need requirements.


2 Answers

try to uninstall this package and then reinstall it.

pip can uninstall a package :

pip uninstall *packagename*
like image 198
ornoone Avatar answered Oct 14 '22 17:10

ornoone


I found that the Chilin2.py in the package has an elder time stamp than that in system directory.

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)
  3. Edit script.
  4. setup.py install
  5. ?

If you did that (i.e. 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?

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).

Is there a way to solve this?

$ touch chilin2/ChiLin2.py
like image 43
merwok Avatar answered Oct 14 '22 15:10

merwok