omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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)

    Pythonista
    1
    3
    2615
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Matteo
      Matteo last edited by

      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):

      1. 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)
      2. save the full content in the ram memory of the python environment.
      3. interpret/execute the source files of the folder "A" as if they were saved in the local memory (for example in site-packages).
      4. 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

      1 Reply Last reply Reply Quote 0
      • Matteo
        Matteo last edited by Matteo

        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

        1 Reply Last reply Reply Quote 1
        • Matteo
          Matteo last edited by

          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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors