Don't get me wrong Pip is a great package manager but there is one thing that had always bugged me, that was having all the dependencies within a single file. For example having all of your development dependencies (linters, formators etc) and your application dependencies (Scrapli, Nornir etc) all within one requirements.txt

This was until I discovered the fact that you can import dependencies from one requirements.txt to another. Let me explain...

First, create a requirements.txt containing your application dependencies.

$ cat requirements.txt
pyats==21.7
pyats.aereport==21.7
pyats.aetest==21.7
pyats.async==21.7
pyats.connections==21.7
pyats.datastructures==21.7
pyats.easypy==21.7
pyats.kleenex==21.7
...

Now we can create a requirements-dev.txt containing our development dependencies, along with importing our previous dependencies, using -r requirements.txt. Like so:

-r requirements.txt
appdirs==1.4.4
astroid==2.6.6
attrs==21.2.0
bandit==1.7.0
black==21.7b0
click==8.0.1
eradicate==2.0.0
flake8==3.9.2
flake8-builtins==1.5.3
flake8-eradicate==1.1.0
...

Now if you now perform a pip install -r requirements-dev.txt you will install both sets of dependencies, whilst keeping the 2 sets of dependencies separated!

Master Network Automation
Join today and get access to:
  • Full deep-dive course library (inc. Batfish, pyATS, Netmiko)
  • Code repositories inc. full course code, scripts and examples
  • 24x7 Multi-vendor labs (Arista, Cisco, Juniper)
  • Private online community
  • Monthly online meetups
  • Monthly guest speakers

100% Satisfaction Guaranteed!
Cancel your membership at any time.


Join Today