43

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?

3 Answers 3

54

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
Sign up to request clarification or add additional context in comments.

2 Comments

Note, the --force overwrites, and does not remove files. I find I depend on pip uninstall <package> 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/<package-programs> and /lib/python/site-packages/<package>. Again, pip is your friend.
The --force option does not appear to be documented nor functional in python3.
5

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

pip install .

It works for me.

2 Comments

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.
stackoverflow.com/a/15731459/4417769 "So basically, use pip. It only offers improvements"
0

In my case, I have to remove the build and dist folders

rm -rf build
rm -rf dist
python3 setup.py install

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.