On Fri, 26 Sep 2014 14:30:53 +0200 Stefano Zacchiroli <[email protected]> wrote: > Since the refactoring with the top-level debsources/ module, the webapp > requires python-matplotlib to be installed to run properly. That is > unfortunate, as matplotlib is needed only by the updater, and induces weird > requirements on the webserver user (e.g., a writable /var/www/.matplotlib > ?!!). > > We should track down and remove this dependency.
The dependency comes from debsources.mainlib, which imports debsources.updater, which imports debsources.charts. However, in debsources.updater, only the function 'update_charts' requires debsources.charts. Moving the 'from debsources import charts' from the top of updater.py to the top of the 'update_charts' function fixes the problem. A patch is attached. This should break PEP8 compliance[1] but flake8 doesn't complain after applying my changes. The unit tests run fine too. Maybe this patch is not ideal: from debsources.updater, debsources.mainlib only requires the functions 'parse_stages' and 'pp_stage' as well as the constants UPDATE_STAGES, KNOWN_STAGES and NO_OBSERVERS. A better fix might be to move those somewhere else (updater_utils.py?). Any thoughts? [1] [https://www.python.org/dev/peps/pep-0008/#imports]
>From 74d6f1560fdaadcff3960d68e4d094a7f3a9c827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Schreiner?= <[email protected]> Date: Tue, 24 Mar 2015 14:06:26 +0100 Subject: [PATCH] Import matploblib in update_charts only. --- debsources/updater.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debsources/updater.py b/debsources/updater.py index 0c90826..d0cc389 100644 --- a/debsources/updater.py +++ b/debsources/updater.py @@ -31,7 +31,6 @@ from datetime import datetime from email.utils import formatdate from sqlalchemy import sql, not_ -from debsources import charts from debsources import db_storage from debsources import fs_storage from debsources import statistics @@ -510,6 +509,7 @@ def update_metadata(status, conf, session): def update_charts(status, conf, session, suites=None): """update stage: rebuild charts""" + from debsources import charts logging.info('update charts...') ensure_stats_dir(conf) suites = __target_suites(session, suites) -- 2.1.4

