Skip to content

Instantly share code, notes, and snippets.

@kwlzn
Created July 25, 2018 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwlzn/01694a2e8a1f4083045ba0967092a91d to your computer and use it in GitHub Desktop.
Save kwlzn/01694a2e8a1f4083045ba0967092a91d to your computer and use it in GitHub Desktop.
external pex bootstrapping example
[omerta ~]$ python2.7
Python 2.7.13 (default, Mar 2 2017, 16:22:01)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests
>>>
[omerta ~]$ pex requests -o requests.pex
[omerta ~]$ python2.7
Python 2.7.13 (default, Mar 2 2017, 16:22:01)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, sys
>>> pex_filename = 'requests.pex'
>>> sys.path.insert(0, os.path.join(os.path.abspath(pex_filename), '.bootstrap'))
>>> from _pex import pex_bootstrapper
>>> pex_bootstrapper.bootstrap_pex_env(pex_filename)
>>> import requests
>>> requests.__file__
'/Users/kwilson/.pex/install/requests-2.19.1-py2.py3-none-any.whl.9c19d1f49965483c8e82326b964ec1050dff6851/requests-2.19.1-py2.py3-none-any.whl/requests/__init__.pyc'
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment