39

I am using distutil to install my python code using

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.

What I am looking for is an option to force overwriting of all files, eg. something like

python setup.py --force install

Any Ideas?

Alexis Wilke
  • 15,168
  • 8
  • 60
  • 116

2 Answers2

52

The Python developers had the same idea, they just put the option after the command:

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:

python setup.py --help install
Alexis Wilke
  • 15,168
  • 8
  • 60
  • 116
Aaron Curtis
  • 536
  • 6
  • 3
  • 1
    Note, the --force overwrites, and does not remove files. I find I depend on pip uninstall when I need to switch versions. Otherwise, you do not know what is lurking. If pip is not an option, then I think you have to manually remove /bin/ and /lib/python/site-packages/. Again, pip is your friend. – zerocog Aug 21 '17 at 18:51
0

Go to the setup.py directory and I simply use:

 pip install .

It works for me.

Alexis Wilke
  • 15,168
  • 8
  • 60
  • 116
陳子軼
  • 117
  • 5
  • It also works for me. It properly overwrites my files, even `install --force` didn't do that for some reason. setup.py seems to be properly executed and all my files are copied to where they should go. – sezanzeb Nov 29 '20 at 14:00
  • 2
    https://stackoverflow.com/a/15731459/4417769 "So basically, use pip. It only offers improvements" – sezanzeb Nov 29 '20 at 14:58