Created
February 3, 2014 05:56
-
-
Save wickman/8779443 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------- code/__main__.py ------- | |
import os | |
import pkgutil | |
from pprint import pprint | |
import sys | |
from zipimport import zipimporter | |
sys.path.insert(0, os.path.join(sys.argv[0], 'deps')) | |
import twitter | |
print('twitter: %s, twitter.__path__: %s' % (twitter, twitter.__path__)) | |
for importer in pkgutil.iter_importers(): | |
if isinstance(importer, zipimporter): | |
print('zipimporter: %s, archive: %s, prefix: %s' % (importer, importer.archive, importer.prefix)) | |
import twitter.aurora | |
import twitter.thermos | |
------- code/deps/twitter/__init__.py ------- | |
__import__('pkg_resources').declare_namespace(__name__) | |
------- code/deps/twitter/aurora.py ------- | |
DERP1 = 1 | |
------- code/twitter/__init__.py ------- | |
__import__('pkg_resources').declare_namespace(__name__) | |
------- code/twitter/thermos.py ------- | |
DERP2 = 2 | |
------- run.sh ------- | |
pushd code | |
find . -iname *~ -or -name *.pyc | xargs rm -f | |
zip -q -r code.pex __main__.py __init__.py deps twitter | |
mv code.pex .. | |
popd | |
echo --------------------------- | |
echo python2.7 | |
python2.7 code | |
echo --------------------------- | |
echo pypy | |
pypy code | |
echo --------------------------- | |
echo python2.7 | |
python2.7 code.pex | |
echo --------------------------- | |
echo pypy | |
pypy code.pex | |
*********** OUTPUT *********** | |
--------------------------- | |
python2.7 | |
twitter: <module 'twitter' from '/Users/wickman/work/2014.02.01.pypy_nspkg/code/twitter/__init__.py'>, twitter.__path__: ['code/deps/twitter', 'code/twitter'] | |
zipimporter: <zipimporter object "/Users/wickman/Python/CPython-2.7.6/lib/python2.7/site-packages/setuptools-2.0.2-py2.7.egg">, archive: /Users/wickman/Python/CPython-2.7.6/lib/python2.7/site-packages/setuptools-2.0.2-py2.7.egg, prefix: | |
--------------------------- | |
pypy | |
twitter: <module 'twitter' from '/Users/wickman/work/2014.02.01.pypy_nspkg/code/twitter/__init__.py'>, twitter.__path__: ['code/deps/twitter', 'code/twitter'] | |
zipimporter: <zipimporter object at 0x0000000102f5a4f8>, archive: /Users/wickman/Python/PyPy-2.2.1/site-packages/setuptools-2.0.2-py2.7.egg, prefix: | |
--------------------------- | |
python2.7 | |
twitter: <module 'twitter' from 'code.pex/twitter/__init__.py'>, twitter.__path__: ['code.pex/deps/twitter', 'code.pex/twitter'] | |
zipimporter: <zipimporter object "code.pex/deps/">, archive: code.pex, prefix: deps/ | |
zipimporter: <zipimporter object "code.pex">, archive: code.pex, prefix: | |
zipimporter: <zipimporter object "/Users/wickman/Python/CPython-2.7.6/lib/python2.7/site-packages/setuptools-2.0.2-py2.7.egg">, archive: /Users/wickman/Python/CPython-2.7.6/lib/python2.7/site-packages/setuptools-2.0.2-py2.7.egg, prefix: | |
--------------------------- | |
pypy | |
twitter: <module 'twitter' from 'code.pex/twitter/__init__.py'>, twitter.__path__: ['code.pex/twitter'] | |
zipimporter: <zipimporter object at 0x0000000102f5a4f8>, archive: code.pex, prefix: deps/ | |
zipimporter: <zipimporter object at 0x0000000102f5b8f8>, archive: code.pex, prefix: | |
zipimporter: <zipimporter object at 0x0000000102f5a408>, archive: /Users/wickman/Python/PyPy-2.2.1/site-packages/setuptools-2.0.2-py2.7.egg, prefix: | |
Traceback (most recent call last): | |
File "app_main.py", line 72, in run_toplevel | |
File "/Users/wickman/Python/PyPy-2.2.1/lib-python/2.7/runpy.py", line 162, in _run_module_as_main | |
"__main__", fname, loader, pkg_name) | |
File "/Users/wickman/Python/PyPy-2.2.1/lib-python/2.7/runpy.py", line 72, in _run_code | |
exec code in run_globals | |
File "code.pex/__main__.py", line 17, in <module> | |
import twitter.aurora | |
ImportError: No module named twitter.aurora |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment