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 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.
-
@bar0n, this sounds like an enhancement idea to be included in Pythonista-Issues.
-
This would be really useful. Now that Working Copy can sync files from iCloud Drive, my dream would be to someday have all of my Pythonista files in Git.
-
Wait, two questions:
- Is Working Copy able to detect iCloud Drive files changes to commit it in github ?
- if yes, why not putting your Pythonista files directly in the iCloud Drive folder of Pythonista ?
-
@SmartGoat said:
- Is Working Copy able to detect iCloud Drive files changes to commit it in github ?
Yes, that feature has been added.
- 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 thesite-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. -
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.
-
@RainmanNoodles @mikael this actually is same for me.
Software Version: 13.3.1
Device: iPad Air2
Model Number: MGH62LL/Aever 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..
-
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 thesys.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
-
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.
-
@h3ky1 Make sure to use
sys.path.append(path_to_core_module)
insidetest_basic
so Python knows where core is. leemendelowitz.githubEdit:
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.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/.')
-
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.pyand 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.