launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #28285
[Merge] ~cjwatson/launchpad:wsgi-archive-auth-bionic into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:wsgi-archive-auth-bionic into launchpad:master.
Commit message:
Fix wsgi-archive-auth.py for Ubuntu 18.04
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/418180
`scripts/wsgi-archive-auth.py` runs within Apache mod_wsgi, which is a difficult environment for Launchpad code: it doesn't activate Launchpad's virtualenv and can't even be told to disable the automatic import of the `site` module (similar to Python's `-S` command-line option), so we have to take various countermeasures before manually activating the virtualenv so that we can import other parts of Launchpad.
In bionic, we need a new countermeasure. The system `zope.interface` package (installed as a dependency of landscape-common) is built with setuptools >= 31.0.0, which has new namespace package handling that causes `sys.modules["zope"]` to exist and to point to the system-installed package, even without importing `zope.interface`; this then confuses Launchpad code that tries to import from `zope.interface` later. Arrange for the namespace package to be re-imported to avoid this problem.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:wsgi-archive-auth-bionic into launchpad:master.
diff --git a/scripts/wsgi-archive-auth.py b/scripts/wsgi-archive-auth.py
index 53e5327..77fdf62 100755
--- a/scripts/wsgi-archive-auth.py
+++ b/scripts/wsgi-archive-auth.py
@@ -32,6 +32,13 @@ top = os.path.dirname(scripts_dir)
sys.modules.pop("site", None)
sys.modules.pop("sitecustomize", None)
+# If the system Zope packages were built with setuptools >= 31.0.0, then the
+# new namespace package handling there causes sys.modules["zope"] to exist
+# pointing to the system-installed package, which will confuse attempts to
+# import zope.interface later. Cross fingers and arrange for it to be
+# re-imported.
+sys.modules.pop("zope", None)
+
import _pythonpath # noqa: F401,E402
from lp.soyuz.wsgi.archiveauth import check_password # noqa: E402