DEV Community

Cover image for Ship your requirements.txt
Matt Layman
Matt Layman

Posted on • Originally published at mattlayman.com

4

Ship your requirements.txt

Dependencies: they're always changing.

Software is in such continuous flux. With this stream of change, maintainers can take a helpful step to inform users of dependency versions at the time of a release. By including a requirements.txt in a release, a maintainer can notify users of the state of the world when the package was released.

Python packages (or "distributions" if you want to use the official term) set dependencies in the setup.py file. A rule of thumb is to exclude version numbers in setup.py to avoid causing conflicts between packages. If my package says it requires requests==2.10.0 and your package says it requires requests==2.9.2, then users can run into trouble. Users who want to have to both my package and your package may run into trouble when installing.

By including a requirements.txt when you release a Python package on PyPI, you can tell users "Here are the versions of dependencies that I used when I declared my software fit for release." Many strange environments exist in the world and including your dependency versions in a separate file can help future software archeologists figure out how to make your software work in strange places.

This article first appeared on mattlayman.com.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay