Module for remote in-memory Python package/module loading through HTTP/S
httpimport
Remote, in-memory Python package/module importing through HTTP/S
A feature that Python2/3 misses and has become popular in other languages is the remote loading of packages/modules.
httpimport
lets Python2/3 packages and modules to be imported directly in Python interpreter’s process memory, through remote URIs
, and more…
Examples
Load a simple package/module through HTTP/S
>>> with httpimport.remote_repo(['package1','package2','package3'], 'http://my-codes.example.com/python_packages'):
... import package1
...
Load directly from a GitHub/BitBucket/GitLab repo
- Load a python file from a github-gist (using this gist):
import httpimport
url = "https://gist.githubusercontent.com/operatorequals/ee5049677e7bbc97af2941d1d3f04ace/raw/e55fa867d3fb350f70b2897bb415f410027dd7e4"
with httpimport.remote_repo(["hello"], url):
import hello
hello.hello()
>>> with httpimport.github_repo('operatorequals', 'covertutils', branch = 'master'):
... import covertutils
... # Also works with 'bitbucket_repo' and 'gitlab_repo'
Load a package/module from HTTP/S directory directly to a variable
>>> module_object = httpimport.load('package1',