dgelessus/fistutils

语言: Python

git: https://github.com/dgelessus/fistutils

distutils和相关库修补用于Pythonista。
distutils and related libraries patched for use in Pythonista.
README.md (中文)

fistutils

distutils,setuptools和pip修补用于Pythonista。

这些可能需要Pythonista beta版本1.6或发行版本2.0才能正常工作,尤其是distutils,因为它必须从stdlib中隐藏版本。如果您仍在使用Pythonista 1.5,则需要在每次运行时手动修改sys.path,以使修补的distutils优先于stdlib的版本。

pip在技术上有效,但仍存在许多问题:

  1. 点不得用于更新自己!否则所有补丁都会被覆盖,pip将不再适用于Pythonista。 (pip.conf中已禁用内置更新通知。)
  2. 在使用pip执行任何“动作”(即安装,升级或卸载模块)之后,必须重新启动Pythonista。否则pip的“状态”(即已安装模块及其版本的数据库)未正确更新。
  3. 只能安装纯Python模块。所有iOS应用程序都不允许进程分叉,这使得无法调用外部编译器。动态库也只能在应用程序开发人员签名时加载,这意味着任何已编译的库都不可用。哦,Apple禁止这种事情。
  4. Pythonista附带的模块无法识别。这意味着如果安装了一个模块并且其中一个依赖项已包含在Pythonista中,则该模块将重新安装到用户站点包中(如果它是纯Python)或安装将完全失败(如果它需要本机代码) 。
  5. 缓存不起作用。目前通过pip.conf手动禁用它,因为否则每次都会显示有关缓存目录的权限/所有者的警告。
  6. 可能会有一些奇怪的警告和奇怪的格式化输出,因为pip的补丁是非常hackish。它有效,但肯定不是很好。

有关如何解决这些问题的任何建议都是受欢如果您有工作代码,请提交拉取请求。

安装

的distutils

  1. 将distutils文件夹移动或复制到site-packages文件夹中。
  2. 在编辑器中打开pydistutils.cfg文件。
  3. 在Python提示符下运行此命令以“安装”配置文件:import editor,os,shutil; shutil.copyfile(editor.get_path(),os.path.expanduser(“〜/ .pydistutils.cfg”))

setuptools的

  1. 从https://pypi.python.org/pypi/setuptools下载setuptools(不是方向盘)的源版本。 (已知版本18.3.2可以使用,未来的版本也应该可以使用,因为只修改了一个文件。)
  2. 使用存储或其他程序提取下载的存档。
  3. 打开site-patch.py​​并复制其全部内容,并将其粘贴到<setuptools-source-folder> /setuptools/site-patch.py​​中。
  4. 打开setuptools的setup.py脚本。
  5. 点击并按住“播放”按钮,在文本字段中键入install,然后按“运行”。
  6. 重启Pythonista。双击主页按钮打开应用程序切换器,向上滑动Pythonista“窗口”,然后再次打开Pythonista。

果仁

  1. 打开pip的setup.py脚本。
  2. 点击并按住“播放”按钮,在文本字段中键入install,然后按“运行”。
  3. 在编辑器中打开pip.conf文件。
  4. 在Python提示符下运行此命令以“安装”配置文件:import editor,os,shutil; os.makedirs(os.path.expanduser( “〜/的.config / PIP”)); shutil.copyfile(editor.get_path(),os.path.expanduser(“〜/ .config / pip / pip.conf”))

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

fistutils

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:

  1. pip MUST NOT BE USED TO UPDATE ITSELF! Otherwise all patches are overwritten and pip will no longer work on Pythonista. (The built-in update notification has been disabled in the pip.conf.)
  2. After any "action" (i. e. installing, upgrading or uninstalling a module) is performed using pip, Pythonista must be rebooted. Otherwise pip's "state" (i. e. the database of installed modules and their versions) is not updated properly.
  3. 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.
  4. 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).
  5. 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.
  6. 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.

Installation

distutils

  1. Move or copy the distutils folder into your site-packages folder.
  2. Open the pydistutils.cfg file in the editor.
  3. 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"))

setuptools

  1. 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.)
  2. Extract the downloaded archive using stash or another program.
  3. Open site-patch.py and copy its entire contents, and paste them into <setuptools-source-folder>/setuptools/site-patch.py.
  4. Open setuptools' setup.py script.
  5. Tap and hold the "play" button, type install into the text field, and press Run.
  6. 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.

pip

  1. Open pip's setup.py script.
  2. Tap and hold the "play" button, type install into the text field, and press Run.
  3. Open the pip.conf file in the editor.
  4. 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"))