Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Read/initialize full python libraries stored in the cloud (eg Dropbox)
-
Sorry for the strange question but it makes me curious. It is not related to Pythonista app, but maybe to any Python distribution.
The question: with only Python programming language and an online device can I (does a script exist to):
- read the full content of a compressed folder named "A" where:
- the folder "A" is a compressed (zip, tar, gz, rar, ...) folder which contains python sources like a common library, like the ones you find here;
- the compressed folder "A" is saved in a cloud service, for example dropbox, and it has a valid shared link.
- for read full content I mean read all files (pure-python sources)
- save the full content in the ram memory of the python environment.
- interpret/execute the source files of the folder "A" as if they were saved in the local memory (for example in site-packages).
- use in python console the definitions, functions, everything available with the library in the cloud in the same way I can import everything from a correctly locally installed library inside my python environment?
I expect you can ask me why? I don't know (but I know that in this way the speed for importing libraries will be decreased compared to have the libraries properly installed in the local memory/storage). I'm only curious to know if it is possibile by a theoretical point of view and with a full python 2.7.12 environment.
Thanks
- read the full content of a compressed folder named "A" where:
-
Hi. Since nobody answered I suppose the question was difficult to understand (or maybe not interesting). Anyway I post here a fast solution I tried yesterday (I have not done a lot of tests but for now it works with the example that I show here).
Well, suppose I want to import a package/library (named “A” for example) without installing it in Pythonista with the common “pip install …”. Let’s say, only to test it without full installation.
Let’s suppose also that I want to import the lib “A” in the remote server provided by SageMathCell (available through internet browser or python interface). For now, I know it is not possible to install python packages/libraries (pure-python) in SageMathCell with pip install. But it is possibile to import temporary them using only RAM (at least pure-python, maybe also not-pure-python, SageMathCell works with a Linux distribution and maybe some not-pure-python libs compiled for Linux could be imported by server).
This kind of magic is available with httpimport script written by John Torakis (https://github.com/operatorequals/httpimport).
The example I tested:
Lib “A” is a pure python lib to perform linear programming with simplex algorithm (https://github.com/khalibartan/simplex-method).
The script for Pythonista or for SageMathCell is this. You can download it executing:
import urllib url = "https://drive.google.com/uc?export=download&id=1sO3G2YLVhBSE54M2AXTT3O8OvMHzRURb" filename = "httpimport test.py" urllib.urlretrieve(url, filename)
It works with Pythonista and with SageMathCell (so it works with sage_interface).
I can’t use it with any python packages saved in cloud. The script is not tested, so most likely it doesn’t work always. I will perform some tests.
Bye
-
For those interested, httpimport author John Torakis is updating his library to support more features. This is the link of his project on GitHub.
Thanks