本文を読み飛ばす

PY4A: いろいろ

PY4A: Numpy をビルド

PyCrypto と同様のMakefileを作って、 compile OK でした。

ただ、 user base は、FATには置けなさそう。 .so の読み込みができません。 /data/local/tmp/local にコピーすれば読み込めました。

PY4A: PyCrypto をビルド

PEP452 って知らなかったです。 py4a の pyver と abi は間違っているみたいです。

次のリリースぐらいには直そうかな

さて、 pycrypto を cross compile してみました。

  • ファイル名の扱いで苦労しました

  • wheel (pip) の platform チェックを調べました

  • pycrypto の実機確認をしました。(簡単な例のみ)

  • スクリプトに落とし込んで完了

wheel (pip) の platform チェックを調べる

import re

wheel_file_re = re.compile(
        r"""^(?P<namever>(?P<name>.+?)-(?P<ver>\d.*?))
        ((-(?P<build>\d.*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
        \.whl|\.dist-info)$""",
        re.VERBOSE
    )
for i in ("pycrypto-2.6.1-cp36-cp36m-arm_linux_androideabi.whl",
          "pycrypto-2.6.1-cpython-36m-arm_linux_androideabi.whl",
          ):
    info = wheel_file_re.match(i)
    print(info.group("ver"),
          info.group("pyver"),
          info.group("abi"),
          info.group("plat"))

>>> 2.6.1 cp36 cp36m arm_linux_androideabi
>>> 2.6.1 cpython 36m arm_linux_androideabi

n7000 ~ # bash python3.sh
Python 3.6.0 (default, Mar  5 2017, 14:39:55)
[GCC 4.9 20140827 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from wheel import pep425tags
>>> pep425tags.supported_tags
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'wheel.pep425tags' has no attribute 'supported_tags'
>>> pep425tags.supported_tags
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'wheel.pep425tags' has no attribute 'supported_tags'
>>> from pip import pep425tags as a
WARNING:root:cert file changed, android system have no-compatibles with python:/mnt/sdcard/com.googlecode.python3forandroid/cacert.pem
>>> a.supported_tags
[('cp36', 'cp36m', 'linux_armv7l'), ('cp36', 'abi3', 'linux_armv7l'), ('cp36', 'none', 'linux_armv7l'), ('cp35', 'abi3', 'linux_armv7l'), ('cp34', 'abi3', 'linux_armv7l'), ('cp33', 'abi3', 'linux_armv7l'), ('cp32', 'abi3', 'linux_armv7l'), ('py3', 'none', 'linux_armv7l'), ('cp36', 'none', 'any'), ('cp3', 'none', 'any'), ('py36', 'none', 'any'), ('py3', 'none', 'any'), ('py35', 'none', 'any'), ('py34', 'none', 'any'), ('py33', 'none', 'any'), ('py32', 'none', 'any'), ('py31', 'none', 'any'), ('py30', 'none', 'any')]

出力を見ると linux_armv7l となってますね。

ファイル名を変更して install を実効してみます。:

n7000 ~ # bash python3.sh sl4a/scripts/pip_console.py install wheel
WARNING:root:cert file changed, android system have no-compatibles with python:/mnt/sdcard/com.googlecode.python3forandroid/cacert.pem
Collecting wheel
  Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
    100% |################################| 71kB 177kB/s
Installing collected packages: wheel
Successfully installed wheel-0.29.0
n7000 ~ # bash python3.sh sl4a/scripts/pip_console.py install pycrypto-2.6.1-cp36-cp36m-linux_armv7l.whl
WARNING:root:cert file changed, android system have no-compatibles with python:/mnt/sdcard/com.googlecode.python3forandroid/cacert.pem
Processing ./pycrypto-2.6.1-cp36-cp36m-linux_armv7l.whl
Installing collected packages: pycrypto
Successfully installed pycrypto-2.6.1

使えるかどうかテスト

n7000 ~ # bash python3.sh
Python 3.6.0 (default, Mar  5 2017, 14:39:55)
[GCC 4.9 20140827 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from Crypto.Hash import SHA256
>>> SHA256.new('abc'.encode("latin-1")).hexdigest()
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'

[Makefile](https://github.com/kuri65536/python-for-android/python-modules/PyCrypto/Makefile) に落とし込んで完了 [#130](https://github.com/kuri65536/python-for-android/issues/130)

PY4A: Python2 を2.7.12にupdate

放置していたので、update

  • Android NDK を r10e に upgrade ( r13b はgcc含まないので見送り)

  • r10e でツール名が i686-pc-linux-android -> i686-linux-android (libffi)

  • PREFIX, EXE_PREFIX, VPATH が必要になっていた (getpath.c)

PY4A: Python3関係 3.5は飛ばして3.6に対応

3.5がコンパイルできてなかったのは、 pythonのsrcにあるsetup.pyが動いてないせいでした。

cross compileには対応してないみたいです。

無理やりpatch当てて通しましたが、 sysconfigがhost用になっていたりして いろいろ修正が必要でした。

compile optionはtarget用に切り替えできたから これでいいのかな...

PY4A: Python2 を2.7.11にupdate

2015/12にリリースされていたので、update。

特に修正は必要なかった。

Docutils System Messages

コメント

Comments powered by Disqus
宣伝: