distutils
, setuptools
and pip
patched for use in Pythonista.
These may require the Pythonista beta version 1.6 or release version 2.0 to work properly, especially distutils
, because it has to shadow the version from the stdlib. If you're still on Pythonista 1.5, you'll need to modify your sys.path
manually on every run to make the patched distutils
take priority over the version from the stdlib.
pip
technically works, however there are still a number of issues:
pip
MUST NOT BE USED TO UPDATE ITSELF! Otherwise all patches are overwritten andpip
will no longer work on Pythonista. (The built-in update notification has been disabled in thepip.conf
.)- After any "action" (i. e. installing, upgrading or uninstalling a module) is performed using
pip
, Pythonista must be rebooted. Otherwisepip
's "state" (i. e. the database of installed modules and their versions) is not updated properly. - Only pure Python modules can be installed. Process forking is disallowed for all iOS apps, which makes invoking an external compiler impossible. Dynamic libraries can also only be loaded if signed by the app developer, meaning that any compiled libraries wouldn't be usable. Oh, and that kind of thing is forbidden by Apple.
- Modules that come with Pythonista are not recognized. This means that if a module is installed and one of its dependencies is already included in Pythonista, the module will be reinstalled into the user
site-packages
(if it is pure Python) or the installation will fail entirely (if it requires native code). - The cache does not work. Currently it is disabled manually through the
pip.conf
, because otherwise a warning about the cache directory's permissions/owner is displayed every time. - There may be some odd warnings and strangely formatted output here and there, because the patches to
pip
are very hackish. It works, but it's certainly not great.
Any suggestions on how to fix these are welcome. If you have working code, please do submit a pull request.
- Move or copy the
distutils
folder into yoursite-packages
folder. - Open the
pydistutils.cfg
file in the editor. - Run this command in the Python prompt to "install" the config file:
import editor, os, shutil; shutil.copyfile(editor.get_path(), os.path.expanduser("~/.pydistutils.cfg"))
- Download a source version of
setuptools
(not a wheel) from https://pypi.python.org/pypi/setuptools. (Version 18.3.2 is known to work, future versions should as well, because only a single file is modified.) - Extract the downloaded archive using
stash
or another program. - Open
site-patch.py
and copy its entire contents, and paste them into<setuptools-source-folder>/setuptools/site-patch.py
. - Open
setuptools
'setup.py
script. - Tap and hold the "play" button, type
install
into the text field, and press Run. - Restart Pythonista. Double-press the home button to open the app switcher, swipe the Pythonista "window" up and off the screen, then open Pythonista again.
- Open
pip
'ssetup.py
script. - Tap and hold the "play" button, type
install
into the text field, and press Run. - Open the
pip.conf
file in the editor. - Run this command in the Python prompt to "install" the config file:
import editor, os, shutil; os.makedirs(os.path.expanduser("~/.config/pip")); shutil.copyfile(editor.get_path(), os.path.expanduser("~/.config/pip/pip.conf"))