pip-tools

Florian Demmer

= pip-compile + pip-sync

Django Friends Meetup, 2017-06-14

What is it?

 

A set of tools to keep your pinned Python dependencies fresh.

 

-- https://github.com/jazzband/pip-tools

requirements.txt

# pip install pip-tools
# vi requirements.in
wagtail==1.3.1
<esc>:x
# pip-compile requirements.in
# cat requirements.txt
wagtail==1.3.1
django-modelcluster==1.1  # via wagtail
django-taggit==0.18.0     # via wagtail
...

flashback... 2016-01-25

Overview

  1. read requirements from
    • setup.py (install_requires=[])
    • requirements.in (convention)
  2. find available packages
  3. write requirements to
    • requirements.txt (convention)


# pip-compile requirements.in

Better pinning

  • source (the *.in file)
    • unpinned (pytz)
    • range (django>=1.10,<1.11)
       
  • output (the *.txt file)
    • pinned to exact, available version
      (pytz==2017.2)
    • additional required packages
      (redis==2.10.5       # via django-redis)

Inheritance

useful for additional "dev" requirements

  1. define base requirements in "base.in"
  2. create "dev.in" with additional packages

 

*.in file:
 

-r base.in

django-debug-toolbar

Package index

  • create your own packages
  • host your own pypi mirror
  • ...

 

*.in file:
 

--extra-index-url https://private.site/pypi/

Upgrade packages

upgrade everything (according to pinning)

# pip-compile --upgrade

 

upgrade only specific package

# pip-compile --upgrade-package requests

Update virtualenv

finally update your virtualenv

# pip install -r dev.txt

 

or sync (= make sure venv is equal to dev.txt)

# pip-sync dev.txt

Pip tip

show outdated packages

 

# pip list --outdated

newrelic (2.80.1.61) - Latest: 2.86.3.70 [sdist]
paramiko (2.1.2) - Latest: 2.2.0 [wheel]
path.py (8.2.1) - Latest: 10.3.1 [wheel]

 

All the things

 

 

  • https://github.com/jazzband/pip-tools

  • my twitter: @fdemmer

  • slides: https://slides.com/fdemmer

Made with Slides.com