Introducing PyEnvDiff-lib and a Hub & Spoke Python Environment Diff Tool

Comparing python environments is now easier than ever, because of the release of PyEnvDiff v0.3.

Have you ever had code work on your machine, but not another, due to a difference in installed libraries, version of python, or something else in the environment? Or tried to help somebody get something running, only to learn too late that their environment has a problem? PyEnvDiff tackles these challenges and more.

PyEnvDiff is a pure-python, dependency-free, library and tool that collects, organizes, displays and saves information about any python environment (2.6 to 3.8 or fork, any OS), and then enables both humans and computers to compare.

It is powerful even for a single environment, to get an overview of the current state. From just one command you can take a look at sys.path, which versions of what packages are installed, and the exact specs on the interpreter. When you have two or more python environments diffs can be performed. It’s your choice how. You can do a comparison between any two environments via files you manually move around. There is also a builtin HTTP service, which one or more python interpreters can send environment information to, in hub & spoke pattern. The one python environment becomes a server with a simple HTML UI that enables both a view for the one environment and a hub-like menu for running diffs on any two (or more) other interpreters which act as spokes. The environment information sent to the hub is all stored in RAM. So, its gone after a restart.

Other use-cases could include confirming deployments went as planned systematically, asking users (say in a GitHub issue thread) to send information about their python environment in a standardized and comprehensive way, doing a survey across a set of environments, seeing what is actually available in a serverless setting, adding an endpoint on any web-app back-end to display intelligence about the app’s environment, or supporting environment parity activities.

The object model for the library centers around a set of subclasses of a “Collector” base class. A Collector captures intelligence about a python environment, or fails to so gracefully, as well as serializes the information for enabling displaying on the command line, in JSON, or HTML.

The pyenvdiff-lib package includes the command line utility, hub-style server with web-UI, and spoke-style client. The package just needs to be anywhere on your PYTHONPATH or installed via pip install pyenvdiff; you will have all 3 tools plus a library for programmatic usage. Nothing but the package itself will be installed.

The GitHub README has more information.

Any feedback is appreciated. Feel free to make an issue on GitHub for anything related at all or e-mail me via the contact information on my site.

Thanks to the contributors, developers who have provided feedback already, and the PyCon Canada 2018 sponsors, organizers, and attendees for the enthusiasm and sprint-time to encourage further development.

Markets, Data, Technology & Experiments. Views and opinions expressed are my own.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store