Home > Net >  pip install module but with fix version in dependency
pip install module but with fix version in dependency

Time:09-29

I recently had to bump a google cloud library due to a conflict that was generating a bug. Long story short, I had

google-cloud-pubsub==1.4.2

which I had to bump to 1.4.3. This in turn reverted google-api-core module to 1.16.0, which generated a conflict with another module google-cloud-secret-manager which required a higher version of google-api-core.

Now, I have removed google-cloud-secret-manager. But, If I try to install the module again to the last version however, it will bump me google-api-core to a version not compatible with google-cloud-pubsub. What I want to do instead is to pip install google-cloud-secret-manager to the highest possible version that is compatible with google-api-core==1.16.0 without manually trying to install all the versions until i find the right match. Is it something possible? Is there a pip install fix dependency version command that could allow me to easily install google-cloud-secret-manager that will not change the version of the dependency module google-api-core to a different version? Thank you

CodePudding user response:

You can achieve this with a constraints file. Just put all your constraints into that file:

google-api-core==1.16.0

Then you can install via:

python -m pip install -c constraints.txt google-cloud-secret-manager

This will try every version of google-cloud-secret-manager, starting from the most recent version, until it finds a version that is compatible with the given constraints.

  • Related