Preparation for Xcode ? Delete files in PythonistaAppTemplate?
And the app still work. :)
The compilation was a little more smooth, when the compiler didnt seem to copy over all the
For your suggestion, it almost calls for a small snippet of code to analyse what could be deleted. ;)
But for now I am happy, and I will come back to this issue later.
You must not have had any modules in the pylib_ext folder. But still, remember that you use more modules than your main program imports. Also, remember that apple has a maximum app size. It is in the documentation, I forget the actual number.
lukaskollmer last edited by
I made it through to TestFlight. :)
And just a main.py file, gave an app size og 60 MB.
Which is within the 100 Mb, "over the air" download limit.
So I dont want to hassle around to get lower app size. :)
A lot of the stuff in the regular pylib folder is taking up space. A lot of those modules you don't need. Your main.py will barely take up any space. You might be able to get your app size under 10mB.
ltddev last edited by
May I ask the community and @omz in particular if there is yet a an equivalent template available for Pythonista v2.0? If there is, please provide a link to it. If there is not, is there an action plan to provide one?
It is my understanding that given there is no template for Pythonista v2.0 it is NOT currently possible to produce apps for the Apple App store. Is my understanding correct?
Depends on which Python you are using. Pythonista 2.0 carries 2 Python levels: Python 2.7 and Python 3.5. The current template supports Python 2.7. To my knowledge, there is no template for Xcode and Python 3.5.
ltddev last edited by
@NoBetterName that was my understanding as well, and you help to format my request more clearly: I mean where is there a template for Pythonista 2.0, Python level 3.x code?
I got this started.
Running this snippet on the phone, give me the file paths.
import inspect import importlib pyt_mods = [ "os", "datetime", "json", "requests", "operator", "time", ] pythonista_mods = [ "ui", "console", "dialogs", "objc_util" ] all_mods = pyt_mods + pythonista_mods keep_list =  for imods in all_mods: try: module_obj = importlib.import_module(imods) filepath = inspect.getfile(module_obj).split("PythonistaKit.framework") keep_list.append(filepath) except TypeError as e: print(e) for filep in keep_list: print(filep)```
So I made an initial script "strip_pylib.py".
This script should be runned in pythonista at the phone.
It will make a "pylib_clean.sh" file, which should be copied to:
at the Xcode project.
And then issue:
source pylib_clean.sh rm pylib_clean.sh
(Note: pylib_clean.sh should be deleted in the PythonistaKit.framework folder afterwards,
or there will be problems with signing and sending to App store.)
pylib_clean.sh will delete a lot of files.
After compilation in Xcode, the program did not work.
I had to manually copy back the directory: "/pylib/encodings" from another copy of PythonistaAppTemplate, and then it worked.
The compilation in Xcode is a lot faster. :)
And the app size went from 60 MB to 30 MB.
There are still some files left, but I am not sure why they survived.
# Clear all # To get pythonista to work again, restart the app import sys sys.modules[__name__].__dict__.clear() # Now import import sys import inspect import importlib splitstr = "PythonistaKit.framework" pyt_mods = [ "os", "datetime", "json", "requests", "operator", "time", ] pythonista_mods = [ "ui", "console", "dialogs", "objc_util" ] all_mods = pyt_mods + pythonista_mods keep_list =  for imods in all_mods: try: m = importlib.import_module(imods) dirpath, filepath = inspect.getfile(m).split(splitstr) keep_list.append(filepath) except TypeError as e: #print(e) pass # Get the imported modules dict = sys.modules for key in dict: val = dict[key] if val == None: continue else: try: filepath = inspect.getfile(val) if splitstr in filepath: filepath_append = filepath.split(splitstr) keep_list.append(filepath_append) else: pass except TypeError as e: #print(e) pass # Make uniq and sort keep_list = sorted(set(keep_list)) # Now find all files import os fp = dirpath+splitstr extensions = [".py", ".pyo"] all_files =  for path, dirs, files in os.walk(fp): for f in files: filename, file_extension = os.path.splitext(f) if "/pylib/" in path or "/pylib_ext/" in path: if file_extension in extensions: stringfp = os.path.join(path, f) dirpath, filepath = stringfp.split(splitstr) all_files.append(filepath) # Make uniq and sort all_files = sorted(set(all_files)) # Make a delete list dellist = [x for x in all_files if x not in keep_list] # Write delete file fname = 'pylib_clean.sh' f = open(fname,'w') f.write("#!/usr/bin/env bash\n") for idel in dellist: f.write("rm ."+idel+"\n") f.close() f = open(fname, "r") for line in f: print(line), f.close()