Giter Club home page Giter Club logo

Comments (4)

operatorequals avatar operatorequals commented on August 11, 2024

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 under http://localhost:8001
  • test_package_2 is served under http://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.

MatteoLM avatar MatteoLM commented on August 11, 2024

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.

operatorequals avatar operatorequals commented on August 11, 2024

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.

lavvy avatar lavvy commented on August 11, 2024

I think if .zip import is supported, it will take care of dependencies a great deal

from httpimport.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.