It might be notable that a module for importing packages/modules available through HTTP/S exists and it is httpimport
. This is for both Python2 and Python3.
So, as of the accepted answer, it turns out that there are ways to programmatically import remote modules "like javascript" as follows:
>>> with httpimport.remote_repo(['package1'], 'http://my-codes.example.com/python_packages'):
... import package1
...
>>> # -- 'package1' code is available here --
Edit (31/01/2023):
The syntax of most httpimport
commands has changed after the 1.0.0
re-write. The new parameters for remote_repo
omits the first argument, as below:
>>> with httpimport.remote_repo('http://my-codes.example.com/python_packages'):
... import package1
...
You might want to look at all usage examples provided in the repository README:
https://github.com/operatorequals/httpimport#basic-usage