Package: django-package-monitor
Django Package MonitorThis package is now Python3 and Django 1.11 and above. For previous versions please refer to the Python2 branch.A Django app for keeping track of dependency updates.BackgroundAt YunoJuno we have a Django project that includes almost 100 external packages.
In order to manage updates to these we have a rolling development task that
comes around in the first week of each month, and includes the following:Usingpip list--outdatedlist out all available updatesGroup updates (usingsemver) into Major, Minor, Patch, OtherApply patch updates in a single update / commitApply minor updates as a group, see what breaks, remove, rinse, repeatTake a view on major updatesThis task is a PITA, and so we decided to make it simpler.ImplementationThis project contains a Django app that can be used to monitor your packages.It consists of a single model,PackageVersion, an admin list view that you
can use to view current package versions, and load latest versions from PyPI,
and a single management command that can be used to load local requirements and
update remote versions from the shell - which you could run overnight if you
felt the need.It is important to note that this appdoes notupdate your requirements for
you - it simply displays the requirements that you have, and the latest that
is available on PyPI.In order to illustrate how it works, the app itself contains a Django project
that can be used to demonstrate the feature.InstallationDownload / install the app using pip:pipinstalldjango-package-monitorAdd the apppackage_monitorto yourINSTALLED_APPSDjango setting:# settings.pyINSTALLED_APPS=('django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','package_monitor',...)Set thePACKAGE_MONITOR_REQUIREMENTS_FILEsetting to point to your project
requirements file:# settings.pyPACKAGE_MONITOR_REQUIREMENTS_FILE=path.join(PROJECT_ROOT,'requirements.txt')Add the app URLs to your project - NB it must have the namespace set:# urls.pyurlpatterns=patterns('',url(r'^admin/',include(admin.site.urls)),url(r'^package_monitor/',include('package_monitor.urls',namespace='package_monitor')),)At this point you should have a working implementation. You can test this by running
the management command to load your local requirements:# load up the local requirements file$pythonmanage.pyrefresh_packages--localThis will load all of the requirements it finds in the requirements file specified into the
database. If you then want to check PyPI for updated version, run the command with the--remoteoption. You can run both of these command together:# load up the local requirements file, and check PyPI$pythonmanage.pyrefresh_packages--local--remoteIf you want to clean out the existingPackageVersiontable before loading the local file, use the--cleanoption:# clear out database, load up the local requirements file, and check PyPI$pythonmanage.pyrefresh_packages--clean--local--remoteTestsThere is a test suite that can be run using tox:$pipinstall-rrequirements$toxIn addition to the unit tests, the source distribution also includes a fully-functioning Django
project, that can be run from the repo root, and used to demonstrate how it works:$gitclonegit@github.com:yunojuno/django-package-monitor.git$cddjango-package-monitor$pipinstall-rrequirements.txt# you will need to create a superuser in order to access the admin site$pythonmanage.pycreatesuperuser$pythonmanage.pyrunserverIf you then log in to the app (http://localhost:8000/adminby default), you can then see the admin
list page:If you click on the “Reload local requirements” button in the top-right, it will load up the contents
of the requirements file that you used earlier:NB If any requirements cannot be parsed by thesemantic_version.Version.coercemethod, then theis_parseableproperty is set toFalse, and the package is in effect unmanaged.At this point it has parsed the requirements file, and stored the current working version of
each package (ascurrent_version). In order to see what the latest versions are, select all the packages,
and choose “Update selected packages from PyPI” form the actions list:This may take some time, as it will call the PyPI API for each package (excluding those that are
marked as editable), and download the latest version info for each. At the end of this, you should
see the page updated with the new version information (aslatest_version) - as well as the licence
information that is stored in the PyPI metadata:If you drill down to the detail on an individual package, you can see all of the available versions:ContributingThis is by no means complete - it can’t cope with requirements that are anything other than ‘==’,
and it doesn’t (yet) help with updating the requirements file itself. However, it’s good enough to
be of value, hence releasing it. If you would like to contribute to the project, usual Github rules
apply:Fork the repo to your own accountSubmit a pull requestAdd tests for any new codeFollow coding style of existing projectLicenceThis project is MIT licensed - see the LICENCE file for details.