1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
From ecb9787a2bbdbfc8076dd96af47946e21142ffb3 Mon Sep 17 00:00:00 2001
From: Barry Warsaw <barry@debian.org>
Date: Thu, 13 Aug 2015 18:21:53 -0400
Subject: Work around Debian's devendorizing of pkg_resource dependencies.
Forwarded: not-needed
Patch-Name: handle-pkg_resources-devendorization.patch
---
pex/pex_bootstrapper.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/pex/pex_bootstrapper.py b/pex/pex_bootstrapper.py
index 137757f..f2aaa45 100644
--- a/pex/pex_bootstrapper.py
+++ b/pex/pex_bootstrapper.py
@@ -94,6 +94,20 @@ def bootstrap_pex(entry_point):
register_finders()
maybe_reexec_pex()
+ # 2015-03-24 BAW (Debian/Ubuntu): This will make grown Pythonistas weep. In
+ # Debian, we devendorize pkg_resources by removing all its bundled
+ # dependencies and making it use the system versions. This plays havoc with
+ # pex though, because pex messes with sys.path and sys.modules and ends up
+ # double importing sub-modules from pkg_resources. This confuses Python
+ # deeply, resulting in AttributeError tracebacks when pkg_resources itself
+ # tries to dig sub-modules out of its own namespace. Yes, AttributeErrors,
+ # not ImportErrors. By pure trial and error, this seems to work around the
+ # problem.
+ import sys
+ for modname in list(sys.modules):
+ if modname.startswith('pkg_resources.'):
+ del sys.modules[modname]
+
from . import pex
pex.PEX(entry_point).execute()
|