1

I have a python package that is used by other applications across an organization, let's call it buildtools.

Other applications in my organization have installed this package via

pip install git+https://${OAUTH_TOKEN}:x-oauth-basic@github.com/my_organization/buildtools#egg=buildtools

I want to add a new feature to buildtools that requires a 3rd party package, let's just say its requests. So within buildtools I add requests to requirements.txt, import it, and it's all good.

But none of the other applications in my organization have requests as one of their dependencies in requirements.txt.

When I merge my new code in and update the package, I believe we will run into some ImportError: No module named requests errors in the downstream applications that use buildtools.

How can I ensure that any application that uses the buildtools package gets the requests package installed when they get the latest buildtools?

In other words, how can I update buildtools's dependencies recursively?

I am aware that I could add requests to requirements.txt across all the applications in my organization that uses buildtools, but I'm trying to avoid that.

Lee Gaines
  • 484
  • 3
  • 11

2 Answers2

0

Why don't you just run

pip install -r requirements.txt

as discussed, e.g. here?

That's the best and most painless way to update/install required packages recursively.

s0mbre
  • 361
  • 2
  • 14
  • As far as I understand, this wouldn't work because some of the machines that run my package don't have the 3rd party package I want to use installed on them. So if I update _my_ `requirements.txt` with a package that isn't installed on those machines there will be a "module not found" error. Does that make sense? I could very likely be wrong... – Lee Gaines Sep 16 '19 at 01:35
  • No, you should deliver your updated ```requirements.txt``` to the target machines and run the code above **from the target machines**. In that case, ```pip``` will automatically download and install the packages as described in ```requirements.txt```. – s0mbre Sep 17 '19 at 21:29
0

After further research I found that install_requires within setup.py is exactly what I was looking for. This example explains it well.

Lee Gaines
  • 484
  • 3
  • 11