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.


    Request to add pylzfse to Pythonista

    Pythonista
    images pylzfse
    2
    9
    4609
    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.
    • TechnoExplorer
      TechnoExplorer last edited by

      Hi

      I was wondering whether pylzfse could be added to pythonista as I’m currently working on an image decompression project.

      Also I can’t just copy the code over as its c code.

      Thanks

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

        Apple provides the compression library, which includes lzsfe. You can implement your own wrapper to these functions using ctypes.

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

          I wanted to try and build it as a c extention for pythonista. I have already suceeded in building it for macOS, but having trouble building it for pythonista. I've tried both pip and python setup.py build, but they both fail. In truth, there are no errors, but it doesn’t show up when I try to import it.

          This is what I get when I try to install it

          [pylzfse]$ python setup.py install
          running install
          running build
          running build_ext
          building 'lzfse' extension
          xcrun --sdk iphonesimulator clang -arch x86_64 --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -miphoneos-version-min=7.0 -fno-strict-aliasing -OPT:Olimit=0 -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Ilzfse/src -I/var/containers/Bundle/Application/6419CEB5-AE35-4A82-8ED9-EC7744B0314A/Pythonista3.app/Frameworks/Py2Kit.framework/pylib/include/python2.7 -c lzfse/src/lzvn_decode_base.c -o build/temp.darwin-18.2.0-iPad5,3-2.7/lzfse/src/lzvn_decode_base.o -std=c99

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

            You cannot build a c extension. However you could build a wrapper using ctypes to call iOS built in libraries. Or also could use cffi.

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

              If you can’t build c extensions, then why is there a page dedicated to it? - http://omz-software.com/pythonista/docs/extending/building.html

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

                Everything below the line is just a copy of the police standard library docs.
                ... However iOS kernel restrictions prevent loading unsigned executable code.
                Also multiprocessing, and some other standard python bits are unsupported.

                But again, ctypes is provided, and you can totally write a few line wrapper to each compression library methods.

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

                  Sorry, let me clarify -- you cannot use c extenaions in the app. But you could use the XCode template to build your own app, in which case you can (since you would be using your developer id to sign the files)

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

                    Ah. I see. The thing is that I need to be able to run this in pythonista on my iPad for ideal portability between different OS’s. Idk whether I could cffi on my Mac for this and then move it over to pythonista. Bottom line is that I need to somehow get this code running in pythonista because I don’t exactly want to do a complete port of it to the python programming language.

                    1 Reply Last reply Reply Quote 0
                    • JonB
                      JonB last edited by ccc

                      try :
                          import pylzsfe
                      except ImportError:
                          import pylzsfe_wrapper as pylzsfe
                      

                      Handles the compatibility issues. As far as I can tell, pylzsfe offers two methods -- compress and decompress, so should be straightforward to implement the ctypes wrappers and whatever wrappers to simulate that pylzsfe interface. That's sort of the only real option you have, certainly in the short term.

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