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.


    Local scripts cannot be accessed via Files app/document picker

    Pythonista
    8
    14
    7479
    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.
    • SmartGoat
      SmartGoat last edited by

      Wait, two questions:

      1. Is Working Copy able to detect iCloud Drive files changes to commit it in github ?
      2. if yes, why not putting your Pythonista files directly in the iCloud Drive folder of Pythonista ?
      comfortablynick 1 Reply Last reply Reply Quote 0
      • comfortablynick
        comfortablynick @SmartGoat last edited by

        @SmartGoat said:

        1. Is Working Copy able to detect iCloud Drive files changes to commit it in github ?

        Yes, that feature has been added.

        1. if yes, why not putting your Pythonista files directly in the iCloud Drive folder of Pythonista ?

        That is an option, one that I intend to use at some point. I'm using it currently for Scriptable, and it works great. I can edit a Scriptable script on my iPhone, then I open up Working Copy on my iPad (where I set up the sync) and see the change ready to be committed.

        One reason why (2) isn't a complete solution, is that Pythonista doesn't see iCloud in PYTHONPATH. In order to add user-defined modules, I believe they have to go in one of the site-packages directories in the device file system. But for version control of most scripts in Pythonista, the Working Copy sync function should work well with the Pythonista iCloud folder.

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

          Iirc you can, in a pythonista-startup script, modify sys.path to point to your iCloud folder.

          I forget the details, but sys.path is somewhat reset when globals are reset, but I think there was also a way around that.. possibly with site module or .pth files.

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

            Looks like this still hasn't been addressed. The "On My iPad/Pythonista 3" folder appears to be completely disconnected from the app. This needs to be fixed for Git via Working Copy to be viable.

            Any updates from the developer on this bug?

            mikael stephen 2 Replies Last reply Reply Quote 0
            • mikael
              mikael @RainmanNoodles last edited by

              @RainmanNoodles, there is something I do not understand here, as git via Working Copy works fine for me, with even two different route options:

              1. Open WC repository as an External Folder from Pythonista.
              2. Sync WC repository with an iCloud directory visible in Pythonista.

              Of course, in all cases you need to do the commits in WC.

              1 Reply Last reply Reply Quote 0
              • stephen
                stephen @RainmanNoodles last edited by stephen

                @RainmanNoodles @mikael this actually is same for me.

                Software Version: 13.3.1
                Device: iPad Air2
                Model Number: MGH62LL/A

                ever since this last release of Pythonista i still have the Pythonista folder but nolonger synched with App documents i even tried to delete but it just hides if its empty. this is what my icloud has told me.. i never realy used it so i figured it was just my device so i left it be..

                ouch

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

                  @RainmanNoodles @mikael

                  update:

                  After doing a reinstall i gained access to icloud again after reading @JonB comment above about site i figured it would reinstall default paths for the sys.path but aparently only for iCloud. i woder if for myself, and im sure others, this could be a bug from the new external file support? i would include @RainmanNoodles in that but it seem that his year old issue is still valid for his case..

                  *note: this isnt a problem for myself. i can and have been just using the external file access 😉 just wanted to let yall know

                  @RainmanNoodles wth that said you can access other files through External Files
                  img

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

                    I have the same problem as @RainmanNoodles. I had an app that was getting too large for Pythonista alone so I moved it to a git repository, got Working Copy and embarked on syncing between PyCharms -- Cloud Git -- Working Copy -- Pythonista.

                    Along the way, I restructured everything so that I can ultimately package the app. The current problem is that while I have a pretty standard structure, I cannot seem to import at the package level. Given something like this (which works on a PC with PyCharms):

                    README.md
                    LICENSE
                    setup.py
                    requirements.txt
                    app/__init__.py
                    app/core.py
                    app/helpers.py
                    app/tests/test_basic.py
                    app/tests/test_advanced.py
                    docs/conf.py
                    docs/index.rst
                    

                    The script test_basic.py cannot seem to import the core using a variety of import methods

                    from app import core as core
                    ...
                    import app.core as core
                    ...
                    

                    Pythonista gives the ModuleNotFoundError "No module named..." when this works on PC/PyCharms. I believe this is also true if the tests folder is at the same level as the app folder.

                    I have read a few scattered things about modifying sys.path and Pythonista's inability to search up the directory tree for anything (a) not on the device AND (b) not in the Script Library...but no advice to help me solve the problem yet.

                    stephen mikael 2 Replies Last reply Reply Quote 0
                    • stephen
                      stephen @h3ky1 last edited by stephen

                      @h3ky1 Make sure to use sys.path.append(path_to_core_module) inside test_basic so Python knows where core is. leemendelowitz.github

                      Edit:

                      there is also this package i found usefull a while back.. pypi.org

                      1 Reply Last reply Reply Quote 0
                      • mikael
                        mikael @h3ky1 last edited by mikael

                        @h3ky1, it is a pain that Pythonista does not really recognize the external folders as first-class citizens, neither does it include a feature to explicitly set the working directory.

                        (As an aside, I would not necessarily have tests in the app directory, if you think of app as the distributable program.)

                        As the path of least pain, I would suggest pip installing nose, and then creating a run_tests.py in your root with the contents below. Further setting that file as a wrench action will make it most convenient to run your tests while editing your app or the tests (need to use iCloud-synced version for this).

                        import nose
                        nose.run(defaultTest='app/tests/.')
                        
                        1 Reply Last reply Reply Quote 1
                        • h3ky1
                          h3ky1 last edited by h3ky1

                          Thanks @stephen and @mikael

                          I moved the test folder (as below - there was a higher app folder also which I have now shown here):

                          app/tests/test_basic.py
                          app/app/core.py

                          and included this in the test_*.py scripts:

                          module_path = os.path.join(os.path.dirname(sys.path[0]), 'app')
                          sys.path.append(module_path)
                          import core
                          

                          which allows for dynamic determination of the appropriate path.

                          Unfortunately, this sits above an import statement and PEP 8 doesn't like it...oh well.

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