Skip to Content
Python for DevOps
book

Python for DevOps

by Noah Gift, Kennedy Behrman, Alfredo Deza, Grig Gheorghiu
December 2019
Intermediate to advanced
506 pages
11h 55m
English
O'Reilly Media, Inc.
Book available
Content preview from Python for DevOps

Chapter 5. Package Management

Often, small scripts grow in usefulness and importance, which creates a need to share and distribute their contents. Python libraries, as well as other code projects, require packaging. Without packaging, distributing code becomes problematic and brittle.

Once past the proof of concept stage, it is helpful to keep track of changes, advertise the type of change (for example, when introducing a backward-incompatible update), and provide a way for users to depend on a specific version. Even in the most straightforward use cases, it is beneficial to follow a few (packaging) guidelines. This, at the very least, should mean keeping track of a changelog and determining a version.

There are several strategies to follow for package management, and knowing a few of the ones most commonly used allows you to adopt the best option to solve a problem. For example, it might be easier to distribute a Python library through the Python Package Index (PyPI) instead of making it a system package like Debian and RPM. If a Python script needs to run at specific intervals or if it is a long-running process, then system packaging working together with systemd might work better.

Although systemd is not a packaging tool, it does play well on systems that depend on it to manage processes and the server startup sequence. Learning how to handle processes with a few systemd configuration settings and some packaging is a great way to increase the capabilities of a Python project ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Practical Python for DevOps Engineers LiveLessons

Practical Python for DevOps Engineers LiveLessons

Chris Jackson

Publisher Resources

ISBN: 9781492057680Errata PageSupplemental Content