Local scripts cannot be accessed via Files app/document picker
Pythonista has two different file storage options: "This iPad" and "iCloud".
Anything stored in the "iCloud" section appears in "iCloud Drive/Pythonista 3" in the Files app. However, for files stored in the "This iPad" section, there is no corresponding "On My iPad/Pythonista 3" folder.
This means that only scripts stored in iCloud Drive are accessible from the file picker, so apps like Working Copy can't work with local scripts. If Pythonista stored its local documents so that they correctly appeared in the Files app, Working Copy could see those local files as well.
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.
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?
@RainmanNoodles, there is something I do not understand here, as git via Working Copy works fine for me, with even two different route options:
- Open WC repository as an External Folder from Pythonista.
- Sync WC repository with an iCloud directory visible in Pythonista.
Of course, in all cases you need to do the commits in WC.
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..
After doing a reinstall i gained access to icloud again after reading @JonB comment above about
sitei figured it would reinstall default paths for the
sys.pathbut 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
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.
there is also this package i found usefull a while back.. pypi.org
@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.pyin 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/.')
I moved the test folder (as below - there was a higher app folder also which I have now shown here):
and included this in the test_*.py scripts:
module_path = os.path.join(os.path.dirname(sys.path), '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.