Skip to content
This repository has been archived by the owner on Nov 10, 2023. It is now read-only.

Commit

Permalink
Import fix for namespaced packages
Browse files Browse the repository at this point in the history
Summary: This diff is basically just an import of pex-tool/pex#338, but without the tests (we don't have the pex tests in this repo?). This solves a problem where the pex would fail to run any time you had a namespaced package in your path.

Test Plan: eyes

Reviewed By: sdwilsh

fbshipit-source-id: 8d500c3
  • Loading branch information
scottrice authored and facebook-github-bot committed Nov 1, 2017
1 parent 345f634 commit fca8a46
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions third-party/py/pex/README.facebook
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Local modifications:
- Added the ability to not hash the contents of the pex (used for in-place builds).
- Added support for directory resources
- Back-ported Python 3.6 compatibility commit c5ab73fd4d8e816e21a89d48c8d0c8095ef5a49c
- Back-ported namespaced packages fix, commit 7d2dc7f500aa7ae227c3ddca4b278b807d353a5e
5 changes: 5 additions & 0 deletions third-party/py/pex/pex/pex.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ def minimum_sys_modules(cls, site_libs, modules=None):
new_modules[module_name] = module
continue

# Unexpected objects, e.g. namespace packages, should just be dropped:
if not isinstance(module.__path__, list):
TRACER.log('Dropping %s' % (module_name,), V=3)
continue

# Pop off site-impacting __path__ elements in-place.
for k in reversed(range(len(module.__path__))):
if cls._tainted_path(module.__path__[k], site_libs):
Expand Down

0 comments on commit fca8a46

Please sign in to comment.