Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 490
Jürgen Fuchsberger Avatar asked Oct 02 '13 09:10

Jürgen Fuchsberger


People also ask

Is setup py outdated?

py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. I found a very detailed write-up explaining this issue: "Why you shouldn't invoke setup.py directly" (October 2021).

What does Install_requires do in setup py?

install_requires is a setuptools setup.py keyword that should be used to specify what a project minimally needs to run correctly. When the project is installed by pip, this is the specification that is used to install its dependencies. Additionally, it's best practice to indicate any known lower or upper bounds.

What is Package_dir in setup py?

package_dir = {'': 'lib'} in your setup script. The keys to this dictionary are package names, and an empty package name stands for the root package. The values are directory names relative to your distribution root.

Does pip install invoke setup py?

For installing packages in “editable” mode (pip install --editable), pip will invoke setup.py develop , which will use setuptools' mechanisms to perform an editable/development installation.


2 Answers

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 
like image 55
Aaron Curtis Avatar answered Sep 21 '22 17:09

Aaron Curtis


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

pip install . 

It works for me.

like image 20
陳子軼 Avatar answered Sep 20 '22 17:09

陳子軼