'Pip install but skip setup.py if already exists

I have a script that runs pip install -r requirements.txt -t folder and executes scripts in "folder" for me.

Every time I run it pip install runs, collects all the packages and installs them with setup.py. It looks like it's not making any changes for packages that are already there and up to date but it still takes a while to collect them and run setup.py for each one. Often I'm not modifying the packages.

How can I have it skip ones that are already there? is there a way to speed this up apart from just not running pip install every time?



Solution 1:[1]

You could take a look at :

-I, --ignore-installed Ignore the installed packages (reinstalling instead).

or

--upgrade-strategy Determines how dependency upgrading should be handled [default: only-if-needed]. "eager" - dependencies are upgraded regardless of whether the currently installed version satisfies the requirements of the upgraded package(s). "only-if-needed" - are upgraded only when they do not satisfy the requirements of the upgraded package(s).

Never get into this problem before, but https://pip.pypa.io/en/stable/man/commands/install/?highlight=--ignore-installed it might help you.

Or you can do a pre-setup script that make some check before.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tsrandrei