Comments (4)
Hello Mat!
Let's spare some insight.
On File Types that can be imported
httpimport
is a pure Python importer. That means that it only imports pure Python files (.py
only for the time being, and .pyc
is also possible to be implemented). Extensions compiled from C (.dll
, .so
, .a
, .lib
, .pyd
) can't be supported without big changes (implementing/reusing an in-memory/fileless way to get these objects in runtime and Namespace
). Yet, the compilation has to be correct (same arch and OS) for the platform that is using httpimport
. That can be quirky.
So, we end up with support for packages/modules that only contain:
.py
files in directory structure- single
.py
files
On Dependency Hell of packages/modules
Dependencies can be handled recursively, like in every other Finder/Loader:
Let's assume that test_package
depends on test_package_2
and both are not available in current $PYTHONPATH
.
Specifically:
test_package
is served underhttp://localhost:8001
test_package_2
is served underhttp://localhost:8002
The following code will import test_package
:
>>> from httpimport import remote_repo
>>> with remote_repo(['test_package_2'],"http://localhost:8002") :
... with remote_repo(['test_package'],"http://localhost:8001") :
... import test_package
...
[!] 'test_package.test_package_2' not found in HTTP repository. Moving to next Finder.
>>>
>>> test_package
<module 'test_package' from 'http://localhost:8001/test_package/__init__.py'>
>>> test_package.test_package_2
<module 'test_package_2' from 'http://localhost:8002/test_package_2/__init__.py'>
>>>
The Warning was generated by the Importer
that queried the http://localhost:8001
HTTP repo (inner with
statement).
When it moved to the next Finder
(that queried the http://localhost:8002
repo), no Warning fired, hence the import
was Succesful!
from httpimport.
Ok John, thank you very much for answer!
We know that when a program "A" is executed in a computer, the computer tries to execute the program "A" by searching for all needed libraries in some folders stored in hard disk (it depends on the executable or script main file).
Well, based on your knowledge and in general (regardless of httpimport), can we execute a main program or a main python script "A" that requires some external libraries (let's suppose these libraries are stored in a remote hard disk like GitHub, Dropbox, etc... and we know the url of each required library) by reading and storing in RAM memory of the user's computer both the main program or script "A" and all libraries as if they were on the hard disk of the user's computer? Does something like this exist?
In other words, can we temporarily put in the RAM memory the entire folder tree (with all the contents, required files/libraries in sub-folders, etc...) to run a script, instead of having this folder tree physically saved on the user's hard disk? We know that httpimport can do it with pure python scripts (in my opinion it is a great idea!).
I know that if I can read a library compiled in Linux, I can't read the same library using Windows (a program for Linux os can't be run using Windows os). But the python remote server provided by SageMathCell uses a Linux distribution, so user could compile what he/she wants with a Linux virtual machine installed on his/her computer, create a personal folder with tha main script and all the required libraries (pure python scripts or compiled files by user), save this folder in a remote hard disk like GiHub or personal Dropbox account, use the remote python server to import/load his/her own library to use it with any online device and an interface between his device and the remote python server.
What could be the advantages and disadvantages of a system that copies in the RAM of a computer the complete hierarchy of folders/subfolders saved on the hard disk in order to run any program in RAM as if it was saved on the hard disk with all its dependencies?
Thank you!
Regards
from httpimport.
In a nutshell you are requesting a native (Linux/Windows) linker-loader using HTTP/S (or networking in general).
This is a little bit out of scope for httpimport
(as it is Python only thing), and I'm not aware if this can be done in general.
But to get it straight, you need such a linker that using ldd
will list a HTTP/S URL instead of local library files. This is interesting stuff!
from httpimport.
I think if .zip import is supported, it will take care of dependencies a great deal
from httpimport.
Related Issues (20)
- Old module is imported when online file is changed HOT 2
- I encountered the following error when using the prompt HOT 1
- Support packages with shared object files HOT 2
- New version 0.9.2 breaks loading of joblib pickled model HOT 5
- Relative Path Importing/incorrect import package HOT 2
- Add support for module import directly from PyPI HOT 1
- Problem in Google Colab HOT 4
- Support Gitea Service
- Code to import from gist now breaks with AttributeError: 'list' object has no attribute 'endswith' HOT 5
- attribute error module 'passman' has no attribute 'list_profiles' HOT 2
- Support for Gitlab private repos HOT 9
- import public github HOT 4
- How do I import from private github repo? HOT 3
- can't access private repo from github HOT 5
- AttributeError - unlcear how to import a Class from a module HOT 6
- Not supported from package.module import class HOT 9
- PyPIImporter should be able to use proxy
- Python 3.12 Support HOT 3
- Load a python script that contains a main function HOT 13
- Importing libraries with different installation name HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from httpimport.