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.


    Help on keeping a Python package compatible with Pythonista

    Pythonista
    cli command line setup.py pip argparse
    4
    14
    8238
    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.
    • victordomingos
      victordomingos last edited by

      Nice! I didn’t know pip would work directly with github repositories. It seems to install and remove as expected, but I am not able to run it after installation. Probably I won’t be able to run it from StaSh, because it’s Python 3... but I also didn’t find a way to run it from any other place. I tried to run the countfiles.py from stash_extensions/bin, but I get an error:

      Traceback (most recent call last):
        File "/private/var/mobile/Containers/Shared/AppGroup/F3C0E711-6D38-4FDF-81F2-DC3B97E4E9F1/Pythonista3/Documents/stash_extensions/bin/countfiles.py", line 2, in <module>
          from countfiles.__main__ import main_flow
        File "/private/var/mobile/Containers/Shared/AppGroup/F3C0E711-6D38-4FDF-81F2-DC3B97E4E9F1/Pythonista3/Documents/stash_extensions/bin/countfiles.py", line 2, in <module>
          from countfiles.__main__ import main_flow
      ModuleNotFoundError: No module named 'countfiles.__main__'; 'countfiles' is not a package
      
      1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        I think you need to name your script something different from your package... if you have countfiles.py on the path, i dont think you can import from the countfiles package... maybe have your stash bin be named something else, then use alias to name it countfiles, if you want.

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

          I did a quick test by renaming countfiles.py (which was generated automatically during install) to something else and, besides an unrelated and easy to solve import issue, it seems to work now. I just need to change the entrypoint on setup.py, then.

          Thanks!

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

            Unfortunately, we have run into problems again. The method of pip installing directly from GitHub was working OK, but some of the recent changes in setup.py seem to have broken compatibility with Pythonista. Now I get this error:

            [Count-files_4]$ cd ~/Documents/
            [~/Documents]$ pip install victordomingos/Count-files
            Working on GitHub repository ...
            Opening: https://github.com/victordomingos/Count-files/archive/master.zip
            Save as: /private/var/mobile/Containers/Data/Application/42E7AC0F-227A-43B8-BA4C-BEE6B30E9330/tmp//master.zip (156922 bytes)
                156922  [100.00%]
            Extracting archive file ...
            Running setup file ...
            SyntaxError('invalid syntax', ('/private/var/mobile/Containers/Data/Application/42E7AC0F-227A-43B8-BA4C-BEE6B30E9330/tmp/518fc4bef99942178e4acfbf283d866b/Count-files-master/setup.py', 15, 103, '    sys.stderr.write(f"Unsupported Python version: {sys.version_info.major}.{sys.version_info.minor}. "\n'))
            Failed to run setup.py
            Fall back to directory guessing ...
            Error: Cannot locate packages. Manual installation required.
            

            Maybe it has something to do with the lack of support for Python 3 in StaSh. We will try to remove that f-string and see if it solves the problem.

            Meanwhile, is there any other way to manually install a package like this, which does automatically the creation of an endpoint (which usually goes into stash_extensions/bin)?

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

              pip download generally works, followed by manual tar commands to extract, and then mv to move to where you want it

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

                In this case, setup.py should create an endpoint script in StaSh’s path. That endpoint script was the runnable script. Is there any other way to make it create that file?

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

                  We removed the f-string from setup.py, but now the default check for Python version again gets stuck because of StaSh not supporting Python 3.6. 😕

                  [~/Documents]$ pip install victordomingos/Count-files
                  Working on GitHub repository ...
                  Opening: https://github.com/victordomingos/Count-files/archive/master.zip
                  Save as: /private/var/mobile/Containers/Data/Application/42E7AC0F-227A-43B8-BA4C-BEE6B30E9330/tmp//master.zip 
                      156933
                  Extracting archive file ...
                  Running setup file ...
                  Unsupported Python version: 2.7. Python 3.6 or later is required.
                  
                  1 Reply Last reply Reply Quote 0
                  • ccc
                    ccc last edited by

                    There is a py3 branch on https://github.com/ywangd/stash

                    bennr01 1 Reply Last reply Reply Quote 0
                    • victordomingos
                      victordomingos last edited by

                      Last time I tried to install StaSh for Python 3 it didn’t go very well. I seemed to be in an early development stage. And apparently it still doesn’t work, at least to me. I just downloaded and installed that version:

                      Traceback (most recent call last):
                        File "/private/var/mobile/Containers/Shared/AppGroup/F3C0E711-6D38-4FDF-81F2-DC3B97E4E9F1/Pythonista3/Documents/launch_stash.py", line 31, in <module>
                          from stash import stash
                        File "/private/var/mobile/Containers/Shared/AppGroup/F3C0E711-6D38-4FDF-81F2-DC3B97E4E9F1/Pythonista3/Documents/site-packages/stash/stash.py", line 25, in <module>
                          from .system.shcommon import IN_PYTHONISTA, ON_IPAD
                        File "/private/var/mobile/Containers/Shared/AppGroup/F3C0E711-6D38-4FDF-81F2-DC3B97E4E9F1/Pythonista3/Documents/site-packages/stash/system/shcommon.py", line 50, in <module>
                          import _outputcapture
                      ModuleNotFoundError: No module named '_outputcapture'
                      
                      1 Reply Last reply Reply Quote 0
                      • JonB
                        JonB last edited by

                        did you forcequit pythonista after installng?

                        1 Reply Last reply Reply Quote 0
                        • bennr01
                          bennr01 @ccc last edited by

                          Hi,
                          StaSh supports py3 since version '0.7.0'. Try running 'selfupdate -f' to upgrade to the latest stable version (important: Version '0.7.0' requires a force update, please specify the '-f' parameter when running 'selfupdate').
                          There are also some unmerged changes with more bugfixes ('selfupdate -f bennr01:command_testing').
                          Please force-quit pythonista after updating StaSh.
                          If you have done this and are still experiencing problems, please paste the output of 'version' in StaSh.
                          Please also note that the newest version of StaSh supports botz py2 and py3 and thus uses the python version it is started with (With other words: you have to start StaSh using the py3 interpreter).

                          @ccc said:

                          There is a py3 branch on https://github.com/ywangd/stash

                          The 'py3' branch is outdated and unsupported. The py3 changes are already in 'master' (i think).

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

                            This worked. Thanks!

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