diff --git a/.travis.yml b/.travis.yml index 59a7e035..0b7b450c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,15 @@ sudo: required -dist: trusty +dist: xenial language: python python: -- '2.7' +- '3.6' install: - deactivate - export PATH=/usr/bin:$PATH - sudo dpkg --add-architecture i386 +- sudo add-apt-repository ppa:jonathonf/python-3.6 -y - sudo apt-get -qq update -- sudo apt-get -qq install build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386 +- sudo apt-get -qq install build-essential python3.6 python3.6-dev python3.6-venv python3-pip ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386 - sudo pip install --upgrade cython==0.25.2 pip setuptools - wget -q https://nodejs.org/dist/v8.11.1/node-v8.11.1-linux-x64.tar.xz - tar -xf node-v8.11.1-linux-x64.tar.xz @@ -26,11 +27,14 @@ install: - cd .. - mv buildozer.spec.travis buildozer.spec - mkdir -p cd ~/.buildozer/android/platform/ -- wget -q 'https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip' -P ~/.buildozer/android/platform/ +- wget -q 'https://us.crystax.net/download/crystax-ndk-10.3.2-linux-x86_64.tar.xz' -P ~/.buildozer/android/ - wget -q 'https://dl.google.com/android/android-sdk_r23-linux.tgz' -P ~/.buildozer/android/platform/ - wget -q 'https://dl.google.com/android/repository/platform-27_r01.zip' -P ~/.buildozer/android/platform/ - wget -q 'https://dl.google.com/android/repository/build-tools_r26.0.1-linux.zip' -P ~/.buildozer/android/platform/ -- unzip -qq ~/.buildozer/android/platform/android-ndk-r13b-linux-x86_64.zip -d ~/.buildozer/android/platform/ +- tar -xf ~/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz -C ~/.buildozer/android/ +- cp -f $TRAVIS_BUILD_DIR/scripts/build-target-python.sh ~/.buildozer/android/crystax-ndk-10.3.2/build/tools/build-target-python.sh +- rm -rf ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9 +- ln -s ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21 ~/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9 - tar -xf ~/.buildozer/android/platform/android-sdk_r23-linux.tgz -C ~/.buildozer/android/platform/ - mv ~/.buildozer/android/platform/android-sdk-linux ~/.buildozer/android/platform/android-sdk-23 - unzip -qq ~/.buildozer/android/platform/platform-27_r01.zip -d ~/.buildozer/android/platform/android-sdk-23/platforms diff --git a/Vagrantfile b/Vagrantfile index e3d5fc5c..713a2efa 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -43,7 +43,7 @@ Vagrant.configure("2") do |config| dpkg --add-architecture i386 apt-get update apt-get install -y libssl-dev - apt-get install -y autoconf libffi-dev pkg-config libtool build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386 python-pip + apt-get install -y python3.6 python3.6-dev python3-pip autoconf libffi-dev pkg-config libtool build-essential ccache git libncurses5:i386 libstdc++6:i386 libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 python2.7 python2.7-dev openjdk-8-jdk unzip zlib1g-dev zlib1g:i386 m4 libc6-dev-i386 python-pip pip install -f --upgrade setuptools pyopenssl git clone https://github.com/lbryio/buildozer.git cd buildozer @@ -63,12 +63,15 @@ Vagrant.configure("2") do |config| cp $HOME/lbry-android/buildozer.spec.vagrant $HOME/lbry-android/buildozer.spec mkdir -p cd $HOME/.buildozer/android/platform/ - wget -q 'https://dl.google.com/android/repository/android-ndk-r13b-linux-x86_64.zip' -P $HOME/.buildozer/android/platform/ + wget -q 'https://us.crystax.net/download/crystax-ndk-10.3.2-linux-x86_64.tar.xz' -P $HOME/.buildozer/android/ wget -q 'https://dl.google.com/android/android-sdk_r23-linux.tgz' -P $HOME/.buildozer/android/platform/ wget -q 'https://dl.google.com/android/repository/platform-27_r01.zip' -P $HOME/.buildozer/android/platform/ wget -q 'https://dl.google.com/android/repository/build-tools_r26.0.1-linux.zip' -P $HOME/.buildozer/android/platform/ - unzip -qq $HOME/.buildozer/android/platform/android-ndk-r13b-linux-x86_64.zip -d $HOME/.buildozer/android/platform/ - rm $HOME/.buildozer/android/platform/android-ndk-r13b-linux-x86_64.zip + tar -xf ~/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz -C $HOME/.buildozer/android/ + rm $HOME/.buildozer/android/crystax-ndk-10.3.2-linux-x86_64.tar.xz + ln -s $HOME/.buildozer/android/crystax-ndk-10.3.2/platforms/android-21 $HOME/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9 + cp -f $HOME/lbry-android/scripts/build-target-python.sh $HOME/.buildozer/android/crystax-ndk-10.3.2/build/tools/build-target-python.sh + rm -rf $HOME/.buildozer/android/crystax-ndk-10.3.2/platforms/android-9 tar -xf $HOME/.buildozer/android/platform/android-sdk_r23-linux.tgz -C $HOME/.buildozer/android/platform/ rm $HOME/.buildozer/android/platform/android-sdk_r23-linux.tgz mv $HOME/.buildozer/android/platform/android-sdk-linux $HOME/.buildozer/android/platform/android-sdk-23 diff --git a/buildozer.spec.sample b/buildozer.spec.sample index 7305b759..fe626139 100644 --- a/buildozer.spec.sample +++ b/buildozer.spec.sample @@ -36,7 +36,7 @@ version.filename = %(source.dir)s/main.py # (list) Application requirements # comma seperated e.g. requirements = sqlite3,kivy -requirements = openssl, sqlite3, hostpython2, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, keyring==10.4.0, netifaces, txupnp==0.0.1a10, git+https://github.com/lbryio/lbryschema.git@v0.0.16#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git@v0.21.2#egg=lbrynet, asn1crypto, cryptography==2.2.2, pyopenssl==17.4.0, treq==17.8.0, funcsigs, mock, pbr, unqlite +requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, miniupnpc==1.9, gmpy, appdirs==1.4.3, argparse==1.2.1, docopt, base58==1.0.0, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2, pyyaml, qrcode==5.2.2, requests, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, txJSON-RPC, zope.interface==4.3.3, protobuf==3.2.0, keyring==10.4.0, txupnp, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, asn1crypto, treq==17.8.0, funcsigs, mock, pbr, pyopenssl, twisted, idna, Automat, hyperlink, PyHamcrest, netifaces, cryptography, aiohttp, git+https://github.com/lbryio/torba#egg=torba, coincurve # (str) Custom source folders for requirements # Sets custom source for any requirements with recipes @@ -98,16 +98,16 @@ android.minapi = 21 android.sdk = 23 # (str) Android NDK version to use -android.ndk = 13b +#android.ndk = 13b # (bool) Use --private data storage (True) or --dir public storage (False) #android.private_storage = True # (str) Android NDK directory (if empty, it will be automatically downloaded.) -#android.ndk_path = ~/Dev/SDKs/android-ndk-r13b +android.ndk_path = ~/.buildozer/android/crystax-ndk-10.3.2 # (str) Android SDK directory (if empty, it will be automatically downloaded.) -#android.sdk_path = ~/Dev/SDKs/android +#android.sdk_path = ~/.buildozer/android # (str) ANT directory (if empty, it will be automatically downloaded.) #android.ant_path = diff --git a/buildozer.spec.travis b/buildozer.spec.travis index 7305b759..fe626139 100644 --- a/buildozer.spec.travis +++ b/buildozer.spec.travis @@ -36,7 +36,7 @@ version.filename = %(source.dir)s/main.py # (list) Application requirements # comma seperated e.g. requirements = sqlite3,kivy -requirements = openssl, sqlite3, hostpython2, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, keyring==10.4.0, netifaces, txupnp==0.0.1a10, git+https://github.com/lbryio/lbryschema.git@v0.0.16#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git@v0.21.2#egg=lbrynet, asn1crypto, cryptography==2.2.2, pyopenssl==17.4.0, treq==17.8.0, funcsigs, mock, pbr, unqlite +requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, miniupnpc==1.9, gmpy, appdirs==1.4.3, argparse==1.2.1, docopt, base58==1.0.0, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2, pyyaml, qrcode==5.2.2, requests, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, txJSON-RPC, zope.interface==4.3.3, protobuf==3.2.0, keyring==10.4.0, txupnp, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, asn1crypto, treq==17.8.0, funcsigs, mock, pbr, pyopenssl, twisted, idna, Automat, hyperlink, PyHamcrest, netifaces, cryptography, aiohttp, git+https://github.com/lbryio/torba#egg=torba, coincurve # (str) Custom source folders for requirements # Sets custom source for any requirements with recipes @@ -98,16 +98,16 @@ android.minapi = 21 android.sdk = 23 # (str) Android NDK version to use -android.ndk = 13b +#android.ndk = 13b # (bool) Use --private data storage (True) or --dir public storage (False) #android.private_storage = True # (str) Android NDK directory (if empty, it will be automatically downloaded.) -#android.ndk_path = ~/Dev/SDKs/android-ndk-r13b +android.ndk_path = ~/.buildozer/android/crystax-ndk-10.3.2 # (str) Android SDK directory (if empty, it will be automatically downloaded.) -#android.sdk_path = ~/Dev/SDKs/android +#android.sdk_path = ~/.buildozer/android # (str) ANT directory (if empty, it will be automatically downloaded.) #android.ant_path = diff --git a/buildozer.spec.vagrant b/buildozer.spec.vagrant index 7305b759..fe626139 100644 --- a/buildozer.spec.vagrant +++ b/buildozer.spec.vagrant @@ -36,7 +36,7 @@ version.filename = %(source.dir)s/main.py # (list) Application requirements # comma seperated e.g. requirements = sqlite3,kivy -requirements = openssl, sqlite3, hostpython2, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, functools32, miniupnpc==1.9, gmpy==1.17, twisted==16.6.0, appdirs==1.4.3, argparse==1.2.1, docopt==0.6.2, base58==0.2.2, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse==0.2.0, jsonrpc==1.2, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2==1.3, pyyaml==3.12, qrcode==5.2.2, requests==2.9.1, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, slowaes==0.1a1, txJSON-RPC==0.5, wsgiref==0.1.2, zope.interface==4.3.3, protobuf==3.2.0, keyring==10.4.0, netifaces, txupnp==0.0.1a10, git+https://github.com/lbryio/lbryschema.git@v0.0.16#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git@v0.21.2#egg=lbrynet, asn1crypto, cryptography==2.2.2, pyopenssl==17.4.0, treq==17.8.0, funcsigs, mock, pbr, unqlite +requirements = python3crystax, openssl, sqlite3, hostpython3crystax, android, distro, pyjnius, certifi==2018.4.16, constantly, incremental, miniupnpc==1.9, gmpy, appdirs==1.4.3, argparse==1.2.1, docopt, base58==1.0.0, colorama==0.3.7, dnspython==1.12.0, ecdsa==0.13, envparse, jsonrpclib==0.1.7, jsonschema==2.5.1, pbkdf2, pyyaml, qrcode==5.2.2, requests, seccure==0.3.1.3, attrs==18.1.0, pyasn1, pyasn1-modules, service_identity==16.0.0, six==1.9.0, txJSON-RPC, zope.interface==4.3.3, protobuf==3.2.0, keyring==10.4.0, txupnp, git+https://github.com/lbryio/lbryschema.git#egg=lbryschema, git+https://github.com/lbryio/lbryum.git#egg=lbryum, git+https://github.com/lbryio/lbry.git#egg=lbrynet, asn1crypto, treq==17.8.0, funcsigs, mock, pbr, pyopenssl, twisted, idna, Automat, hyperlink, PyHamcrest, netifaces, cryptography, aiohttp, git+https://github.com/lbryio/torba#egg=torba, coincurve # (str) Custom source folders for requirements # Sets custom source for any requirements with recipes @@ -98,16 +98,16 @@ android.minapi = 21 android.sdk = 23 # (str) Android NDK version to use -android.ndk = 13b +#android.ndk = 13b # (bool) Use --private data storage (True) or --dir public storage (False) #android.private_storage = True # (str) Android NDK directory (if empty, it will be automatically downloaded.) -#android.ndk_path = ~/Dev/SDKs/android-ndk-r13b +android.ndk_path = ~/.buildozer/android/crystax-ndk-10.3.2 # (str) Android SDK directory (if empty, it will be automatically downloaded.) -#android.sdk_path = ~/Dev/SDKs/android +#android.sdk_path = ~/.buildozer/android # (str) ANT directory (if empty, it will be automatically downloaded.) #android.ant_path = diff --git a/p4a/pythonforandroid/bootstrap.py b/p4a/pythonforandroid/bootstrap.py index f7aa6c9b..ef89fef8 100644 --- a/p4a/pythonforandroid/bootstrap.py +++ b/p4a/pythonforandroid/bootstrap.py @@ -1,12 +1,12 @@ -from os.path import (join, dirname, isdir, splitext, basename, realpath) -from os import listdir, mkdir +from os.path import (join, dirname, isdir, splitext, basename) +from os import listdir import sh import glob import json import importlib from pythonforandroid.logger import (warning, shprint, info, logger, - debug, error) + debug) from pythonforandroid.util import (current_directory, ensure_dir, temp_directory, which) from pythonforandroid.recipe import Recipe diff --git a/p4a/pythonforandroid/bootstraps/lbry/build/jni/src/start.c b/p4a/pythonforandroid/bootstraps/lbry/build/jni/src/start.c index e709ca5f..80cd5ace 100644 --- a/p4a/pythonforandroid/bootstraps/lbry/build/jni/src/start.c +++ b/p4a/pythonforandroid/bootstraps/lbry/build/jni/src/start.c @@ -308,9 +308,9 @@ JNIEXPORT void JNICALL Java_org_kivy_android_PythonService_nativeStart( setenv("PYTHONHOME", python_home, 1); setenv("PYTHONPATH", python_path, 1); setenv("PYTHON_SERVICE_ARGUMENT", arg, 1); - + char ca_path[128]; - snprintf(ca_path, 128, "%s/lib/python2.7/site-packages/certifi/cacert.pem", python_home); + snprintf(ca_path, 128, "%s/crystax_python/site-packages/certifi/cacert.pem", python_home); setenv("SSL_CERT_FILE", ca_path, 1); char *argv[] = {"."}; diff --git a/p4a/pythonforandroid/build.py b/p4a/pythonforandroid/build.py index 461839c1..38766883 100644 --- a/p4a/pythonforandroid/build.py +++ b/p4a/pythonforandroid/build.py @@ -396,6 +396,7 @@ class Context(object): 'platforms', 'android-{}'.format(self.android_min_api), platform_dir) + if not exists(self.ndk_platform): warning('ndk_platform doesn\'t exist: {}'.format( self.ndk_platform)) @@ -529,7 +530,7 @@ class Context(object): if self.python_recipe.from_crystax: return self.get_python_install_dir() return join(self.get_python_install_dir(), - 'lib', 'python2.7', 'site-packages') + 'lib', 'python3.6', 'site-packages') def get_libs_dir(self, arch): '''The libs dir for a given arch.''' @@ -634,7 +635,7 @@ def run_pymodules_install(ctx, modules): venv = sh.Command(ctx.virtualenv) with current_directory(join(ctx.build_dir)): - shprint(venv, '--python=python2.7', 'venv') + shprint(venv, '--python=python3.6', 'venv') info('Creating a requirements.txt file for the Python modules') with open('requirements.txt', 'w') as fileh: diff --git a/p4a/pythonforandroid/distribution.py b/p4a/pythonforandroid/distribution.py index 0db59a28..735b64a7 100644 --- a/p4a/pythonforandroid/distribution.py +++ b/p4a/pythonforandroid/distribution.py @@ -41,7 +41,7 @@ class Distribution(object): return str(self) @classmethod - def get_distribution(cls, ctx, name=None, recipes=[], + def get_distribution(cls, ctx, name=None, recipes=[], force_build=False, extra_dist_dirs=[], require_perfect_match=False): @@ -70,10 +70,6 @@ class Distribution(object): correct set of recipes. ''' - # AND: This whole function is a bit hacky, it needs checking - # properly to make sure it follows logically correct - # possibilities - existing_dists = Distribution.get_distributions(ctx) needs_build = True # whether the dist needs building, will be returned diff --git a/p4a/pythonforandroid/logger.py b/p4a/pythonforandroid/logger.py index 93c086f8..38afba0e 100644 --- a/p4a/pythonforandroid/logger.py +++ b/p4a/pythonforandroid/logger.py @@ -1,4 +1,3 @@ - import logging import os import re @@ -16,7 +15,7 @@ if not six.PY3: stderr = codecs.getwriter('utf8')(stderr) if six.PY2: - unistr = unicode + unistr = unicode # noqa F821 else: unistr = str @@ -43,6 +42,7 @@ class LevelDifferentiatingFormatter(logging.Formatter): Err_Style.RESET_ALL) + record.msg return super(LevelDifferentiatingFormatter, self).format(record) + logger = logging.getLogger('p4a') if not hasattr(logger, 'touched'): # Necessary as importlib reloads # this, which would add a second @@ -72,6 +72,7 @@ class colorama_shim(object): def enable(self, enable): self._enabled = enable + Out_Style = colorama_shim(Colo_Style) Out_Fore = colorama_shim(Colo_Fore) Err_Style = colorama_shim(Colo_Style) @@ -173,6 +174,8 @@ def shprint(command, *args, **kwargs): msg_width = columns - len(msg_hdr) - 1 output = command(*args, **kwargs) for line in output: + if isinstance(line, bytes): + line = line.decode('utf-8', errors='replace') if logger.level > logging.DEBUG: msg = line.replace( '\n', ' ').replace( diff --git a/p4a/pythonforandroid/patching.py b/p4a/pythonforandroid/patching.py index 541bab85..2a477332 100644 --- a/p4a/pythonforandroid/patching.py +++ b/p4a/pythonforandroid/patching.py @@ -18,6 +18,7 @@ def is_platform(platform): return uname()[0] == platform return is_x + is_linux = is_platform('Linux') is_darwin = is_platform('Darwin') @@ -30,31 +31,31 @@ def is_arch(xarch): def is_api_gt(apiver): def is_x(recipe, **kwargs): - return recipe.ctx.android_min_api > apiver + return recipe.ctx.android_api > apiver return is_x def is_api_gte(apiver): def is_x(recipe, **kwargs): - return recipe.ctx.android_min_api >= apiver + return recipe.ctx.android_api >= apiver return is_x def is_api_lt(apiver): def is_x(recipe, **kwargs): - return recipe.ctx.android_min_api < apiver + return recipe.ctx.android_api < apiver return is_x def is_api_lte(apiver): def is_x(recipe, **kwargs): - return recipe.ctx.android_min_api <= apiver + return recipe.ctx.android_api <= apiver return is_x def is_api(apiver): def is_x(recipe, **kwargs): - return recipe.ctx.android_min_api == apiver + return recipe.ctx.android_api == apiver return is_x diff --git a/p4a/pythonforandroid/recipe.py b/p4a/pythonforandroid/recipe.py index d80d03bc..20bab446 100644 --- a/p4a/pythonforandroid/recipe.py +++ b/p4a/pythonforandroid/recipe.py @@ -1,11 +1,11 @@ -from os.path import join, dirname, isdir, exists, isfile, split, realpath, basename +from os.path import basename, dirname, exists, isdir, isfile, join, realpath import importlib -import zipfile import glob from shutil import rmtree from six import PY2, with_metaclass import hashlib +from re import match import sh import shutil @@ -20,7 +20,6 @@ from pythonforandroid.logger import (logger, info, warning, error, debug, shprin from pythonforandroid.util import (urlretrieve, current_directory, ensure_dir) # this import is necessary to keep imp.load_source from complaining :) -import pythonforandroid.recipes if PY2: @@ -149,7 +148,7 @@ class Recipe(with_metaclass(RecipeMeta)): urlretrieve(url, target, report_hook) return target - elif parsed_url.scheme in ('git', 'git+ssh', 'git+http', 'git+https'): + elif parsed_url.scheme in ('git', 'git+file', 'git+ssh', 'git+http', 'git+https'): if isdir(target): with current_directory(target): shprint(sh.git, 'fetch', '--tags') @@ -168,43 +167,6 @@ class Recipe(with_metaclass(RecipeMeta)): shprint(sh.git, 'submodule', 'update', '--recursive') return target - def extract_source(self, source, cwd): - """ - (internal) Extract the `source` into the directory `cwd`. - """ - if not source: - return - if isfile(source): - info("Extract {} into {}".format(source, cwd)) - - if source.endswith(".tgz") or source.endswith(".tar.gz"): - shprint(sh.tar, "-C", cwd, "-xvzf", source) - - elif source.endswith(".tbz2") or source.endswith(".tar.bz2"): - shprint(sh.tar, "-C", cwd, "-xvjf", source) - - elif source.endswith(".zip"): - zf = zipfile.ZipFile(source) - zf.extractall(path=cwd) - zf.close() - - else: - warning( - "Error: cannot extract, unrecognized extension for {}" - .format(source)) - raise Exception() - - elif isdir(source): - info("Copying {} into {}".format(source, cwd)) - - shprint(sh.cp, '-a', source, cwd) - - else: - warning( - "Error: cannot extract or copy, unrecognized path {}" - .format(source)) - raise Exception() - # def get_archive_rootdir(self, filename): # if filename.endswith(".tgz") or filename.endswith(".tar.gz") or \ # filename.endswith(".tbz2") or filename.endswith(".tar.bz2"): @@ -225,19 +187,19 @@ class Recipe(with_metaclass(RecipeMeta)): build directory. """ info("Applying patch {}".format(filename)) - filename = join(self.recipe_dir, filename) + filename = join(self.get_recipe_dir(), filename) shprint(sh.patch, "-t", "-d", self.get_build_dir(arch), "-p1", "-i", filename, _tail=10) def copy_file(self, filename, dest): info("Copy {} to {}".format(filename, dest)) - filename = join(self.recipe_dir, filename) + filename = join(self.get_recipe_dir(), filename) dest = join(self.build_dir, dest) shutil.copy(filename, dest) def append_file(self, filename, dest): info("Append {} to {}".format(filename, dest)) - filename = join(self.recipe_dir, filename) + filename = join(self.get_recipe_dir(), filename) dest = join(self.build_dir, dest) with open(filename, "rb") as fd: data = fd.read() @@ -329,7 +291,14 @@ class Recipe(with_metaclass(RecipeMeta)): return join(self.get_build_container_dir(arch), self.name) def get_recipe_dir(self): - # AND: Redundant, an equivalent property is already set by get_recipe + """ + Returns the local recipe directory or defaults to the core recipe + directory. + """ + if self.ctx.local_recipes is not None: + local_recipe_dir = join(self.ctx.local_recipes, self.name) + if exists(local_recipe_dir): + return local_recipe_dir return join(self.ctx.root_dir, 'recipes', self.name) # Public Recipe API to be subclassed if needed @@ -349,6 +318,16 @@ class Recipe(with_metaclass(RecipeMeta)): return url = self.versioned_url + ma = match(u'^(.+)#md5=([0-9a-f]{32})$', url) + if ma: # fragmented URL? + if self.md5sum: + raise ValueError( + ('Received md5sum from both the {} recipe ' + 'and its url').format(self.name)) + url = ma.group(1) + expected_md5 = ma.group(2) + else: + expected_md5 = self.md5sum shprint(sh.mkdir, '-p', join(self.ctx.packages_path, self.name)) @@ -356,44 +335,41 @@ class Recipe(with_metaclass(RecipeMeta)): filename = shprint(sh.basename, url).stdout[:-1].decode('utf-8') do_download = True - marker_filename = '.mark-{}'.format(filename) if exists(filename) and isfile(filename): if not exists(marker_filename): shprint(sh.rm, filename) - elif self.md5sum: + elif expected_md5: current_md5 = md5sum(filename) - if current_md5 == self.md5sum: - debug('Checked md5sum: downloaded expected content!') - do_download = False - else: - info('Downloaded unexpected content...') + if current_md5 != expected_md5: debug('* Generated md5sum: {}'.format(current_md5)) - debug('* Expected md5sum: {}'.format(self.md5sum)) - + debug('* Expected md5sum: {}'.format(expected_md5)) + raise ValueError( + ('Generated md5sum does not match expected md5sum ' + 'for {} recipe').format(self.name)) + do_download = False else: do_download = False - info('{} download already cached, skipping' - .format(self.name)) # If we got this far, we will download if do_download: debug('Downloading {} from {}'.format(self.name, url)) shprint(sh.rm, '-f', marker_filename) - self.download_file(url, filename) + self.download_file(self.versioned_url, filename) shprint(sh.touch, marker_filename) - if exists(filename) and isfile(filename) and self.md5sum: + if exists(filename) and isfile(filename) and expected_md5: current_md5 = md5sum(filename) - if self.md5sum is not None: - if current_md5 == self.md5sum: - debug('Checked md5sum: downloaded expected content!') - else: - info('Downloaded unexpected content...') + if expected_md5 is not None: + if current_md5 != expected_md5: debug('* Generated md5sum: {}'.format(current_md5)) - debug('* Expected md5sum: {}'.format(self.md5sum)) - exit(1) + debug('* Expected md5sum: {}'.format(expected_md5)) + raise ValueError( + ('Generated md5sum does not match expected md5sum ' + 'for {} recipe').format(self.name)) + else: + info('{} download already cached, skipping'.format(self.name)) def unpack(self, arch): info_main('Unpacking {} for {}'.format(self.name, arch)) @@ -404,8 +380,6 @@ class Recipe(with_metaclass(RecipeMeta)): if user_dir is not None: info('P4A_{}_DIR exists, symlinking instead'.format( self.name.lower())) - # AND: Currently there's something wrong if I use ln, fix this - warning('Using cp -a instead of symlink...fix this!') if exists(self.get_build_dir(arch)): return shprint(sh.rm, '-rf', build_dir) @@ -421,11 +395,13 @@ class Recipe(with_metaclass(RecipeMeta)): filename = shprint( sh.basename, self.versioned_url).stdout[:-1].decode('utf-8') + ma = match(u'^(.+)#md5=([0-9a-f]{32})$', filename) + if ma: # fragmented URL? + filename = ma.group(1) with current_directory(build_dir): directory_name = self.get_build_dir(arch) - # AND: Could use tito's get_archive_rootdir here if not exists(directory_name) or not isdir(directory_name): extraction_filename = join( self.ctx.packages_path, self.name, filename) @@ -638,7 +614,6 @@ class Recipe(with_metaclass(RecipeMeta)): if len(logger.handlers) > 1: logger.removeHandler(logger.handlers[1]) recipe = mod.recipe - recipe.recipe_dir = dirname(recipe_file) recipe.ctx = ctx cls.recipes[name] = recipe return recipe @@ -755,6 +730,10 @@ class PythonRecipe(Recipe): return join( Recipe.get_recipe('hostpython2', self.ctx).get_build_dir(), 'hostpython') + elif 'hostpython3crystax' in self.ctx.recipe_build_order: + return join( + Recipe.get_recipe('hostpython3crystax', self.ctx).get_build_dir(), + 'hostpython') else: python_recipe = self.ctx.python_recipe return 'python{}'.format(python_recipe.version) @@ -779,6 +758,34 @@ class PythonRecipe(Recipe): env['PYTHONNOUSERSITE'] = '1' if not self.call_hostpython_via_targetpython: + # sets python headers/linkages...depending on python's recipe + python_version = self.ctx.python_recipe.version + python_short_version = '.'.join(python_version.split('.')[:2]) + if 'python2' in self.ctx.recipe_build_order: + env['PYTHON_ROOT'] = self.ctx.get_python_install_dir() + env['CFLAGS'] += ' -I' + env[ + 'PYTHON_ROOT'] + '/include/python2.7' + env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \ + ' -lpython2.7' + elif self.ctx.python_recipe.from_crystax: + ndk_dir_python = join(self.ctx.ndk_dir, 'sources', + 'python', python_version) + env['CFLAGS'] += ' -I{} '.format( + join(ndk_dir_python, 'include', + 'python')) + env['LDFLAGS'] += ' -L{}'.format( + join(ndk_dir_python, 'libs', arch.arch)) + env['LDFLAGS'] += ' -lpython{}m'.format(python_short_version) + elif 'python3' in self.ctx.recipe_build_order: + # This headers are unused cause python3 recipe was removed + # TODO: should be reviewed when python3 recipe added + env['PYTHON_ROOT'] = self.ctx.get_python_install_dir() + env['CFLAGS'] += ' -I' + env[ + 'PYTHON_ROOT'] + '/include/python{}m'.format( + python_short_version) + env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \ + ' -lpython{}m'.format( + python_short_version) hppath = [] hppath.append(join(dirname(self.hostpython_location), 'Lib')) hppath.append(join(hppath[0], 'site-packages')) @@ -819,28 +826,12 @@ class PythonRecipe(Recipe): with current_directory(self.get_build_dir(arch.arch)): hostpython = sh.Command(self.hostpython_location) - if self.ctx.python_recipe.from_crystax: - # hppath = join(dirname(self.hostpython_location), 'Lib', - # 'site-packages') hpenv = env.copy() - # if 'PYTHONPATH' in hpenv: - # hpenv['PYTHONPATH'] = ':'.join([hppath] + - # hpenv['PYTHONPATH'].split(':')) - # else: - # hpenv['PYTHONPATH'] = hppath - # hpenv['PYTHONHOME'] = self.ctx.get_python_install_dir() - # shprint(hostpython, 'setup.py', 'build', - # _env=hpenv, *self.setup_extra_args) shprint(hostpython, 'setup.py', 'install', '-O2', '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=.', - # AND: will need to unhardcode the 3.5 when adding 2.7 (and other crystax supported versions) _env=hpenv, *self.setup_extra_args) - # site_packages_dir = self.ctx.get_site_packages_dir() - # built_files = glob.glob(join('build', 'lib*', '*')) - # for filen in built_files: - # shprint(sh.cp, '-r', filen, join(site_packages_dir, split(filen)[-1])) elif self.call_hostpython_via_targetpython: shprint(hostpython, 'setup.py', 'install', '-O2', _env=env, *self.setup_extra_args) @@ -857,7 +848,6 @@ class PythonRecipe(Recipe): '--root={}'.format(self.ctx.get_python_install_dir()), '--install-lib=lib/python2.7/site-packages', _env=hpenv, *self.setup_extra_args) - # AND: Hardcoded python2.7 needs fixing # If asked, also install in the hostpython build dir if self.install_in_hostpython: @@ -917,6 +907,7 @@ class CompiledComponentsPythonRecipe(PythonRecipe): shprint(hostpython, 'setup.py', self.build_cmd, '-v', _env=env, *self.setup_extra_args) + class CppCompiledComponentsPythonRecipe(CompiledComponentsPythonRecipe): """ Extensions that require the cxx-stl """ call_hostpython_via_targetpython = False @@ -926,39 +917,34 @@ class CppCompiledComponentsPythonRecipe(CompiledComponentsPythonRecipe): keys = dict( ctx=self.ctx, arch=arch, - arch_noeabi=arch.arch.replace('eabi', ''), - pyroot=self.ctx.get_python_install_dir() + arch_noeabi=arch.arch.replace('eabi', '') ) env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' - env['CFLAGS'] += " -I{pyroot}/include/python2.7 " \ - " -I{ctx.ndk_dir}/platforms/android-{ctx.android_min_api}/arch-{arch_noeabi}/usr/include" \ + env['CFLAGS'] += " -I{ctx.ndk_dir}/platforms/android-{ctx.android_api}/arch-{arch_noeabi}/usr/include" \ " -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/include" \ " -I{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/include".format(**keys) env['CXXFLAGS'] = env['CFLAGS'] + ' -frtti -fexceptions' env['LDFLAGS'] += " -L{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}" \ - " -lpython2.7" \ " -lgnustl_shared".format(**keys) - return env - def build_compiled_components(self,arch): + def build_compiled_components(self, arch): super(CppCompiledComponentsPythonRecipe, self).build_compiled_components(arch) # Copy libgnustl_shared.so with current_directory(self.get_build_dir(arch.arch)): sh.cp( - "{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/libgnustl_shared.so".format(ctx=self.ctx,arch=arch), + "{ctx.ndk_dir}/sources/cxx-stl/gnu-libstdc++/{ctx.toolchain_version}/libs/{arch.arch}/libgnustl_shared.so".format(ctx=self.ctx, arch=arch), self.ctx.get_libs_dir(arch.arch) ) - - class CythonRecipe(PythonRecipe): pre_build_ext = False cythonize = True cython_args = [] + call_hostpython_via_targetpython = False def __init__(self, *args, **kwargs): super(CythonRecipe, self).__init__(*args, **kwargs) @@ -1082,21 +1068,6 @@ class CythonRecipe(PythonRecipe): env['LIBLINK_PATH'] = liblink_path ensure_dir(liblink_path) - if self.ctx.python_recipe.from_crystax: - env['CFLAGS'] = '-I{} '.format( - join(self.ctx.ndk_dir, 'sources', 'python', - self.ctx.python_recipe.version, 'include', - 'python')) + env['CFLAGS'] - - # Temporarily hardcode the -lpython3.x as this does not - # get applied automatically in some environments. This - # will need generalising, along with the other hardcoded - # py3.5 references, to support other python3 or crystax - # python versions. - python3_version = self.ctx.python_recipe.version - python3_version = '.'.join(python3_version.split('.')[:2]) - env['LDFLAGS'] = env['LDFLAGS'] + ' -lpython{}m'.format(python3_version) - return env diff --git a/p4a/pythonforandroid/recipes/cryptography/__init__.py b/p4a/pythonforandroid/recipes/cryptography/__init__.py index 91fae24c..64f79df9 100644 --- a/p4a/pythonforandroid/recipes/cryptography/__init__.py +++ b/p4a/pythonforandroid/recipes/cryptography/__init__.py @@ -5,7 +5,7 @@ class CryptographyRecipe(CompiledComponentsPythonRecipe): name = 'cryptography' version = '1.4' url = 'https://github.com/pyca/cryptography/archive/{version}.tar.gz' - depends = [('python2', 'python3crystax'), 'openssl', 'idna', 'pyasn1', 'six', 'setuptools', 'enum34', 'ipaddress', 'cffi'] + depends = [('python2', 'python3crystax'), 'openssl', 'idna', 'pyasn1', 'six', 'setuptools', 'ipaddress', 'cffi'] call_hostpython_via_targetpython = False def get_recipe_env(self, arch): diff --git a/recipes/android/__init__.py b/recipes/android/__init__.py index 87fdff01..16110958 100644 --- a/recipes/android/__init__.py +++ b/recipes/android/__init__.py @@ -1,3 +1,83 @@ +from pythonforandroid.recipe import CythonRecipe, IncludedFilesBehaviour +from pythonforandroid.util import current_directory +from pythonforandroid.patching import will_build +from pythonforandroid import logger + +from os.path import join + + +class AndroidRecipe(IncludedFilesBehaviour, CythonRecipe): + # name = 'android' + version = None + url = None + + src_filename = 'src' + + depends = [('pygame', 'sdl2', 'genericndkbuild'), ('python2', 'python3crystax')] + + config_env = {} + + def get_recipe_env(self, arch): + env = super(AndroidRecipe, self).get_recipe_env(arch) + env.update(self.config_env) + return env + + def prebuild_arch(self, arch): + super(AndroidRecipe, self).prebuild_arch(arch) + + tpxi = 'DEF {} = {}\n' + th = '#define {} {}\n' + tpy = '{} = {}\n' + + bootstrap = bootstrap_name = self.ctx.bootstrap.name + is_sdl2 = bootstrap_name in ('sdl2', 'sdl2python3', 'sdl2_gradle') + is_pygame = bootstrap_name in ('pygame',) + is_webview = bootstrap_name in ('webview',) + is_lbry = bootstrap_name in ('lbry',) + + if is_sdl2 or is_webview or is_lbry: + if is_sdl2: + bootstrap = 'sdl2' + java_ns = 'org.kivy.android' + jni_ns = 'org/kivy/android' + elif is_pygame: + java_ns = 'org.renpy.android' + jni_ns = 'org/renpy/android' + else: + logger.error('unsupported bootstrap for android recipe: {}'.format(bootstrap_name)) + exit(1) + + config = { + 'BOOTSTRAP': bootstrap, + 'IS_SDL2': int(is_sdl2), + 'IS_PYGAME': int(is_pygame), + 'PY2': int(will_build('python2')(self)), + 'JAVA_NAMESPACE': java_ns, + 'JNI_NAMESPACE': jni_ns, + } + + with current_directory(self.get_build_dir(arch.arch)): + with open(join('android', 'config.pxi'), 'w') as fpxi: + with open(join('android', 'config.h'), 'w') as fh: + with open(join('android', 'config.py'), 'w') as fpy: + for key, value in config.items(): + fpxi.write(tpxi.format(key, repr(value))) + fpy.write(tpy.format(key, repr(value))) + fh.write(th.format(key, value if isinstance(value, int) + else '"{}"'.format(value))) + self.config_env[key] = str(value) + + if is_sdl2: + fh.write('JNIEnv *SDL_AndroidGetJNIEnv(void);\n') + fh.write('#define SDL_ANDROID_GetJNIEnv SDL_AndroidGetJNIEnv\n') + elif is_pygame: + fh.write('JNIEnv *SDL_ANDROID_GetJNIEnv(void);\n') + + +recipe = AndroidRecipe() + + +''' from pythonforandroid.recipe import CythonRecipe, Recipe, IncludedFilesBehaviour from pythonforandroid.util import current_directory from pythonforandroid.patching import will_build @@ -83,3 +163,4 @@ class AndroidRecipe(IncludedFilesBehaviour, CythonRecipe): recipe = AndroidRecipe() +''' \ No newline at end of file diff --git a/recipes/android/src/setup.py b/recipes/android/src/setup.py index 8a276fe2..47ef6a94 100755 --- a/recipes/android/src/setup.py +++ b/recipes/android/src/setup.py @@ -6,7 +6,7 @@ lib_dict = { 'pygame': ['sdl'], 'sdl2': ['SDL2', 'SDL2_image', 'SDL2_mixer', 'SDL2_ttf'] } -sdl_libs = lib_dict[os.environ['BOOTSTRAP']] +sdl_libs = lib_dict[os.environ['BOOTSTRAP']] if os.environ['BOOTSTRAP'] == 'sdl2' else [] renpy_sound = Extension('android._android_sound', ['android/_android_sound.c', 'android/_android_sound_jni.c', ], diff --git a/recipes/cffi/__init__.py b/recipes/cffi/__init__.py index 0fc6018d..b4aa5ed2 100644 --- a/recipes/cffi/__init__.py +++ b/recipes/cffi/__init__.py @@ -1,36 +1,58 @@ -from pythonforandroid.recipe import CompiledComponentsPythonRecipe, Recipe -from os.path import join + +import os +from pythonforandroid.recipe import CompiledComponentsPythonRecipe class CffiRecipe(CompiledComponentsPythonRecipe): - name = 'cffi' - version = '1.11.0' - #url = 'https://pypi.python.org/packages/source/c/cffi/cffi-{version}.tar.gz' - url = 'https://pypi.python.org/packages/4e/32/4070bdf32812c89eb635c80880a5caa2e0189aa7999994c265577e5154f3/cffi-{version}.tar.gz' + name = 'cffi' + version = '1.11.5' + url = 'https://pypi.python.org/packages/source/c/cffi/cffi-{version}.tar.gz' - depends = [('python2', 'python3crystax'), 'setuptools', 'pycparser', 'libffi'] + depends = [('python2', 'python3crystax'), 'setuptools', 'pycparser', 'libffi'] - patches = ['disable-pkg-config.patch'] + patches = ['disable-pkg-config.patch'] - # call_hostpython_via_targetpython = False - install_in_hostpython = True + # call_hostpython_via_targetpython = False + install_in_hostpython = True - def get_recipe_env(self, arch=None): - env = super(CffiRecipe, self).get_recipe_env(arch) - libffi = self.get_recipe('libffi', self.ctx) - includes = libffi.get_include_dirs(arch) - env['CFLAGS'] = ' -I'.join([env.get('CFLAGS', '')] + includes) - env['LDFLAGS'] = (env.get('CFLAGS', '') + ' -L' + - self.ctx.get_libs_dir(arch.arch)) - env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' - env['PYTHONPATH'] = ':'.join([self.ctx.get_site_packages_dir(), env['BUILDLIB_PATH']]) - - target_python = Recipe.get_recipe('python2', self.ctx).get_build_dir(arch.arch) - env['PYTHON_ROOT'] = join(target_python, 'python-install') - env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' - env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython2.7' - - return env + def get_hostrecipe_env(self, arch=None): + # fixes missing ffi.h on some host systems (e.g. gentoo) + env = super(CffiRecipe, self).get_hostrecipe_env(arch) + libffi = self.get_recipe('libffi', self.ctx) + includes = libffi.get_include_dirs(arch) + env['FFI_INC'] = ",".join(includes) + return env + + def get_recipe_env(self, arch=None): + env = super(CffiRecipe, self).get_recipe_env(arch) + # sets linker to use the correct gcc (cross compiler) + env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' + libffi = self.get_recipe('libffi', self.ctx) + includes = libffi.get_include_dirs(arch) + env['CFLAGS'] = ' -I'.join([env.get('CFLAGS', '')] + includes) + env['LDFLAGS'] = (env.get('CFLAGS', '') + ' -L' + + self.ctx.get_libs_dir(arch.arch)) + env['LDFLAGS'] += ' -L{}'.format(os.path.join(self.ctx.bootstrap.build_dir, 'libs', arch.arch)) + + # required for libc and libdl + ndk_dir = self.ctx.ndk_platform + ndk_lib_dir = os.path.join(ndk_dir, 'usr', 'lib') + env['LDFLAGS'] += ' -L{}'.format(ndk_lib_dir) + env['LDFLAGS'] += " --sysroot={}".format(self.ctx.ndk_platform) + env['PYTHONPATH'] = ':'.join([ + self.ctx.get_site_packages_dir(), + env['BUILDLIB_PATH'], + ]) + if self.ctx.ndk == 'crystax': + # only keeps major.minor (discards patch) + python_version = self.ctx.python_recipe.version[0:3] + ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version) + env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch)) + env['LDFLAGS'] += ' -lpython{}m'.format(python_version) + # until `pythonforandroid/archs.py` gets merged upstream: + # https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6 + env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python) + return env -recipe = CffiRecipe() +recipe = CffiRecipe() \ No newline at end of file diff --git a/recipes/cffi/disable-pkg-config.patch b/recipes/cffi/disable-pkg-config.patch index 56346bb7..cf2abd5b 100644 --- a/recipes/cffi/disable-pkg-config.patch +++ b/recipes/cffi/disable-pkg-config.patch @@ -1,17 +1,18 @@ -diff -Naur cffi-1.4.2/setup.py b/setup.py ---- cffi-1.4.2/setup.py 2015-12-21 12:09:47.000000000 -0600 -+++ b/setup.py 2015-12-23 10:20:40.590622524 -0600 -@@ -5,8 +5,7 @@ +diff --git a/setup.py b/setup.py +index c1db368..57311c3 100644 +--- a/setup.py ++++ b/setup.py +@@ -5,8 +5,7 @@ import errno sources = ['c/_cffi_backend.c'] libraries = ['ffi'] -include_dirs = ['/usr/include/ffi', - '/usr/include/libffi'] # may be changed by pkg-config -+include_dirs = [] ++include_dirs = os.environ['FFI_INC'].split(",") if 'FFI_INC' in os.environ else [] define_macros = [] library_dirs = [] extra_compile_args = [] -@@ -67,14 +66,7 @@ +@@ -67,14 +66,7 @@ def ask_supports_thread(): sys.stderr.write("The above error message can be safely ignored\n") def use_pkg_config(): diff --git a/recipes/coincurve/__init__.py b/recipes/coincurve/__init__.py new file mode 100644 index 00000000..921655e5 --- /dev/null +++ b/recipes/coincurve/__init__.py @@ -0,0 +1,42 @@ +import os +from pythonforandroid.recipe import PythonRecipe, CompiledComponentsPythonRecipe + + +class CoincurveRecipe(CompiledComponentsPythonRecipe): + version = '7.1.0' + url = 'https://github.com/ofek/coincurve/archive/{version}.tar.gz' + call_hostpython_via_targetpython = False + depends = [('python2', 'python3crystax'), 'setuptools', + 'libffi', 'cffi', 'libsecp256k1'] + patches = [ + "cross_compile.patch", "drop_setup_requires.patch", + "find_lib.patch", "no-download.patch", "setup.py.patch"] + + def get_recipe_env(self, arch=None, with_flags_in_cc=True): + env = super(CoincurveRecipe, self).get_recipe_env(arch, with_flags_in_cc) + # sets linker to use the correct gcc (cross compiler) + env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' + libsecp256k1 = self.get_recipe('libsecp256k1', self.ctx) + libsecp256k1_dir = libsecp256k1.get_build_dir(arch.arch) + env['LDFLAGS'] += ' -L{}'.format(os.path.join(libsecp256k1_dir, '.libs')) + env['CFLAGS'] += ' -I' + os.path.join(libsecp256k1_dir, 'include') + # only keeps major.minor (discards patch) + python_version = self.ctx.python_recipe.version[0:3] + # required additional library and path for Crystax + if self.ctx.ndk == 'crystax': + ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version) + env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch)) + env['LDFLAGS'] += ' -lpython{}m'.format(python_version) + # until `pythonforandroid/archs.py` gets merged upstream: + # https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6 + env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python) + else: + env['PYTHON_ROOT'] = self.ctx.get_python_install_dir() + env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python{}'.format(python_version) + env['LDFLAGS'] += " -lpython{}".format(python_version) + env['LDFLAGS'] += " -lsecp256k1" + return env + + +recipe = CoincurveRecipe() + diff --git a/recipes/coincurve/cross_compile.patch b/recipes/coincurve/cross_compile.patch new file mode 100644 index 00000000..fbbdd49b --- /dev/null +++ b/recipes/coincurve/cross_compile.patch @@ -0,0 +1,12 @@ +diff --git a/setup.py b/setup.py +index c224fb2..bf925bd 100644 +--- a/setup.py ++++ b/setup.py +@@ -182,6 +182,7 @@ class build_clib(_build_clib): + '--disable-dependency-tracking', + '--with-pic', + '--enable-module-recovery', ++ "--host=%s" % os.environ['TOOLCHAIN_PREFIX'], + '--disable-jni', + '--prefix', + os.path.abspath(self.build_clib), diff --git a/recipes/coincurve/drop_setup_requires.patch b/recipes/coincurve/drop_setup_requires.patch new file mode 100644 index 00000000..9994b3fa --- /dev/null +++ b/recipes/coincurve/drop_setup_requires.patch @@ -0,0 +1,12 @@ +diff --git a/setup.py b/setup.py +index c224fb2..466e789 100644 +--- a/setup.py ++++ b/setup.py +@@ -250,7 +250,6 @@ else: + def has_c_libraries(self): + return not has_system_lib() + setup_kwargs = dict( +- setup_requires=['cffi>=1.3.0', 'pytest-runner>=2.6.2'], + ext_package='coincurve', + cffi_modules=['_cffi_build/build.py:ffi'], + cmdclass={ diff --git a/recipes/coincurve/find_lib.patch b/recipes/coincurve/find_lib.patch new file mode 100644 index 00000000..3d3c41d9 --- /dev/null +++ b/recipes/coincurve/find_lib.patch @@ -0,0 +1,13 @@ +diff --git a/setup_support.py b/setup_support.py +index e7a4f2e..72f0c4d 100644 +--- a/setup_support.py ++++ b/setup_support.py +@@ -68,6 +69,8 @@ def build_flags(library, type_, path): + + + def _find_lib(): ++ # we're picking up the recipe one ++ return True + from cffi import FFI + ffi = FFI() + try: diff --git a/recipes/coincurve/no-download.patch b/recipes/coincurve/no-download.patch new file mode 100644 index 00000000..fcf4d204 --- /dev/null +++ b/recipes/coincurve/no-download.patch @@ -0,0 +1,13 @@ +diff --git a/setup.py b/setup.py +index c224fb2..d5f6d1a 100644 +--- a/setup.py ++++ b/setup.py +@@ -51,6 +51,8 @@ if [int(i) for i in setuptools_version.split('.', 2)[:2]] < [3, 3]: + + + def download_library(command): ++ # we will use the custom libsecp256k1 recipe ++ return + if command.dry_run: + return + libdir = absolute('libsecp256k1') diff --git a/recipes/coincurve/setup.py.patch b/recipes/coincurve/setup.py.patch new file mode 100644 index 00000000..bdc7ab4d --- /dev/null +++ b/recipes/coincurve/setup.py.patch @@ -0,0 +1,22 @@ +From bf3a0684e9b0af29d9777f61d6e7e1d3cc0f2803 Mon Sep 17 00:00:00 2001 +From: Kieran Prasch +Date: Thu, 19 Jul 2018 14:11:48 -0700 +Subject: [PATCH] Exclude tests in setup.py + +--- + setup.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/setup.py b/setup.py +index 0b579f1..0a793ed 100644 +--- a/setup.py ++++ b/setup.py +@@ -277,7 +277,7 @@ def has_c_libraries(self): + install_requires=['asn1crypto', 'cffi>=1.3.0'], + tests_require=['pytest>=2.8.7'], + +- packages=find_packages(exclude=('_cffi_build', '_cffi_build.*', 'libsecp256k1')), ++ packages=find_packages(exclude=('_cffi_build', '_cffi_build.*', 'libsecp256k1', 'tests')), + + distclass=Distribution, + zip_safe=False, diff --git a/recipes/cryptography/__init__.py b/recipes/cryptography/__init__.py index d286924a..c69ad61c 100644 --- a/recipes/cryptography/__init__.py +++ b/recipes/cryptography/__init__.py @@ -1,30 +1,37 @@ from pythonforandroid.recipe import CompiledComponentsPythonRecipe, Recipe from os.path import dirname, join +import os class CryptographyRecipe(CompiledComponentsPythonRecipe): name = 'cryptography' - version = '2.2.2' + version = '2.3.1' url = 'https://github.com/pyca/cryptography/archive/{version}.tar.gz' - depends = [('python2', 'python3crystax'), 'openssl', 'idna', 'pyasn1', 'six', 'setuptools', 'enum34', 'ipaddress', 'cffi'] + depends = [('python2', 'python3crystax'), 'openssl', 'idna', 'pyasn1', 'six', 'setuptools', 'ipaddress', 'cffi'] call_hostpython_via_targetpython = False + patches = ['force-urandom.patch'] def get_recipe_env(self, arch): env = super(CryptographyRecipe, self).get_recipe_env(arch) r = self.get_recipe('openssl', self.ctx) openssl_dir = r.get_build_dir(arch.arch) - target_python = Recipe.get_recipe('python2', self.ctx).get_build_dir(arch.arch) - env['PYTHON_ROOT'] = self.ctx.get_python_install_dir() - env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' + \ - ' -I' + join(openssl_dir, 'include') + \ - ' -I' + join(target_python, 'Modules/_ctypes/libffi_arm_wince') + env['CFLAGS'] += ' -I' + join(openssl_dir, 'include') + ' -w' # Set linker to use the correct gcc env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' - env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + \ - ' -L' + openssl_dir + \ - ' -lpython2.7' + \ + env['LDFLAGS'] += ' -L' + openssl_dir + \ ' -lssl' + r.version + \ ' -lcrypto' + r.version - + + if self.ctx.ndk == 'crystax': + # only keeps major.minor (discards patch) + python_version = self.ctx.python_recipe.version[0:3] + ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version) + env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch)) + env['LDFLAGS'] += ' -lpython{}m'.format(python_version) + # until `pythonforandroid/archs.py` gets merged upstream: + # https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6 + env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python) + ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch)) + + return env recipe = CryptographyRecipe() diff --git a/recipes/cryptography/force-urandom.patch b/recipes/cryptography/force-urandom.patch new file mode 100644 index 00000000..dceeab34 --- /dev/null +++ b/recipes/cryptography/force-urandom.patch @@ -0,0 +1,11 @@ +--- x/src/_cffi_src/openssl/src/osrandom_engine.h 2018-09-25 23:19:08.303397032 +0100 ++++ y/src/_cffi_src/openssl/src/osrandom_engine.h 2018-09-25 23:21:45.945980819 +0100 +@@ -42,7 +42,7 @@ + #define CRYPTOGRAPHY_OSRANDOM_ENGINE CRYPTOGRAPHY_OSRANDOM_ENGINE_GETENTROPY + #elif defined(__linux__) && defined(SYS_getrandom) + /* Linux 3.4.17+ */ +- #define CRYPTOGRAPHY_OSRANDOM_ENGINE CRYPTOGRAPHY_OSRANDOM_ENGINE_GETRANDOM ++ #define CRYPTOGRAPHY_OSRANDOM_ENGINE CRYPTOGRAPHY_OSRANDOM_ENGINE_DEV_URANDOM // force /dev/urandom + #else + /* Keep this as last entry, fall back to /dev/urandom */ + #define CRYPTOGRAPHY_OSRANDOM_ENGINE CRYPTOGRAPHY_OSRANDOM_ENGINE_DEV_URANDOM diff --git a/recipes/gmpy/__init__.py b/recipes/gmpy/__init__.py index 23c60538..d96bdd09 100644 --- a/recipes/gmpy/__init__.py +++ b/recipes/gmpy/__init__.py @@ -27,10 +27,10 @@ class GmpyRecipe(CythonRecipe): libgmp_build_dir = Recipe.get_recipe('libgmp', self.ctx).get_build_dir(arch.arch) env['CFLAGS'] += ' -I%s' % (join(libgmp_build_dir, 'include')) - target_python = Recipe.get_recipe('python2', self.ctx).get_build_dir(arch.arch) + target_python = Recipe.get_recipe('python3crystax', self.ctx).get_build_dir(arch.arch) env['PYTHON_ROOT'] = join(target_python, 'python-install') - env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' - env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython2.7' + env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python3.6' + env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython3.6m' return env diff --git a/recipes/hostpython2/Setup b/recipes/hostpython2/Setup deleted file mode 100644 index 58207718..00000000 --- a/recipes/hostpython2/Setup +++ /dev/null @@ -1,495 +0,0 @@ -# -*- makefile -*- -# The file Setup is used by the makesetup script to construct the files -# Makefile and config.c, from Makefile.pre and config.c.in, -# respectively. The file Setup itself is initially copied from -# Setup.dist; once it exists it will not be overwritten, so you can edit -# Setup to your heart's content. Note that Makefile.pre is created -# from Makefile.pre.in by the toplevel configure script. - -# (VPATH notes: Setup and Makefile.pre are in the build directory, as -# are Makefile and config.c; the *.in and *.dist files are in the source -# directory.) - -# Each line in this file describes one or more optional modules. -# Modules enabled here will not be compiled by the setup.py script, -# so the file can be used to override setup.py's behavior. - -# Lines have the following structure: -# -# ... [ ...] [ ...] [ ...] -# -# is anything ending in .c (.C, .cc, .c++ are C++ files) -# is anything starting with -I, -D, -U or -C -# is anything ending in .a or beginning with -l or -L -# is anything else but should be a valid Python -# identifier (letters, digits, underscores, beginning with non-digit) -# -# (As the makesetup script changes, it may recognize some other -# arguments as well, e.g. *.so and *.sl as libraries. See the big -# case statement in the makesetup script.) -# -# Lines can also have the form -# -# = -# -# which defines a Make variable definition inserted into Makefile.in -# -# Finally, if a line contains just the word "*shared*" (without the -# quotes but with the stars), then the following modules will not be -# built statically. The build process works like this: -# -# 1. Build all modules that are declared as static in Modules/Setup, -# combine them into libpythonxy.a, combine that into python. -# 2. Build all modules that are listed as shared in Modules/Setup. -# 3. Invoke setup.py. That builds all modules that -# a) are not builtin, and -# b) are not listed in Modules/Setup, and -# c) can be build on the target -# -# Therefore, modules declared to be shared will not be -# included in the config.c file, nor in the list of objects to be -# added to the library archive, and their linker options won't be -# added to the linker options. Rules to create their .o files and -# their shared libraries will still be added to the Makefile, and -# their names will be collected in the Make variable SHAREDMODS. This -# is used to build modules as shared libraries. (They can be -# installed using "make sharedinstall", which is implied by the -# toplevel "make install" target.) (For compatibility, -# *noconfig* has the same effect as *shared*.) -# -# In addition, *static* explicitly declares the following modules to -# be static. Lines containing "*static*" and "*shared*" may thus -# alternate throughout this file. - -# NOTE: As a standard policy, as many modules as can be supported by a -# platform should be present. The distribution comes with all modules -# enabled that are supported by most platforms and don't require you -# to ftp sources from elsewhere. - - -# Some special rules to define PYTHONPATH. -# Edit the definitions below to indicate which options you are using. -# Don't add any whitespace or comments! - -# Directories where library files get installed. -# DESTLIB is for Python modules; MACHDESTLIB for shared libraries. -DESTLIB=$(LIBDEST) -MACHDESTLIB=$(BINLIBDEST) - -# NOTE: all the paths are now relative to the prefix that is computed -# at run time! - -# Standard path -- don't edit. -# No leading colon since this is the first entry. -# Empty since this is now just the runtime prefix. -DESTPATH= - -# Site specific path components -- should begin with : if non-empty -SITEPATH= - -# Standard path components for test modules -TESTPATH= - -# Path components for machine- or system-dependent modules and shared libraries -MACHDEPPATH=:plat-$(PLATDIR) -EXTRAMACHDEPPATH= - -# Path component for the Tkinter-related modules -# The TKPATH variable is always enabled, to save you the effort. -TKPATH=:lib-tk - -# Path component for old modules. -OLDPATH=:lib-old - -COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH)$(OLDPATH) -PYTHONPATH=$(COREPYTHONPATH) - - -# The modules listed here can't be built as shared libraries for -# various reasons; therefore they are listed here instead of in the -# normal order. - -# This only contains the minimal set of modules required to run the -# setup.py script in the root of the Python source tree. - -posix posixmodule.c # posix (UNIX) system calls -errno errnomodule.c # posix (UNIX) errno values -pwd pwdmodule.c # this is needed to find out the user's home dir - # if $HOME is not set -_sre _sre.c # Fredrik Lundh's new regular expressions -_codecs _codecsmodule.c # access to the builtin codecs and codec registry -_weakref _weakref.c # weak referencess - -# The zipimport module is always imported at startup. Having it as a -# builtin module avoids some bootstrapping problems and reduces overhead. -zipimport zipimport.c - -# The rest of the modules listed in this file are all commented out by -# default. Usually they can be detected and built as dynamically -# loaded modules by the new setup.py script added in Python 2.1. If -# you're on a platform that doesn't support dynamic loading, want to -# compile modules statically into the Python binary, or need to -# specify some odd set of compiler switches, you can uncomment the -# appropriate lines below. - -# ====================================================================== - -# The Python symtable module depends on .h files that setup.py doesn't track -_symtable symtablemodule.c - -# The SGI specific GL module: - -GLHACK=-Dclear=__GLclear -#gl glmodule.c cgensupport.c -I$(srcdir) $(GLHACK) -lgl -lX11 - -# Pure module. Cannot be linked dynamically. -# -DWITH_QUANTIFY, -DWITH_PURIFY, or -DWITH_ALL_PURE -#WHICH_PURE_PRODUCTS=-DWITH_ALL_PURE -#PURE_INCLS=-I/usr/local/include -#PURE_STUBLIBS=-L/usr/local/lib -lpurify_stubs -lquantify_stubs -#pure puremodule.c $(WHICH_PURE_PRODUCTS) $(PURE_INCLS) $(PURE_STUBLIBS) - -# Uncommenting the following line tells makesetup that all following -# modules are to be built as shared libraries (see above for more -# detail; also note that *static* reverses this effect): - -#*shared* - -# GNU readline. Unlike previous Python incarnations, GNU readline is -# now incorporated in an optional module, configured in the Setup file -# instead of by a configure script switch. You may have to insert a -# -L option pointing to the directory where libreadline.* lives, -# and you may have to change -ltermcap to -ltermlib or perhaps remove -# it, depending on your system -- see the GNU readline instructions. -# It's okay for this to be a shared library, too. - -#readline readline.c -lreadline -ltermcap - -# Modules that should always be present (non UNIX dependent): - -array arraymodule.c # array objects -cmath cmathmodule.c _math.c # -lm # complex math library functions -math mathmodule.c _math.c # -lm # math library functions, e.g. sin() -_struct _struct.c # binary structure packing/unpacking -time timemodule.c # -lm # time operations and variables -operator operator.c # operator.add() and similar goodies -#_testcapi _testcapimodule.c # Python C API test module -_random _randommodule.c # Random number generator -_collections _collectionsmodule.c # Container types -_heapq _heapqmodule.c # Heapq type -itertools itertoolsmodule.c # Functions creating iterators for efficient looping -strop stropmodule.c # String manipulations -_functools _functoolsmodule.c # Tools for working with functions and callable objects -_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator -#_pickle _pickle.c # pickle accelerator -datetime datetimemodule.c # date/time type -_bisect _bisectmodule.c # Bisection algorithms - -unicodedata unicodedata.c # static Unicode character database - -# access to ISO C locale support -#_locale _localemodule.c # -lintl - - -# Modules with some UNIX dependencies -- on by default: -# (If you have a really backward UNIX, select and socket may not be -# supported...) - -fcntl fcntlmodule.c # fcntl(2) and ioctl(2) -#spwd spwdmodule.c # spwd(3) -#grp grpmodule.c # grp(3) -select selectmodule.c # select(2); not on ancient System V - -# Memory-mapped files (also works on Win32). -#mmap mmapmodule.c - -# CSV file helper -#_csv _csv.c - -# Socket module helper for socket(2) -_socket socketmodule.c - -# Socket module helper for SSL support; you must comment out the other -# socket line above, and possibly edit the SSL variable: -#SSL=/usr/local/ssl -#_ssl _ssl.c \ -# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -# -L$(SSL)/lib -lssl -lcrypto - -# The crypt module is now disabled by default because it breaks builds -# on many systems (where -lcrypt is needed), e.g. Linux (I believe). -# -# First, look at Setup.config; configure may have set this for you. - -#crypt cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems - - -# Some more UNIX dependent modules -- off by default, since these -# are not supported by all UNIX systems: - -#nis nismodule.c -lnsl # Sun yellow pages -- not everywhere -#termios termios.c # Steen Lumholt's termios module -#resource resource.c # Jeremy Hylton's rlimit interface - - -# Multimedia modules -- off by default. -# These don't work for 64-bit platforms!!! -# #993173 says audioop works on 64-bit platforms, though. -# These represent audio samples or images as strings: - -#audioop audioop.c # Operations on audio samples -#imageop imageop.c # Operations on images - - -# Note that the _md5 and _sha modules are normally only built if the -# system does not have the OpenSSL libs containing an optimized version. - -# The _md5 module implements the RSA Data Security, Inc. MD5 -# Message-Digest Algorithm, described in RFC 1321. The necessary files -# md5.c and md5.h are included here. - -_md5 md5module.c md5.c - - -# The _sha module implements the SHA checksum algorithms. -# (NIST's Secure Hash Algorithms.) -_sha shamodule.c -_sha256 sha256module.c -_sha512 sha512module.c - - -# SGI IRIX specific modules -- off by default. - -# These module work on any SGI machine: - -# *** gl must be enabled higher up in this file *** -#fm fmmodule.c $(GLHACK) -lfm -lgl # Font Manager -#sgi sgimodule.c # sgi.nap() and a few more - -# This module requires the header file -# /usr/people/4Dgifts/iristools/include/izoom.h: -#imgfile imgfile.c -limage -lgutil -lgl -lm # Image Processing Utilities - - -# These modules require the Multimedia Development Option (I think): - -#al almodule.c -laudio # Audio Library -#cd cdmodule.c -lcdaudio -lds -lmediad # CD Audio Library -#cl clmodule.c -lcl -lawareaudio # Compression Library -#sv svmodule.c yuvconvert.c -lsvideo -lXext -lX11 # Starter Video - - -# The FORMS library, by Mark Overmars, implements user interface -# components such as dialogs and buttons using SGI's GL and FM -# libraries. You must ftp the FORMS library separately from -# ftp://ftp.cs.ruu.nl/pub/SGI/FORMS. It was tested with FORMS 2.2a. -# NOTE: if you want to be able to use FORMS and curses simultaneously -# (or both link them statically into the same binary), you must -# compile all of FORMS with the cc option "-Dclear=__GLclear". - -# The FORMS variable must point to the FORMS subdirectory of the forms -# toplevel directory: - -#FORMS=/ufs/guido/src/forms/FORMS -#fl flmodule.c -I$(FORMS) $(GLHACK) $(FORMS)/libforms.a -lfm -lgl - - -# SunOS specific modules -- off by default: - -#sunaudiodev sunaudiodev.c - - -# A Linux specific module -- off by default; this may also work on -# some *BSDs. - -#linuxaudiodev linuxaudiodev.c - - -# George Neville-Neil's timing module: - -#timing timingmodule.c - - -# The _tkinter module. -# -# The command for _tkinter is long and site specific. Please -# uncomment and/or edit those parts as indicated. If you don't have a -# specific extension (e.g. Tix or BLT), leave the corresponding line -# commented out. (Leave the trailing backslashes in! If you -# experience strange errors, you may want to join all uncommented -# lines and remove the backslashes -- the backslash interpretation is -# done by the shell's "read" command and it may not be implemented on -# every system. - -# *** Always uncomment this (leave the leading underscore in!): -# _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ -# *** Uncomment and edit to reflect where your Tcl/Tk libraries are: -# -L/usr/local/lib \ -# *** Uncomment and edit to reflect where your Tcl/Tk headers are: -# -I/usr/local/include \ -# *** Uncomment and edit to reflect where your X11 header files are: -# -I/usr/X11R6/include \ -# *** Or uncomment this for Solaris: -# -I/usr/openwin/include \ -# *** Uncomment and edit for Tix extension only: -# -DWITH_TIX -ltix8.1.8.2 \ -# *** Uncomment and edit for BLT extension only: -# -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \ -# *** Uncomment and edit for PIL (TkImaging) extension only: -# (See http://www.pythonware.com/products/pil/ for more info) -# -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ -# *** Uncomment and edit for TOGL extension only: -# -DWITH_TOGL togl.c \ -# *** Uncomment and edit to reflect your Tcl/Tk versions: -# -ltk8.2 -ltcl8.2 \ -# *** Uncomment and edit to reflect where your X11 libraries are: -# -L/usr/X11R6/lib \ -# *** Or uncomment this for Solaris: -# -L/usr/openwin/lib \ -# *** Uncomment these for TOGL extension only: -# -lGL -lGLU -lXext -lXmu \ -# *** Uncomment for AIX: -# -lld \ -# *** Always uncomment this; X11 libraries to link with: -# -lX11 - -# Lance Ellinghaus's syslog module -#syslog syslogmodule.c # syslog daemon interface - - -# Curses support, requring the System V version of curses, often -# provided by the ncurses library. e.g. on Linux, link with -lncurses -# instead of -lcurses). -# -# First, look at Setup.config; configure may have set this for you. - -#_curses _cursesmodule.c -lcurses -ltermcap -# Wrapper for the panel library that's part of ncurses and SYSV curses. -#_curses_panel _curses_panel.c -lpanel -lncurses - - -# Generic (SunOS / SVR4) dynamic loading module. -# This is not needed for dynamic loading of Python modules -- -# it is a highly experimental and dangerous device for calling -# *arbitrary* C functions in *arbitrary* shared libraries: - -#dl dlmodule.c - - -# Modules that provide persistent dictionary-like semantics. You will -# probably want to arrange for at least one of them to be available on -# your machine, though none are defined by default because of library -# dependencies. The Python module anydbm.py provides an -# implementation independent wrapper for these; dumbdbm.py provides -# similar functionality (but slower of course) implemented in Python. - -# The standard Unix dbm module has been moved to Setup.config so that -# it will be compiled as a shared library by default. Compiling it as -# a built-in module causes conflicts with the pybsddb3 module since it -# creates a static dependency on an out-of-date version of db.so. -# -# First, look at Setup.config; configure may have set this for you. - -#dbm dbmmodule.c # dbm(3) may require -lndbm or similar - -# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm: -# -# First, look at Setup.config; configure may have set this for you. - -#gdbm gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm - - -# Sleepycat Berkeley DB interface. -# -# This requires the Sleepycat DB code, see http://www.sleepycat.com/ -# The earliest supported version of that library is 3.0, the latest -# supported version is 4.0 (4.1 is specifically not supported, as that -# changes the semantics of transactional databases). A list of available -# releases can be found at -# -# http://www.sleepycat.com/update/index.html -# -# Edit the variables DB and DBLIBVERto point to the db top directory -# and the subdirectory of PORT where you built it. -#DB=/usr/local/BerkeleyDB.4.0 -#DBLIBVER=4.0 -#DBINC=$(DB)/include -#DBLIB=$(DB)/lib -#_bsddb _bsddb.c -I$(DBINC) -L$(DBLIB) -ldb-$(DBLIBVER) - -# Historical Berkeley DB 1.85 -# -# This module is deprecated; the 1.85 version of the Berkeley DB library has -# bugs that can cause data corruption. If you can, use later versions of the -# library instead, available from . - -#DB=/depot/sundry/src/berkeley-db/db.1.85 -#DBPORT=$(DB)/PORT/irix.5.3 -#bsddb185 bsddbmodule.c -I$(DBPORT)/include -I$(DBPORT) $(DBPORT)/libdb.a - - - -# Helper module for various ascii-encoders -binascii binascii.c - -# Fred Drake's interface to the Python parser -parser parsermodule.c - -# cStringIO and cPickle -cStringIO cStringIO.c -cPickle cPickle.c - - -# Lee Busby's SIGFPE modules. -# The library to link fpectl with is platform specific. -# Choose *one* of the options below for fpectl: - -# For SGI IRIX (tested on 5.3): -#fpectl fpectlmodule.c -lfpe - -# For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2): -# (Without the compiler you don't have -lsunmath.) -#fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm - -# For other systems: see instructions in fpectlmodule.c. -#fpectl fpectlmodule.c ... - -# Test module for fpectl. No extra libraries needed. -#fpetest fpetestmodule.c - -# Andrew Kuchling's zlib module. -# This require zlib 1.1.3 (or later). -# See http://www.gzip.org/zlib/ -zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz - -# Interface to the Expat XML parser -# -# Expat was written by James Clark and is now maintained by a group of -# developers on SourceForge; see www.libexpat.org for more -# information. The pyexpat module was written by Paul Prescod after a -# prototype by Jack Jansen. Source of Expat 1.95.2 is included in -# Modules/expat/. Usage of a system shared libexpat.so/expat.dll is -# not advised. -# -# More information on Expat can be found at www.libexpat.org. -# -pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI - - -# Hye-Shik Chang's CJKCodecs - -# multibytecodec is required for all the other CJK codec modules -#_multibytecodec cjkcodecs/multibytecodec.c - -#_codecs_cn cjkcodecs/_codecs_cn.c -#_codecs_hk cjkcodecs/_codecs_hk.c -#_codecs_iso2022 cjkcodecs/_codecs_iso2022.c -#_codecs_jp cjkcodecs/_codecs_jp.c -#_codecs_kr cjkcodecs/_codecs_kr.c -#_codecs_tw cjkcodecs/_codecs_tw.c - -# Example -- included for reference only: -# xx xxmodule.c - -# Another example -- the 'xxsubtype' module shows C-level subtyping in action -xxsubtype xxsubtype.c diff --git a/recipes/hostpython2/__init__.py b/recipes/hostpython2/__init__.py deleted file mode 100644 index 5deb45e9..00000000 --- a/recipes/hostpython2/__init__.py +++ /dev/null @@ -1,60 +0,0 @@ - -from pythonforandroid.toolchain import Recipe, shprint, current_directory, info, warning -from os.path import join, exists -from os import environ -import sh - - -class Hostpython2Recipe(Recipe): - version = '2.7.13' - url = 'http://python.org/ftp/python/{version}/Python-{version}.tar.xz' - name = 'hostpython2' - - conflicts = ['hostpython3'] - - def get_build_container_dir(self, arch=None): - choices = self.check_recipe_choices() - dir_name = '-'.join([self.name] + choices) - return join(self.ctx.build_dir, 'other_builds', dir_name, 'desktop') - - def get_build_dir(self, arch=None): - return join(self.get_build_container_dir(), self.name) - - def prebuild_arch(self, arch): - # Override hostpython Setup? - shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'), - join(self.get_build_dir(), 'Modules', 'Setup')) - - def build_arch(self, arch): - env = dict(environ) - with current_directory(self.get_build_dir()): - - if exists('hostpython'): - info('hostpython already exists, skipping build') - self.ctx.hostpython = join(self.get_build_dir(), - 'hostpython') - self.ctx.hostpgen = join(self.get_build_dir(), - 'hostpgen') - return - - configure = sh.Command('./configure') - - shprint(configure, _env=env) - shprint(sh.make, '-j5', _env=env) - - shprint(sh.mv, join('Parser', 'pgen'), 'hostpgen') - - if exists('python.exe'): - shprint(sh.mv, 'python.exe', 'hostpython') - elif exists('python'): - shprint(sh.mv, 'python', 'hostpython') - else: - warning('Unable to find the python executable after ' - 'hostpython build! Exiting.') - exit(1) - - self.ctx.hostpython = join(self.get_build_dir(), 'hostpython') - self.ctx.hostpgen = join(self.get_build_dir(), 'hostpgen') - - -recipe = Hostpython2Recipe() diff --git a/recipes/hostpython3crystax/__init__.py b/recipes/hostpython3crystax/__init__.py new file mode 100644 index 00000000..1559df2c --- /dev/null +++ b/recipes/hostpython3crystax/__init__.py @@ -0,0 +1,46 @@ +from pythonforandroid.toolchain import Recipe, shprint +from os.path import join +import sh + + +class Hostpython3Recipe(Recipe): + version = 'auto' # the version is taken from the python3crystax recipe + name = 'hostpython3crystax' + + conflicts = ['hostpython2'] + + def get_build_container_dir(self, arch=None): + choices = self.check_recipe_choices() + dir_name = '-'.join([self.name] + choices) + return join(self.ctx.build_dir, 'other_builds', dir_name, 'desktop') + + # def prebuild_armeabi(self): + # # Override hostpython Setup? + # shprint(sh.cp, join(self.get_recipe_dir(), 'Setup'), + # join(self.get_build_dir('armeabi'), 'Modules', 'Setup')) + + def get_build_dir(self, arch=None): + return join(self.get_build_container_dir(), self.name) + + def build_arch(self, arch): + """ + Creates expected build and symlinks system Python version. + """ + self.ctx.hostpython = '/usr/bin/false' + self.ctx.hostpgen = '/usr/bin/false' + # creates the sub buildir (used by other recipes) + # https://github.com/kivy/python-for-android/issues/1154 + sub_build_dir = join(self.get_build_dir(), 'build') + shprint(sh.mkdir, '-p', sub_build_dir) + python3crystax = self.get_recipe('python3crystax', self.ctx) + system_python = sh.which("python" + python3crystax.version) + if system_python is None: + raise OSError( + ('Trying to use python3crystax=={} but this Python version ' + 'is not installed locally.').format(python3crystax.version)) + link_dest = join(self.get_build_dir(), 'hostpython') + shprint(sh.ln, '-sf', system_python, link_dest) + + +recipe = Hostpython3Recipe() + diff --git a/recipes/idna/__init__.py b/recipes/idna/__init__.py new file mode 100644 index 00000000..a79c0f6d --- /dev/null +++ b/recipes/idna/__init__.py @@ -0,0 +1,14 @@ +from pythonforandroid.recipe import PythonRecipe + + +class IdnaRecipe(PythonRecipe): + name = 'idna' + version = '2.6' + url = 'https://github.com/kjd/idna/archive/v{version}.tar.gz' + + depends = [('python2', 'python3crystax'), 'setuptools'] + + call_hostpython_via_targetpython = False + + +recipe = IdnaRecipe() \ No newline at end of file diff --git a/recipes/incremental/__init__.py b/recipes/incremental/__init__.py index 4a61083a..10e6b10f 100644 --- a/recipes/incremental/__init__.py +++ b/recipes/incremental/__init__.py @@ -7,7 +7,7 @@ class IncrementalRecipe(PythonRecipe): version = '17.5.0' url = 'https://pypi.python.org/packages/8f/26/02c4016aa95f45479eea37c90c34f8fab6775732ae62587a874b619ca097/incremental-{version}.tar.gz' - depends = ['python2', 'setuptools'] + depends = [('python2', 'python3crystax'), 'setuptools'] call_hostpython_via_targetpython = False install_in_hostpython = True diff --git a/recipes/ipaddress/__init__.py b/recipes/ipaddress/__init__.py index 12a042a1..509ecc50 100644 --- a/recipes/ipaddress/__init__.py +++ b/recipes/ipaddress/__init__.py @@ -2,13 +2,11 @@ from pythonforandroid.recipe import PythonRecipe class IpaddressRecipe(PythonRecipe): - name = 'ipaddress' - version = '1.0.16' - url = 'https://pypi.python.org/packages/source/i/ipaddress/ipaddress-{version}.tar.gz' + name = 'ipaddress' + version = '1.0.16' + url = 'https://pypi.python.org/packages/source/i/ipaddress/ipaddress-{version}.tar.gz' - depends = ['python2'] - - call_hostpython_via_targetpython = False + depends = [('python2', 'python3crystax')] -recipe = IpaddressRecipe() +recipe = IpaddressRecipe() \ No newline at end of file diff --git a/recipes/libffi/Application.mk b/recipes/libffi/Application.mk new file mode 100644 index 00000000..599da111 --- /dev/null +++ b/recipes/libffi/Application.mk @@ -0,0 +1,3 @@ +APP_OPTIM := release +APP_ABI := all # or armeabi +APP_MODULES := libffi \ No newline at end of file diff --git a/recipes/libffi/__init__.py b/recipes/libffi/__init__.py new file mode 100644 index 00000000..6d808407 --- /dev/null +++ b/recipes/libffi/__init__.py @@ -0,0 +1,83 @@ +from os.path import exists, join +from pythonforandroid.recipe import Recipe +from pythonforandroid.logger import info, shprint +from pythonforandroid.util import current_directory +import sh + + +class LibffiRecipe(Recipe): + name = 'libffi' + version = 'v3.2.1' + url = 'https://github.com/atgreen/libffi/archive/{version}.zip' + + patches = ['remove-version-info.patch'] + + def get_host(self, arch): + with current_directory(self.get_build_dir(arch.arch)): + host = None + with open('Makefile') as f: + for line in f: + if line.startswith('host = '): + host = line.strip()[7:] + break + + if not host or not exists(host): + raise RuntimeError('failed to find build output! ({})' + .format(host)) + + return host + + def should_build(self, arch): + return not exists(join(self.ctx.get_libs_dir(arch.arch), 'libffi.so')) + + def build_arch(self, arch): + env = self.get_recipe_env(arch) + with current_directory(self.get_build_dir(arch.arch)): + if not exists('configure'): + shprint(sh.Command('./autogen.sh'), _env=env) + shprint(sh.Command('autoreconf'), '-vif', _env=env) + shprint(sh.Command('./configure'), + '--host=' + arch.toolchain_prefix, + '--prefix=' + self.ctx.get_python_install_dir(), + '--enable-shared', _env=env) + #'--with-sysroot={}'.format(self.ctx.ndk_platform), + #'--target={}'.format(arch.toolchain_prefix), + + # ndk 15 introduces unified headers required --sysroot and + # -isysroot for libraries and headers. libtool's head explodes + # trying to weave them into it's own magic. The result is a link + # failure tryng to link libc. We call make to compile the bits + # and manually link... + + try: + shprint(sh.make, '-j5', 'libffi.la', _env=env) + except sh.ErrorReturnCode_2: + info("make libffi.la failed as expected") + cc = sh.Command(env['CC'].split()[0]) + cflags = env['CC'].split()[1:] + + cflags.extend(['-march=armv7-a', '-mfloat-abi=softfp', '-mfpu=vfp', + '-mthumb', '-shared', '-fPIC', '-DPIC', + 'src/.libs/prep_cif.o', 'src/.libs/types.o', + 'src/.libs/raw_api.o', 'src/.libs/java_raw_api.o', + 'src/.libs/closures.o', 'src/arm/.libs/sysv.o', + 'src/arm/.libs/ffi.o', ] + ) + + ldflags = env['LDFLAGS'].split() + cflags.extend(ldflags) + cflags.extend(['-Wl,-soname', '-Wl,libffi.so', '-o', + '.libs/libffi.so']) + + with current_directory(self.get_host(arch)): + shprint(cc, *cflags, _env=env) + + shprint(sh.cp, '-t', self.ctx.get_libs_dir(arch.arch), + join(self.get_host(arch), '.libs', 'libffi.so')) + + def get_include_dirs(self, arch): + return [join(self.get_build_dir(arch.arch), self.get_host(arch), + 'include')] + + +recipe = LibffiRecipe() diff --git a/recipes/libffi/disable-mips-check.patch b/recipes/libffi/disable-mips-check.patch new file mode 100644 index 00000000..0f727ba4 --- /dev/null +++ b/recipes/libffi/disable-mips-check.patch @@ -0,0 +1,35 @@ +diff -Naur libffi/Android.mk b/Android.mk +--- libffi/Android.mk 2015-12-22 17:00:48.025478556 -0600 ++++ b/Android.mk 2015-12-22 17:02:23.999249390 -0600 +@@ -23,23 +23,20 @@ + # Build rules for the target. + # + +-# We only build ffi for mips. +-ifeq ($(TARGET_ARCH),mips) + +- include $(CLEAR_VARS) ++include $(CLEAR_VARS) + +- ffi_arch := $(TARGET_ARCH) +- ffi_os := $(TARGET_OS) ++ffi_arch := $(TARGET_ARCH) ++ffi_os := $(TARGET_OS) + +- # This include just keeps the nesting a bit saner. +- include $(LOCAL_PATH)/Libffi.mk ++# This include just keeps the nesting a bit saner. ++include $(LOCAL_PATH)/Libffi.mk + +- LOCAL_MODULE_TAGS := optional +- LOCAL_MODULE := libffi ++LOCAL_MODULE_TAGS := optional ++LOCAL_MODULE := libffi + +- include $(BUILD_SHARED_LIBRARY) ++include $(BUILD_SHARED_LIBRARY) + +-endif + + # Also include the rules for the test suite. + include external/libffi/testsuite/Android.mk diff --git a/recipes/libffi/remove-version-info.patch b/recipes/libffi/remove-version-info.patch new file mode 100644 index 00000000..7bdc11a6 --- /dev/null +++ b/recipes/libffi/remove-version-info.patch @@ -0,0 +1,12 @@ +diff -Naur libffi/Makefile.am b/Makefile.am +--- libffi/Makefile.am 2014-11-12 06:00:59.000000000 -0600 ++++ b/Makefile.am 2015-12-23 15:57:10.363148806 -0600 +@@ -249,7 +249,7 @@ + AM_CFLAGS += -DFFI_DEBUG + endif + +-libffi_la_LDFLAGS = -no-undefined -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(AM_LTLDFLAGS) ++libffi_la_LDFLAGS = -no-undefined -avoid-version $(LTLDFLAGS) $(AM_LTLDFLAGS) + + AM_CPPFLAGS = -I. -I$(top_srcdir)/include -Iinclude -I$(top_srcdir)/src + AM_CCASFLAGS = $(AM_CPPFLAGS) diff --git a/recipes/libgmp/__init__.py b/recipes/libgmp/__init__.py index a974f04e..7e5ba596 100644 --- a/recipes/libgmp/__init__.py +++ b/recipes/libgmp/__init__.py @@ -3,6 +3,7 @@ from os.path import exists, join, realpath from os import uname import glob import sh +import os class LibGMPRecipe(Recipe): @@ -18,8 +19,20 @@ class LibGMPRecipe(Recipe): env = super(LibGMPRecipe, self).get_recipe_env(arch) env['LIBGMP_LDFLAGS'] = '-avoid-version' - return env + ndk_dir = self.ctx.ndk_platform + ndk_lib_dir = os.path.join(ndk_dir, 'usr', 'lib') + if self.ctx.ndk == 'crystax': + crystax_lib_dir = os.path.join(self.ctx.ndk_dir, 'sources/crystax/libs', arch.arch) + env['CFLAGS'] = '{} -L{} -L{}'.format(env.get('CFLAGS'), crystax_lib_dir, ndk_lib_dir); + env['LDFLAGS'] += ' -L{}'.format(ndk_lib_dir) + env['LDFLAGS'] += " --sysroot={}".format(self.ctx.ndk_platform) + env['PYTHONPATH'] = ':'.join([ + self.ctx.get_site_packages_dir(), + env['BUILDLIB_PATH'], + ]) + + return env def build_arch(self, arch): with current_directory(self.get_build_dir(arch.arch)): diff --git a/recipes/libsecp256k1/__init__.py b/recipes/libsecp256k1/__init__.py new file mode 100644 index 00000000..69349d99 --- /dev/null +++ b/recipes/libsecp256k1/__init__.py @@ -0,0 +1,33 @@ +from pythonforandroid.toolchain import shprint, current_directory +from pythonforandroid.recipe import Recipe +from multiprocessing import cpu_count +from os.path import exists +import sh + + +class LibSecp256k1Recipe(Recipe): + + version = 'b0452e6' + url = 'https://github.com/bitcoin-core/secp256k1/archive/{version}.zip' + + def build_arch(self, arch): + super(LibSecp256k1Recipe, self).build_arch(arch) + env = self.get_recipe_env(arch) + with current_directory(self.get_build_dir(arch.arch)): + if not exists('configure'): + shprint(sh.Command('./autogen.sh'), _env=env) + shprint( + sh.Command('./configure'), + '--host=' + arch.toolchain_prefix, + '--prefix=' + self.ctx.get_python_install_dir(), + '--enable-shared', + '--enable-module-recovery', + '--enable-experimental', + '--enable-module-ecdh', + _env=env) + shprint(sh.make, '-j' + str(cpu_count()), _env=env) + libs = ['.libs/libsecp256k1.so'] + self.install_libs(arch, *libs) + + +recipe = LibSecp256k1Recipe() diff --git a/recipes/miniupnpc/__init__.py b/recipes/miniupnpc/__init__.py index 821ac7cc..a4b3a54d 100644 --- a/recipes/miniupnpc/__init__.py +++ b/recipes/miniupnpc/__init__.py @@ -24,8 +24,8 @@ class MiniupnpcRecipe(CythonRecipe): target_python = Recipe.get_recipe('python2', self.ctx).get_build_dir(arch.arch) env['PYTHON_ROOT'] = join(target_python, 'python-install') - env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' - env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython2.7' + env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python3.6' + env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython3.6m' return env diff --git a/recipes/netifaces/__init__.py b/recipes/netifaces/__init__.py index 0c651887..b34fc7bc 100644 --- a/recipes/netifaces/__init__.py +++ b/recipes/netifaces/__init__.py @@ -2,23 +2,31 @@ import glob from pythonforandroid.toolchain import CompiledComponentsPythonRecipe, Recipe from os.path import join +import os import sh class NetifacesRecipe(CompiledComponentsPythonRecipe): version = '0.10.7' url = 'https://files.pythonhosted.org/packages/81/39/4e9a026265ba944ddf1fea176dbb29e0fe50c43717ba4fcf3646d099fe38/netifaces-{version}.tar.gz' - depends = ['python2', 'setuptools'] + depends = [('python2', 'python3crystax'), 'setuptools'] call_hostpython_via_targetpython = False + patches = ['socket-ioctls.patch'] def get_recipe_env(self, arch): env = super(NetifacesRecipe, self).get_recipe_env(arch) - target_python = Recipe.get_recipe('python2', self.ctx).get_build_dir(arch.arch) - env['PYTHON_ROOT'] = join(target_python, 'python-install') env['LDSHARED'] = env['CC'] + ' -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions' - env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' - env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython2.7' + + if self.ctx.ndk == 'crystax': + # only keeps major.minor (discards patch) + python_version = self.ctx.python_recipe.version[0:3] + ndk_dir_python = os.path.join(self.ctx.ndk_dir, 'sources/python/', python_version) + env['LDFLAGS'] += ' -L{}'.format(os.path.join(ndk_dir_python, 'libs', arch.arch)) + env['LDFLAGS'] += ' -lpython{}m'.format(python_version) + # until `pythonforandroid/archs.py` gets merged upstream: + # https://github.com/kivy/python-for-android/pull/1250/files#diff-569e13021e33ced8b54385f55b49cbe6 + env['CFLAGS'] += ' -I{}/include/python/'.format(ndk_dir_python) return env diff --git a/recipes/netifaces/socket-ioctls.patch b/recipes/netifaces/socket-ioctls.patch new file mode 100644 index 00000000..4e6da707 --- /dev/null +++ b/recipes/netifaces/socket-ioctls.patch @@ -0,0 +1,29 @@ +--- a/netifaces.c 2018-09-25 21:26:48.238476102 +0100 ++++ b/netifaces.c 2018-09-25 21:55:14.201995669 +0100 +@@ -22,6 +22,10 @@ + obj = Py_InitModule3((name), (methods), (doc)); + #endif + ++#ifndef HAVE_SOCKET_IOCTLS ++#define HAVE_SOCKET_IOCTLS 1 ++#endif ++ + #ifndef WIN32 + + # include +@@ -178,12 +182,12 @@ + # include + # endif /* HAVE_GETIFADDRS */ + +-# if !HAVE_GETIFADDRS && (!HAVE_SOCKET_IOCTLS || !HAVE_SIOCGIFCONF) ++//# if !HAVE_GETIFADDRS && (!HAVE_SOCKET_IOCTLS || !HAVE_SIOCGIFCONF) + /* If the platform doesn't define, what we need, barf. If you're seeing this, + it means you need to write suitable code to retrieve interface information + on your system. */ +-# error You need to add code for your platform. +-# endif ++//# error You need to add code for your platform. ++//# endif + + #else /* defined(WIN32) */ + diff --git a/recipes/openssl/__init__.py b/recipes/openssl/__init__.py index 19084691..4152b04f 100644 --- a/recipes/openssl/__init__.py +++ b/recipes/openssl/__init__.py @@ -57,7 +57,7 @@ class OpenSSLRecipe(Recipe): break shprint(sh.make, 'clean', _env=env) - self.install_libs(arch, 'libssl' + self.version + '.so', - 'libcrypto' + self.version + '.so') + self.install_libs(arch, 'libssl.a', 'libssl' + self.version + '.so', + 'libcrypto.a', 'libcrypto' + self.version + '.so') recipe = OpenSSLRecipe() diff --git a/recipes/pyasn1/__init__.py b/recipes/pyasn1/__init__.py index 140a3bda..a10f7ca9 100644 --- a/recipes/pyasn1/__init__.py +++ b/recipes/pyasn1/__init__.py @@ -5,8 +5,7 @@ from pythonforandroid.toolchain import PythonRecipe class PyASN1Recipe(PythonRecipe): version = '0.4.2' url = 'https://pypi.python.org/packages/source/p/pyasn1/pyasn1-{version}.tar.gz' - depends = ['python2'] - - call_hostpython_via_targetpython = False + depends = [('python2', 'python3crystax')] + recipe = PyASN1Recipe() diff --git a/recipes/pyjnius/__init__.py b/recipes/pyjnius/__init__.py index d9eaf420..c336e8a3 100644 --- a/recipes/pyjnius/__init__.py +++ b/recipes/pyjnius/__init__.py @@ -18,10 +18,10 @@ class PyjniusRecipe(CythonRecipe): def get_recipe_env(self, arch): env = super(PyjniusRecipe, self).get_recipe_env(arch) - target_python = Recipe.get_recipe('python2', self.ctx).get_build_dir(arch.arch) + target_python = Recipe.get_recipe('python3crystax', self.ctx).get_build_dir(arch.arch) env['PYTHON_ROOT'] = join(target_python, 'python-install') - env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' - env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython2.7' + env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python3.6' + env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython3.6m' return env diff --git a/recipes/pyopenssl/__init__.py b/recipes/pyopenssl/__init__.py new file mode 100644 index 00000000..c3284705 --- /dev/null +++ b/recipes/pyopenssl/__init__.py @@ -0,0 +1,13 @@ +from pythonforandroid.recipe import PythonRecipe + + +class PyOpenSSLRecipe(PythonRecipe): + version = '17.4.0' + url = 'https://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-{version}.tar.gz' + depends = [('python2', 'python3crystax'), 'openssl', 'setuptools'] + site_packages_name = 'OpenSSL' + + call_hostpython_via_targetpython = False + + +recipe = PyOpenSSLRecipe() \ No newline at end of file diff --git a/recipes/python2/Setup.local-ssl b/recipes/python2/Setup.local-ssl deleted file mode 100644 index eadc6eae..00000000 --- a/recipes/python2/Setup.local-ssl +++ /dev/null @@ -1,4 +0,0 @@ -SSL= -_ssl _ssl.c \ - -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ - -L$(SSL) -lssl$(OPENSSL_VERSION) -lcrypto$(OPENSSL_VERSION) diff --git a/recipes/python2/__init__.py b/recipes/python2/__init__.py deleted file mode 100644 index 5842efcd..00000000 --- a/recipes/python2/__init__.py +++ /dev/null @@ -1,203 +0,0 @@ - -from pythonforandroid.recipe import TargetPythonRecipe, Recipe -from pythonforandroid.toolchain import shprint, current_directory, info -from pythonforandroid.patching import (is_linux, is_darwin, is_api_gt, - check_all, is_api_lt, is_ndk) -from os.path import exists, join, realpath -import sh - - -class Python2Recipe(TargetPythonRecipe): - version = "2.7.13" - url = 'http://python.org/ftp/python/{version}/Python-{version}.tar.xz' - name = 'python2' - - depends = ['hostpython2'] - conflicts = ['python3crystax', 'python3'] - opt_depends = ['openssl','sqlite3'] - - patches = [ # 2.7.13-specific patches - 'patches/Python-{version}-xcompile.patch', - 'patches/Python-{version}-ctypes-disable-wchar.patch', - 'patches/Python-{version}-ctypes-libffi-fix-configure.patch', - 'patches/ffi-config.sub-{version}.patch', - # 'patches/fix-locale-{version}.patch', - 'patches/fix-platform-{version}.patch', - 'patches/fix-platform-processor.patch', - 'patches/fix-pwdmodule.patch', - 'patches/modules-locales-{version}.patch', - - # Old 2.7.2 patches - 'patches/ctypes-find-library.patch', - 'patches/custom-loader.patch', - 'patches/disable-modules.patch', - 'patches/fix-dlfcn.patch', - 'patches/fix-dynamic-lookup.patch', - 'patches/fix-filesystemdefaultencoding.patch', - 'patches/fix-gethostbyaddr.patch', - 'patches/fix-termios.patch' ] - - from_crystax = False - - def build_arch(self, arch): - - if not exists(join(self.get_build_dir(arch.arch), 'libpython2.7.so')): - self.do_python_build(arch) - - if not exists(self.ctx.get_python_install_dir()): - shprint(sh.cp, '-a', join(self.get_build_dir(arch.arch), 'python-install'), - self.ctx.get_python_install_dir()) - - # This should be safe to run every time - info('Copying hostpython binary to targetpython folder') - shprint(sh.cp, self.ctx.hostpython, - join(self.ctx.get_python_install_dir(), 'bin', 'python.host')) - self.ctx.hostpython = join(self.ctx.get_python_install_dir(), 'bin', 'python.host') - - if not exists(join(self.ctx.get_libs_dir(arch.arch), 'libpython2.7.so')): - shprint(sh.cp, join(self.get_build_dir(arch.arch), 'libpython2.7.so'), self.ctx.get_libs_dir(arch.arch)) - - - # # if exists(join(self.get_build_dir(arch.arch), 'libpython2.7.so')): - # if exists(join(self.ctx.libs_dir, 'libpython2.7.so')): - # info('libpython2.7.so already exists, skipping python build.') - # if not exists(join(self.ctx.get_python_install_dir(), 'libpython2.7.so')): - # info('Copying python-install to dist-dependent location') - # shprint(sh.cp, '-a', 'python-install', self.ctx.get_python_install_dir()) - # self.ctx.hostpython = join(self.ctx.get_python_install_dir(), 'bin', 'python.host') - - # return - - def do_python_build(self, arch): - shprint(sh.cp, self.ctx.hostpython, self.get_build_dir(arch.arch)) - shprint(sh.cp, self.ctx.hostpgen, join(self.get_build_dir(arch.arch), 'Parser')) - hostpython = join(self.get_build_dir(arch.arch), 'hostpython') - hostpgen = join(self.get_build_dir(arch.arch), 'hostpython') - - with current_directory(self.get_build_dir(arch.arch)): - hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx) - shprint(sh.cp, join(hostpython_recipe.get_recipe_dir(), 'Setup'), 'Modules') - env = arch.get_env() - - # AND: Should probably move these to get_recipe_env for - # neatness, but the whole recipe needs tidying along these - # lines - env['HOSTARCH'] = 'arm-linux-androideabi' - env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout.decode('utf-8').split('\n')[0] - env['CFLAGS'] = ' '.join([env['CFLAGS'], '-DNO_MALLINFO']) - env['LDFLAGS'] += ' -Wl,--allow-multiple-definition' - - # TODO need to add a should_build that checks if optional - # dependencies have changed (possibly in a generic way) - if 'openssl' in self.ctx.recipe_build_order: - r = Recipe.get_recipe('openssl', self.ctx) - openssl_build_dir = r.get_build_dir(arch.arch) - setuplocal = join('Modules', 'Setup.local') - shprint(sh.cp, join(self.get_recipe_dir(), 'Setup.local-ssl'), setuplocal) - #shprint(sh.cat, join(self.get_recipe_dir(), 'Setup.local-ssl'), '>>', setuplocal) - shprint(sh.sed, '-i.backup', 's#^SSL=.*#SSL={}#'.format(openssl_build_dir), setuplocal) - env['OPENSSL_VERSION'] = r.version - env['CFLAGS'] += ' -I%s' % join(openssl_build_dir, 'include') - env['LDFLAGS'] += ' -L%s' % openssl_build_dir - - if 'sqlite3' in self.ctx.recipe_build_order: - # Include sqlite3 in python2 build - r = Recipe.get_recipe('sqlite3', self.ctx) - i = ' -I' + r.get_build_dir(arch.arch) - l = ' -L' + r.get_lib_dir(arch) + ' -lsqlite3' - # Insert or append to env - f = 'CPPFLAGS' - env[f] = env[f] + i if f in env else i - f = 'LDFLAGS' - env[f] = env[f] + l if f in env else l - - - with open('config.site', 'w') as fileh: - fileh.write(''' - ac_cv_file__dev_ptmx=no - ac_cv_file__dev_ptc=no - ac_cv_have_long_long_format=yes - ''') - - configure = sh.Command('./configure') - # AND: OFLAG isn't actually set, should it be? - shprint(configure, - 'CROSS_COMPILE_TARGET=yes', - 'CONFIG_SITE=config.site', - '--host={}'.format(env['HOSTARCH']), - '--build={}'.format(env['BUILDARCH']), - '--prefix={}'.format(realpath('./python-install')), - '--enable-shared', - '--enable-ipv6', - '--disable-toolbox-glue', - '--disable-framework', - '--with-system-ffi', - _env=env) - - # AND: tito left this comment in the original source. It's still true! - # FIXME, the first time, we got a error at: - # python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h - # /home/tito/code/python-for-android/build/python/Python-2.7.2/python: 1: Syntax error: word unexpected (expecting ")") - # because at this time, python is arm, not x86. even that, why /usr/include/netinet/in.h is used ? - # check if we can avoid this part. - - # Hardcoded, remove -I/usr/include/x86_64-linux-gnu from CCSHARED and CFLAGS - # to prevent overriding android arm sysroot includes - make = sh.Command(env['MAKE'].split(' ')[0]) - print('First install (expected to fail...') - try: - shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), - 'HOSTPGEN={}'.format(hostpgen), - 'CROSS_COMPILE_TARGET=yes', - 'INSTSONAME=libpython2.7.so', - _env=env) - except sh.ErrorReturnCode_2: - print('First python2 make failed. This is expected, trying again.') - - print('Make compile...') - shprint(make, '-j5', 'HOSTPYTHON={}'.format(hostpython), - 'HOSTPGEN={}'.format(hostpgen), - 'CROSS_COMPILE_TARGET=yes', - 'INSTSONAME=libpython2.7.so', - _env=env) - - print('Second install (expected to work)') - shprint(sh.touch, 'python.exe', 'python') - # -k added to keep going (need to figure out the reason for make: *** [libinstall] Error 1) - shprint(make, '-j5', 'install', 'HOSTPYTHON={}'.format(hostpython), - 'HOSTPGEN={}'.format(hostpgen), - 'CROSS_COMPILE_TARGET=yes', - 'INSTSONAME=libpython2.7.so', - _env=env) - - if is_darwin(): - shprint(sh.cp, join(self.get_recipe_dir(), 'patches', '_scproxy.py'), - join('python-install', 'Lib')) - shprint(sh.cp, join(self.get_recipe_dir(), 'patches', '_scproxy.py'), - join('python-install', 'lib', 'python2.7')) - - # reduce python - for dir_name in ('test', join('json', 'tests'), 'lib-tk', - join('sqlite3', 'test'), join('unittest, test'), - join('lib2to3', 'tests'), join('bsddb', 'tests'), - join('distutils', 'tests'), join('email', 'test'), - 'curses'): - shprint(sh.rm, '-rf', join('python-install', - 'lib', 'python2.7', dir_name)) - - - # info('Copying python-install to dist-dependent location') - # shprint(sh.cp, '-a', 'python-install', self.ctx.get_python_install_dir()) - - # print('Copying hostpython binary to targetpython folder') - # shprint(sh.cp, self.ctx.hostpython, - # join(self.ctx.get_python_install_dir(), 'bin', 'python.host')) - # self.ctx.hostpython = join(self.ctx.get_python_install_dir(), 'bin', 'python.host') - - - - # print('python2 build done, exiting for debug') - # exit(1) - - -recipe = Python2Recipe() diff --git a/recipes/python2/patches/Python-2.7.13-ctypes-disable-wchar.patch b/recipes/python2/patches/Python-2.7.13-ctypes-disable-wchar.patch deleted file mode 100644 index 9f8c4405..00000000 --- a/recipes/python2/patches/Python-2.7.13-ctypes-disable-wchar.patch +++ /dev/null @@ -1,76 +0,0 @@ ---- Python-2.7.9/Lib/ctypes/__init__.py.orig 2014-12-10 16:59:33.000000000 +0100 -+++ Python-2.7.9/Lib/ctypes/__init__.py 2016-03-17 14:00:15.636079979 +0100 -@@ -268,7 +268,7 @@ - if _os.name in ("nt", "ce"): - _win_functype_cache.clear() - # _SimpleCData.c_wchar_p_from_param -- POINTER(c_wchar).from_param = c_wchar_p.from_param -+ # POINTER(c_wchar).from_param = c_wchar_p.from_param - # _SimpleCData.c_char_p_from_param - POINTER(c_char).from_param = c_char_p.from_param - _pointer_type_cache[None] = c_void_p -@@ -288,29 +288,34 @@ - else: - set_conversion_mode("ascii", "strict") - -- class c_wchar_p(_SimpleCData): -- _type_ = "Z" -- -- class c_wchar(_SimpleCData): -- _type_ = "u" -- -- def create_unicode_buffer(init, size=None): -- """create_unicode_buffer(aString) -> character array -- create_unicode_buffer(anInteger) -> character array -- create_unicode_buffer(aString, anInteger) -> character array -- """ -- if isinstance(init, (str, unicode)): -- if size is None: -- size = len(init)+1 -- buftype = c_wchar * size -- buf = buftype() -- buf.value = init -- return buf -- elif isinstance(init, (int, long)): -- buftype = c_wchar * init -- buf = buftype() -- return buf -- raise TypeError(init) -+# The wchar stuff causes a crash on Android (the bionic C library doesn't -+# implement wchar_t anyway) -+# -+# class c_wchar_p(_SimpleCData): -+# _type_ = "Z" -+# -+# class c_wchar(_SimpleCData): -+# _type_ = "u" -+# -+# POINTER(c_wchar).from_param = c_wchar_p.from_param #_SimpleCData.c_wchar_p_from_param -+# -+# def create_unicode_buffer(init, size=None): -+# """create_unicode_buffer(aString) -> character array -+# create_unicode_buffer(anInteger) -> character array -+# create_unicode_buffer(aString, anInteger) -> character array -+# """ -+# if isinstance(init, (str, unicode)): -+# if size is None: -+# size = len(init)+1 -+# buftype = c_wchar * size -+# buf = buftype() -+# buf.value = init -+# return buf -+# elif isinstance(init, (int, long)): -+# buftype = c_wchar * init -+# buf = buftype() -+# return buf -+# raise TypeError(init) - - # XXX Deprecated - def SetPointerType(pointer, cls): -@@ -552,4 +557,4 @@ - elif sizeof(kind) == 8: c_uint64 = kind - del(kind) - --_reset_cache() -+_reset_cache() -\ No hay ningún carácter de nueva línea al final del fichero diff --git a/recipes/python2/patches/Python-2.7.13-ctypes-libffi-fix-configure.patch b/recipes/python2/patches/Python-2.7.13-ctypes-libffi-fix-configure.patch deleted file mode 100644 index 02d6f837..00000000 --- a/recipes/python2/patches/Python-2.7.13-ctypes-libffi-fix-configure.patch +++ /dev/null @@ -1,33 +0,0 @@ -diff -pruN Python-2.7.9.orig//Modules/_ctypes/libffi/configure.ac Python-2.7.9/Modules/_ctypes/libffi/configure.ac ---- Python-2.7.9.orig//Modules/_ctypes/libffi/configure.ac 2009-04-28 22:01:18.000000000 +0200 -+++ Python-2.7.9/Modules/_ctypes/libffi/configure.ac 2010-04-20 22:46:02.000000000 +0200 -@@ -409,7 +409,7 @@ - - AC_CONFIG_LINKS(include/ffitarget.h:src/$TARGETDIR/ffitarget.h) - --AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile testsuite/Makefile man/Makefile libffi.pc) -+AC_CONFIG_FILES(include/Makefile include/ffi.h Makefile ) - - AC_CONFIG_LINKS(include/ffi_common.h:include/ffi_common.h) - -diff -pruN Python-2.7.9.orig//Modules/_ctypes/libffi/Makefile.am Python-2.7.9/Modules/_ctypes/libffi/Makefile.am ---- Python-2.7.9.orig//Modules/_ctypes/libffi/Makefile.am 2008-03-04 21:09:11.000000000 +0100 -+++ Python-2.7.9/Modules/_ctypes/libffi/Makefile.am 2010-04-20 22:54:03.000000000 +0200 -@@ -2,7 +2,7 @@ - - AUTOMAKE_OPTIONS = foreign subdir-objects - --SUBDIRS = include testsuite man -+SUBDIRS = include - - EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \ - src/alpha/ffi.c src/alpha/osf.S src/alpha/ffitarget.h \ -@@ -34,8 +34,6 @@ - libtool-version ChangeLog.libffi m4/libtool.m4 \ - m4/lt~obsolete.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 - --info_TEXINFOS = doc/libffi.texi -- - ## ################################################################ - - ## \ No newline at end of file diff --git a/recipes/python2/patches/Python-2.7.13-xcompile.patch b/recipes/python2/patches/Python-2.7.13-xcompile.patch deleted file mode 100644 index b3c91087..00000000 --- a/recipes/python2/patches/Python-2.7.13-xcompile.patch +++ /dev/null @@ -1,237 +0,0 @@ ---- Python-2.7.13/configure 2016-12-17 21:05:07.000000000 +0100 -+++ Python-2.7.13-modified/configure 2017-08-10 12:59:24.094953614 +0100 -@@ -14927,7 +14927,7 @@ - $as_echo "$ac_cv_have_long_long_format" >&6; } - fi - --if test "$ac_cv_have_long_long_format" = yes -+if test "$ac_cv_have_long_long_format" != no - then - - $as_echo "#define PY_FORMAT_LONG_LONG \"ll\"" >>confdefs.h ---- Python-2.7.13/Makefile.pre.in 2016-12-17 21:05:06.000000000 +0100 -+++ Python-2.7.13-modified/Makefile.pre.in 2017-08-11 00:17:32.557907871 +0100 -@@ -199,6 +199,7 @@ - - PYTHON= python$(EXE) - BUILDPYTHON= python$(BUILDEXE) -+HOSTPYTHON= ./$(BUILDPYTHON) - - PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@ - _PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@ -@@ -246,6 +247,8 @@ - # Parser - PGEN= Parser/pgen$(EXE) - -+HOSTPGEN= $(PGEN) -+ - PSRCS= \ - Parser/acceler.c \ - Parser/grammar1.c \ -@@ -314,7 +317,7 @@ - - OPCODETARGETS_H= \ - $(srcdir)/Python/opcode_targets.h -- -+ - OPCODETARGETGEN= \ - $(srcdir)/Python/makeopcodetargets.py - -@@ -544,8 +547,8 @@ - *) quiet="";; \ - esac; \ - $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ -- _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \ -- $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build -+ _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' PYTHONXCPREFIX='$(DESTDIR)$(prefix)' \ -+ $(HOSTPYTHON) -E $(srcdir)/setup.py $$quiet build - - # Build static library - # avoid long command lines, same as LIBRARY_OBJS -@@ -681,7 +684,7 @@ - - $(GRAMMAR_H): @GENERATED_COMMENT@ $(GRAMMAR_INPUT) $(PGEN) - @$(MKDIR_P) Include -- $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) -+ $(HOSTPGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) - $(GRAMMAR_C): @GENERATED_COMMENT@ $(GRAMMAR_H) - touch $(GRAMMAR_C) - -@@ -1120,28 +1123,28 @@ - $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \ - $(DESTDIR)$(LIBDEST)/distutils/tests ; \ - fi -- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ -- $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ -+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ -+ $(HOSTPYTHON) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \ - -d $(LIBDEST) -f \ - -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ - $(DESTDIR)$(LIBDEST) -- PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ -- $(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ -+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ -+ $(HOSTPYTHON) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \ - -d $(LIBDEST) -f \ - -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \ - $(DESTDIR)$(LIBDEST) - -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ -- $(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ -+ $(HOSTPYTHON) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \ - -d $(LIBDEST)/site-packages -f \ - -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages - -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ -- $(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ -+ $(HOSTPYTHON) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \ - -d $(LIBDEST)/site-packages -f \ - -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages - -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ -- $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt -+ $(HOSTPYTHON) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt - -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \ -- $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt -+ $(HOSTPYTHON) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt - - # Create the PLATDIR source directory, if one wasn't distributed.. - $(srcdir)/Lib/$(PLATDIR): -@@ -1253,11 +1256,13 @@ - # Install the dynamically loadable modules - # This goes into $(exec_prefix) - sharedinstall: sharedmods -- $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \ -+ CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' \ -+ $(RUNSHARED) $(HOSTPYTHON) $(srcdir)/setup.py install \ -+ --skip-build \ - --prefix=$(prefix) \ -- --install-scripts=$(BINDIR) \ -- --install-platlib=$(DESTSHARED) \ -- --root=$(DESTDIR)/ -+ --install-scripts=$(DESTDIR)$(BINDIR) \ -+ --install-platlib=$(DESTDIR)$(DESTSHARED) \ -+ --root=/ - -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata.py* - - # Here are a couple of targets for MacOSX again, to install a full ---- Python-2.7.13/setup.py 2016-12-17 21:05:07.000000000 +0100 -+++ Python-2.7.13-modified/setup.py 2017-08-11 00:05:55.922860254 +0100 -@@ -17,7 +17,7 @@ - from distutils.command.install_lib import install_lib - from distutils.spawn import find_executable - --cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ -+cross_compiling = "_PYTHON_HOST_PLATFORM" in os.environ or ('PYTHONXCPREFIX' in os.environ) - - def get_platform(): - # cross build -@@ -175,6 +175,7 @@ - def __init__(self, dist): - build_ext.__init__(self, dist) - self.failed = [] -+ self.cross_compile = os.environ.get('CROSS_COMPILE_TARGET') == 'yes' - - def build_extensions(self): - -@@ -310,6 +311,14 @@ - (ext.name, sys.exc_info()[1])) - self.failed.append(ext.name) - return -+ -+ # Import check will not work when cross-compiling. -+ if os.environ.has_key('PYTHONXCPREFIX'): -+ self.announce( -+ 'WARNING: skipping import check for cross-compiled: "%s"' % -+ ext.name) -+ return -+ - # Workaround for Mac OS X: The Carbon-based modules cannot be - # reliably imported into a command-line Python - if 'Carbon' in ext.extra_link_args: -@@ -341,7 +350,7 @@ - self.get_ext_filename(self.get_ext_fullname(ext.name))) - - # Don't try to load extensions for cross builds -- if cross_compiling: -+ if cross_compiling or self.cross_compile: - return - - try: -@@ -455,11 +464,9 @@ - - def detect_modules(self): - # Ensure that /usr/local is always used -- if not cross_compiling: -+ if not cross_compiling or not self.cross_compile: - add_dir_to_list(self.compiler.library_dirs, '/usr/local/lib') - add_dir_to_list(self.compiler.include_dirs, '/usr/local/include') -- if cross_compiling: -- self.add_gcc_paths() - self.add_multiarch_paths() - - # Add paths specified in the environment variables LDFLAGS and -@@ -496,16 +503,17 @@ - for directory in reversed(options.dirs): - add_dir_to_list(dir_list, directory) - -- if os.path.normpath(sys.prefix) != '/usr' \ -- and not sysconfig.get_config_var('PYTHONFRAMEWORK'): -+ #if os.path.normpath(sys.prefix) != '/usr' \ -+ # and not sysconfig.get_config_var('PYTHONFRAMEWORK') \ -+ # and not self.cross_compile: - # OSX note: Don't add LIBDIR and INCLUDEDIR to building a framework - # (PYTHONFRAMEWORK is set) to avoid # linking problems when - # building a framework with different architectures than - # the one that is currently installed (issue #7473) -- add_dir_to_list(self.compiler.library_dirs, -- sysconfig.get_config_var("LIBDIR")) -- add_dir_to_list(self.compiler.include_dirs, -- sysconfig.get_config_var("INCLUDEDIR")) -+ #add_dir_to_list(self.compiler.library_dirs, -+ # sysconfig.get_config_var("LIBDIR")) -+ #add_dir_to_list(self.compiler.include_dirs, -+ # sysconfig.get_config_var("INCLUDEDIR")) - - try: - have_unicode = unicode -@@ -517,7 +525,7 @@ - # be assumed that no additional -I,-L directives are needed. - inc_dirs = self.compiler.include_dirs[:] - lib_dirs = self.compiler.library_dirs[:] -- if not cross_compiling: -+ if not cross_compiling or not self.cross_compile: - for d in ( - '/usr/include', - ): -@@ -526,7 +534,14 @@ - '/lib64', '/usr/lib64', - '/lib', '/usr/lib', - ): -- add_dir_to_list(lib_dirs, d) -+ add_dir_to_list(lib_dirs, d) -+ else: -+ cflags = os.environ.get('CFLAGS') -+ if cflags: -+ inc_dirs += [x[2:] for x in cflags.split() if x.startswith('-I')] -+ ldflags = os.environ.get('LDFLAGS') -+ if ldflags: -+ lib_dirs += [x[2:] for x in ldflags.split() if x.startswith('-L')] - exts = [] - missing = [] - -@@ -2048,8 +2063,15 @@ - - # Pass empty CFLAGS because we'll just append the resulting - # CFLAGS to Python's; -g or -O2 is to be avoided. -- cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ -- % (ffi_builddir, ffi_srcdir, " ".join(config_args)) -+ if cross_compiling or self.cross_compile: -+ cmd = "cd %s && env CFLAGS='' %s/configure --host=%s --build=%s %s" \ -+ % (ffi_builddir, ffi_srcdir, -+ os.environ.get('HOSTARCH'), -+ os.environ.get('BUILDARCH'), -+ " ".join(config_args)) -+ else: -+ cmd = "cd %s && env CFLAGS='' '%s/configure' %s" \ -+ % (ffi_builddir, ffi_srcdir, " ".join(config_args)) - - res = os.system(cmd) - if res or not os.path.exists(ffi_configfile): diff --git a/recipes/python2/patches/_scproxy.py b/recipes/python2/patches/_scproxy.py deleted file mode 100644 index 24239409..00000000 --- a/recipes/python2/patches/_scproxy.py +++ /dev/null @@ -1,10 +0,0 @@ -''' -Stub functions for _scproxy on iOS -No proxy is supported yet. -''' - -def _get_proxy_settings(): - return {'exclude_simple': 1} - -def _get_proxies(): - return {} diff --git a/recipes/python2/patches/ctypes-find-library.patch b/recipes/python2/patches/ctypes-find-library.patch deleted file mode 100644 index 6e32b8db..00000000 --- a/recipes/python2/patches/ctypes-find-library.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py -index 52b3520..01b13a9 100644 ---- a/Lib/ctypes/util.py -+++ b/Lib/ctypes/util.py -@@ -71,7 +71,23 @@ if os.name == "ce": - def find_library(name): - return name - --if os.name == "posix" and sys.platform == "darwin": -+# This patch overrides the find_library to look in the right places on -+# Android -+if True: -+ def find_library(name): -+ # Check the user app lib dir -+ app_root = os.path.abspath('./').split(os.path.sep)[0:4] -+ lib_search = os.path.sep.join(app_root) + os.path.sep + 'lib' -+ for filename in os.listdir(lib_search): -+ if filename.endswith('.so') and name in filename: -+ return lib_search + os.path.sep + filename -+ # Check the normal Android system libraries -+ for filename in os.listdir('/system/lib'): -+ if filename.endswith('.so') and name in filename: -+ return lib_search + os.path.sep + filename -+ return None -+ -+elif os.name == "posix" and sys.platform == "darwin": - from ctypes.macholib.dyld import dyld_find as _dyld_find - def find_library(name): - possible = ['lib%s.dylib' % name, \ No newline at end of file diff --git a/recipes/python2/patches/custom-loader.patch b/recipes/python2/patches/custom-loader.patch deleted file mode 100644 index b5d40582..00000000 --- a/recipes/python2/patches/custom-loader.patch +++ /dev/null @@ -1,67 +0,0 @@ ---- Python-2.7.9.orig/Python/dynload_shlib.c 2010-05-09 16:46:46.000000000 +0200 -+++ Python-2.7.9/Python/dynload_shlib.c 2011-04-20 17:52:12.000000000 +0200 -@@ -6,6 +6,7 @@ - - #include - #include -+#include - - #if defined(__NetBSD__) - #include -@@ -75,6 +76,21 @@ - char pathbuf[260]; - int dlopenflags=0; - -+ static void *libpymodules = NULL; -+ void *rv = NULL; -+ -+ /* Ensure we have access to libpymodules. */ -+ if (libpymodules == NULL) { -+ printf("ANDROID_APP_PATH = %s\n", getenv("ANDROID_APP_PATH")); -+ PyOS_snprintf(pathbuf, sizeof(pathbuf), "%s/libpymodules.so", getenv("ANDROID_APP_PATH")); -+ libpymodules = dlopen(pathbuf, RTLD_NOW); -+ -+ if (libpymodules == NULL) { -+ //abort(); -+ } -+ } -+ -+ - if (strchr(pathname, '/') == NULL) { - /* Prefix bare filename with "./" */ - PyOS_snprintf(pathbuf, sizeof(pathbuf), "./%-.255s", pathname); -@@ -84,6 +100,17 @@ - PyOS_snprintf(funcname, sizeof(funcname), - LEAD_UNDERSCORE "init%.200s", shortname); - -+ -+ /* Read symbols that have been linked into the main binary. */ -+ -+ if (libpymodules) { -+ rv = dlsym(libpymodules, funcname); -+ if (rv != NULL) { -+ return rv; -+ } -+ } -+ -+ - if (fp != NULL) { - int i; - struct stat statb; ---- Python-2.7.2.orig/Python/pythonrun.c 2010-10-29 05:45:34.000000000 +0200 -+++ Python-2.7.2/Python/pythonrun.c 2011-04-20 17:52:12.000000000 +0200 -@@ -254,9 +254,13 @@ - _PyGILState_Init(interp, tstate); - #endif /* WITH_THREAD */ - -+ /* For PGS4A, we don't want to call initsite, as we won't have the -+ library path set up until start.pyx finishes running. */ -+#if 0 - if (!Py_NoSiteFlag) - initsite(); /* Module site */ -- -+#endif -+ - if ((p = Py_GETENV("PYTHONIOENCODING")) && *p != '\0') { - p = icodeset = codeset = strdup(p); - free_codeset = 1; \ No newline at end of file diff --git a/recipes/python2/patches/disable-modules.patch b/recipes/python2/patches/disable-modules.patch deleted file mode 100644 index f89a252f..00000000 --- a/recipes/python2/patches/disable-modules.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Python-2.7.13/setup.py 2016-12-17 21:05:07.000000000 +0100 -+++ Python-2.7.13/setup.py.disabled 2017-08-10 19:47:06.658219931 +0100 -@@ -33,7 +33,7 @@ - COMPILED_WITH_PYDEBUG = ('--with-pydebug' in sysconfig.get_config_var("CONFIG_ARGS")) - - # This global variable is used to hold the list of modules to be disabled. --disabled_module_list = [] -+disabled_module_list = ['_bsddb','_curses','_curses_panel','_locale','_tkinter','bsddb185','bz2','crypt','dbm','dl','gdbm','imageop','linuxaudiodev','nis','ossaudiodev','readline','spwd','sunaudiodev'] - - def add_dir_to_list(dirlist, dir): - """Add the directory 'dir' to the list 'dirlist' (at the front) if diff --git a/recipes/python2/patches/ffi-config.sub-2.7.13.patch b/recipes/python2/patches/ffi-config.sub-2.7.13.patch deleted file mode 100644 index db0ebbb1..00000000 --- a/recipes/python2/patches/ffi-config.sub-2.7.13.patch +++ /dev/null @@ -1,1792 +0,0 @@ ---- Python-2.7.9/Modules/_ctypes/libffi/config.sub.orig 2014-12-10 16:59:51.000000000 +0100 -+++ Python-2.7.9/Modules/_ctypes/libffi/config.sub 2015-05-03 18:58:32.633287511 +0200 -@@ -1,1788 +1,2 @@ - #! /bin/sh --# Configuration validation subroutine script. --# Copyright 1992-2013 Free Software Foundation, Inc. -- --timestamp='2013-04-24' -- --# This file is free software; you can redistribute it and/or modify it --# under the terms of the GNU General Public License as published by --# the Free Software Foundation; either version 3 of the License, or --# (at your option) any later version. --# --# This program is distributed in the hope that it will be useful, but --# WITHOUT ANY WARRANTY; without even the implied warranty of --# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --# General Public License for more details. --# --# You should have received a copy of the GNU General Public License --# along with this program; if not, see . --# --# As a special exception to the GNU General Public License, if you --# distribute this file as part of a program that contains a --# configuration script generated by Autoconf, you may include it under --# the same distribution terms that you use for the rest of that --# program. This Exception is an additional permission under section 7 --# of the GNU General Public License, version 3 ("GPLv3"). -- -- --# Please send patches with a ChangeLog entry to config-patches@gnu.org. --# --# Configuration subroutine to validate and canonicalize a configuration type. --# Supply the specified configuration type as an argument. --# If it is invalid, we print an error message on stderr and exit with code 1. --# Otherwise, we print the canonical config type on stdout and succeed. -- --# You can get the latest version of this script from: --# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD -- --# This file is supposed to be the same for all GNU packages --# and recognize all the CPU types, system types and aliases --# that are meaningful with *any* GNU software. --# Each package is responsible for reporting which valid configurations --# it does not support. The user should be able to distinguish --# a failure to support a valid configuration from a meaningless --# configuration. -- --# The goal of this file is to map all the various variations of a given --# machine specification into a single specification in the form: --# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM --# or in some cases, the newer four-part form: --# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM --# It is wrong to echo any other type of specification. -- --me=`echo "$0" | sed -e 's,.*/,,'` -- --usage="\ --Usage: $0 [OPTION] CPU-MFR-OPSYS -- $0 [OPTION] ALIAS -- --Canonicalize a configuration name. -- --Operation modes: -- -h, --help print this help, then exit -- -t, --time-stamp print date of last modification, then exit -- -v, --version print version number, then exit -- --Report bugs and patches to ." -- --version="\ --GNU config.sub ($timestamp) -- --Copyright 1992-2013 Free Software Foundation, Inc. -- --This is free software; see the source for copying conditions. There is NO --warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." -- --help=" --Try \`$me --help' for more information." -- --# Parse command line --while test $# -gt 0 ; do -- case $1 in -- --time-stamp | --time* | -t ) -- echo "$timestamp" ; exit ;; -- --version | -v ) -- echo "$version" ; exit ;; -- --help | --h* | -h ) -- echo "$usage"; exit ;; -- -- ) # Stop option processing -- shift; break ;; -- - ) # Use stdin as input. -- break ;; -- -* ) -- echo "$me: invalid option $1$help" -- exit 1 ;; -- -- *local*) -- # First pass through any local machine types. -- echo $1 -- exit ;; -- -- * ) -- break ;; -- esac --done -- --case $# in -- 0) echo "$me: missing argument$help" >&2 -- exit 1;; -- 1) ;; -- *) echo "$me: too many arguments$help" >&2 -- exit 1;; --esac -- --# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). --# Here we must recognize all the valid KERNEL-OS combinations. --maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` --case $maybe_os in -- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ -- linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ -- knetbsd*-gnu* | netbsd*-gnu* | \ -- kopensolaris*-gnu* | \ -- storm-chaos* | os2-emx* | rtmk-nova*) -- os=-$maybe_os -- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` -- ;; -- android-linux) -- os=-linux-android -- basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown -- ;; -- *) -- basic_machine=`echo $1 | sed 's/-[^-]*$//'` -- if [ $basic_machine != $1 ] -- then os=`echo $1 | sed 's/.*-/-/'` -- else os=; fi -- ;; --esac -- --### Let's recognize common machines as not being operating systems so --### that things like config.sub decstation-3100 work. We also --### recognize some manufacturers as not being operating systems, so we --### can provide default operating systems below. --case $os in -- -sun*os*) -- # Prevent following clause from handling this invalid input. -- ;; -- -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -- -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -- -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -- -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -- -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -- -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -- -apple | -axis | -knuth | -cray | -microblaze*) -- os= -- basic_machine=$1 -- ;; -- -bluegene*) -- os=-cnk -- ;; -- -sim | -cisco | -oki | -wec | -winbond) -- os= -- basic_machine=$1 -- ;; -- -scout) -- ;; -- -wrs) -- os=-vxworks -- basic_machine=$1 -- ;; -- -chorusos*) -- os=-chorusos -- basic_machine=$1 -- ;; -- -chorusrdb) -- os=-chorusrdb -- basic_machine=$1 -- ;; -- -hiux*) -- os=-hiuxwe2 -- ;; -- -sco6) -- os=-sco5v6 -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -sco5) -- os=-sco3.2v5 -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -sco4) -- os=-sco3.2v4 -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -sco3.2.[4-9]*) -- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -sco3.2v[4-9]*) -- # Don't forget version if it is 3.2v4 or newer. -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -sco5v6*) -- # Don't forget version if it is 3.2v4 or newer. -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -sco*) -- os=-sco3.2v2 -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -udk*) -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -isc) -- os=-isc2.2 -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -clix*) -- basic_machine=clipper-intergraph -- ;; -- -isc*) -- basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` -- ;; -- -lynx*178) -- os=-lynxos178 -- ;; -- -lynx*5) -- os=-lynxos5 -- ;; -- -lynx*) -- os=-lynxos -- ;; -- -ptx*) -- basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` -- ;; -- -windowsnt*) -- os=`echo $os | sed -e 's/windowsnt/winnt/'` -- ;; -- -psos*) -- os=-psos -- ;; -- -mint | -mint[0-9]*) -- basic_machine=m68k-atari -- os=-mint -- ;; --esac -- --# Decode aliases for certain CPU-COMPANY combinations. --case $basic_machine in -- # Recognize the basic CPU types without company name. -- # Some are omitted here because they have special meanings below. -- 1750a | 580 \ -- | a29k \ -- | aarch64 | aarch64_be \ -- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ -- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ -- | am33_2.0 \ -- | arc | arceb \ -- | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ -- | avr | avr32 \ -- | be32 | be64 \ -- | bfin \ -- | c4x | clipper \ -- | d10v | d30v | dlx | dsp16xx \ -- | epiphany \ -- | fido | fr30 | frv \ -- | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ -- | hexagon \ -- | i370 | i860 | i960 | ia64 \ -- | ip2k | iq2000 \ -- | le32 | le64 \ -- | lm32 \ -- | m32c | m32r | m32rle | m68000 | m68k | m88k \ -- | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ -- | mips | mipsbe | mipseb | mipsel | mipsle \ -- | mips16 \ -- | mips64 | mips64el \ -- | mips64octeon | mips64octeonel \ -- | mips64orion | mips64orionel \ -- | mips64r5900 | mips64r5900el \ -- | mips64vr | mips64vrel \ -- | mips64vr4100 | mips64vr4100el \ -- | mips64vr4300 | mips64vr4300el \ -- | mips64vr5000 | mips64vr5000el \ -- | mips64vr5900 | mips64vr5900el \ -- | mipsisa32 | mipsisa32el \ -- | mipsisa32r2 | mipsisa32r2el \ -- | mipsisa64 | mipsisa64el \ -- | mipsisa64r2 | mipsisa64r2el \ -- | mipsisa64sb1 | mipsisa64sb1el \ -- | mipsisa64sr71k | mipsisa64sr71kel \ -- | mipsr5900 | mipsr5900el \ -- | mipstx39 | mipstx39el \ -- | mn10200 | mn10300 \ -- | moxie \ -- | mt \ -- | msp430 \ -- | nds32 | nds32le | nds32be \ -- | nios | nios2 | nios2eb | nios2el \ -- | ns16k | ns32k \ -- | open8 \ -- | or1k | or32 \ -- | pdp10 | pdp11 | pj | pjl \ -- | powerpc | powerpc64 | powerpc64le | powerpcle \ -- | pyramid \ -- | rl78 | rx \ -- | score \ -- | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ -- | sh64 | sh64le \ -- | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ -- | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ -- | spu \ -- | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ -- | ubicom32 \ -- | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ -- | we32k \ -- | x86 | xc16x | xstormy16 | xtensa \ -- | z8k | z80) -- basic_machine=$basic_machine-unknown -- ;; -- c54x) -- basic_machine=tic54x-unknown -- ;; -- c55x) -- basic_machine=tic55x-unknown -- ;; -- c6x) -- basic_machine=tic6x-unknown -- ;; -- m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) -- basic_machine=$basic_machine-unknown -- os=-none -- ;; -- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) -- ;; -- ms1) -- basic_machine=mt-unknown -- ;; -- -- strongarm | thumb | xscale) -- basic_machine=arm-unknown -- ;; -- xgate) -- basic_machine=$basic_machine-unknown -- os=-none -- ;; -- xscaleeb) -- basic_machine=armeb-unknown -- ;; -- -- xscaleel) -- basic_machine=armel-unknown -- ;; -- -- # We use `pc' rather than `unknown' -- # because (1) that's what they normally are, and -- # (2) the word "unknown" tends to confuse beginning users. -- i*86 | x86_64) -- basic_machine=$basic_machine-pc -- ;; -- # Object if more than one company name word. -- *-*-*) -- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 -- exit 1 -- ;; -- # Recognize the basic CPU types with company name. -- 580-* \ -- | a29k-* \ -- | aarch64-* | aarch64_be-* \ -- | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ -- | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ -- | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ -- | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ -- | avr-* | avr32-* \ -- | be32-* | be64-* \ -- | bfin-* | bs2000-* \ -- | c[123]* | c30-* | [cjt]90-* | c4x-* \ -- | clipper-* | craynv-* | cydra-* \ -- | d10v-* | d30v-* | dlx-* \ -- | elxsi-* \ -- | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ -- | h8300-* | h8500-* \ -- | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ -- | hexagon-* \ -- | i*86-* | i860-* | i960-* | ia64-* \ -- | ip2k-* | iq2000-* \ -- | le32-* | le64-* \ -- | lm32-* \ -- | m32c-* | m32r-* | m32rle-* \ -- | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ -- | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ -- | microblaze-* | microblazeel-* \ -- | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ -- | mips16-* \ -- | mips64-* | mips64el-* \ -- | mips64octeon-* | mips64octeonel-* \ -- | mips64orion-* | mips64orionel-* \ -- | mips64r5900-* | mips64r5900el-* \ -- | mips64vr-* | mips64vrel-* \ -- | mips64vr4100-* | mips64vr4100el-* \ -- | mips64vr4300-* | mips64vr4300el-* \ -- | mips64vr5000-* | mips64vr5000el-* \ -- | mips64vr5900-* | mips64vr5900el-* \ -- | mipsisa32-* | mipsisa32el-* \ -- | mipsisa32r2-* | mipsisa32r2el-* \ -- | mipsisa64-* | mipsisa64el-* \ -- | mipsisa64r2-* | mipsisa64r2el-* \ -- | mipsisa64sb1-* | mipsisa64sb1el-* \ -- | mipsisa64sr71k-* | mipsisa64sr71kel-* \ -- | mipsr5900-* | mipsr5900el-* \ -- | mipstx39-* | mipstx39el-* \ -- | mmix-* \ -- | mt-* \ -- | msp430-* \ -- | nds32-* | nds32le-* | nds32be-* \ -- | nios-* | nios2-* | nios2eb-* | nios2el-* \ -- | none-* | np1-* | ns16k-* | ns32k-* \ -- | open8-* \ -- | orion-* \ -- | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ -- | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ -- | pyramid-* \ -- | rl78-* | romp-* | rs6000-* | rx-* \ -- | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ -- | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ -- | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ -- | sparclite-* \ -- | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ -- | tahoe-* \ -- | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ -- | tile*-* \ -- | tron-* \ -- | ubicom32-* \ -- | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ -- | vax-* \ -- | we32k-* \ -- | x86-* | x86_64-* | xc16x-* | xps100-* \ -- | xstormy16-* | xtensa*-* \ -- | ymp-* \ -- | z8k-* | z80-*) -- ;; -- # Recognize the basic CPU types without company name, with glob match. -- xtensa*) -- basic_machine=$basic_machine-unknown -- ;; -- # Recognize the various machine names and aliases which stand -- # for a CPU type and a company and sometimes even an OS. -- 386bsd) -- basic_machine=i386-unknown -- os=-bsd -- ;; -- 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) -- basic_machine=m68000-att -- ;; -- 3b*) -- basic_machine=we32k-att -- ;; -- a29khif) -- basic_machine=a29k-amd -- os=-udi -- ;; -- abacus) -- basic_machine=abacus-unknown -- ;; -- adobe68k) -- basic_machine=m68010-adobe -- os=-scout -- ;; -- alliant | fx80) -- basic_machine=fx80-alliant -- ;; -- altos | altos3068) -- basic_machine=m68k-altos -- ;; -- am29k) -- basic_machine=a29k-none -- os=-bsd -- ;; -- amd64) -- basic_machine=x86_64-pc -- ;; -- amd64-*) -- basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- amdahl) -- basic_machine=580-amdahl -- os=-sysv -- ;; -- amiga | amiga-*) -- basic_machine=m68k-unknown -- ;; -- amigaos | amigados) -- basic_machine=m68k-unknown -- os=-amigaos -- ;; -- amigaunix | amix) -- basic_machine=m68k-unknown -- os=-sysv4 -- ;; -- apollo68) -- basic_machine=m68k-apollo -- os=-sysv -- ;; -- apollo68bsd) -- basic_machine=m68k-apollo -- os=-bsd -- ;; -- aros) -- basic_machine=i386-pc -- os=-aros -- ;; -- aux) -- basic_machine=m68k-apple -- os=-aux -- ;; -- balance) -- basic_machine=ns32k-sequent -- os=-dynix -- ;; -- blackfin) -- basic_machine=bfin-unknown -- os=-linux -- ;; -- blackfin-*) -- basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` -- os=-linux -- ;; -- bluegene*) -- basic_machine=powerpc-ibm -- os=-cnk -- ;; -- c54x-*) -- basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- c55x-*) -- basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- c6x-*) -- basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- c90) -- basic_machine=c90-cray -- os=-unicos -- ;; -- cegcc) -- basic_machine=arm-unknown -- os=-cegcc -- ;; -- convex-c1) -- basic_machine=c1-convex -- os=-bsd -- ;; -- convex-c2) -- basic_machine=c2-convex -- os=-bsd -- ;; -- convex-c32) -- basic_machine=c32-convex -- os=-bsd -- ;; -- convex-c34) -- basic_machine=c34-convex -- os=-bsd -- ;; -- convex-c38) -- basic_machine=c38-convex -- os=-bsd -- ;; -- cray | j90) -- basic_machine=j90-cray -- os=-unicos -- ;; -- craynv) -- basic_machine=craynv-cray -- os=-unicosmp -- ;; -- cr16 | cr16-*) -- basic_machine=cr16-unknown -- os=-elf -- ;; -- crds | unos) -- basic_machine=m68k-crds -- ;; -- crisv32 | crisv32-* | etraxfs*) -- basic_machine=crisv32-axis -- ;; -- cris | cris-* | etrax*) -- basic_machine=cris-axis -- ;; -- crx) -- basic_machine=crx-unknown -- os=-elf -- ;; -- da30 | da30-*) -- basic_machine=m68k-da30 -- ;; -- decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) -- basic_machine=mips-dec -- ;; -- decsystem10* | dec10*) -- basic_machine=pdp10-dec -- os=-tops10 -- ;; -- decsystem20* | dec20*) -- basic_machine=pdp10-dec -- os=-tops20 -- ;; -- delta | 3300 | motorola-3300 | motorola-delta \ -- | 3300-motorola | delta-motorola) -- basic_machine=m68k-motorola -- ;; -- delta88) -- basic_machine=m88k-motorola -- os=-sysv3 -- ;; -- dicos) -- basic_machine=i686-pc -- os=-dicos -- ;; -- djgpp) -- basic_machine=i586-pc -- os=-msdosdjgpp -- ;; -- dpx20 | dpx20-*) -- basic_machine=rs6000-bull -- os=-bosx -- ;; -- dpx2* | dpx2*-bull) -- basic_machine=m68k-bull -- os=-sysv3 -- ;; -- ebmon29k) -- basic_machine=a29k-amd -- os=-ebmon -- ;; -- elxsi) -- basic_machine=elxsi-elxsi -- os=-bsd -- ;; -- encore | umax | mmax) -- basic_machine=ns32k-encore -- ;; -- es1800 | OSE68k | ose68k | ose | OSE) -- basic_machine=m68k-ericsson -- os=-ose -- ;; -- fx2800) -- basic_machine=i860-alliant -- ;; -- genix) -- basic_machine=ns32k-ns -- ;; -- gmicro) -- basic_machine=tron-gmicro -- os=-sysv -- ;; -- go32) -- basic_machine=i386-pc -- os=-go32 -- ;; -- h3050r* | hiux*) -- basic_machine=hppa1.1-hitachi -- os=-hiuxwe2 -- ;; -- h8300hms) -- basic_machine=h8300-hitachi -- os=-hms -- ;; -- h8300xray) -- basic_machine=h8300-hitachi -- os=-xray -- ;; -- h8500hms) -- basic_machine=h8500-hitachi -- os=-hms -- ;; -- harris) -- basic_machine=m88k-harris -- os=-sysv3 -- ;; -- hp300-*) -- basic_machine=m68k-hp -- ;; -- hp300bsd) -- basic_machine=m68k-hp -- os=-bsd -- ;; -- hp300hpux) -- basic_machine=m68k-hp -- os=-hpux -- ;; -- hp3k9[0-9][0-9] | hp9[0-9][0-9]) -- basic_machine=hppa1.0-hp -- ;; -- hp9k2[0-9][0-9] | hp9k31[0-9]) -- basic_machine=m68000-hp -- ;; -- hp9k3[2-9][0-9]) -- basic_machine=m68k-hp -- ;; -- hp9k6[0-9][0-9] | hp6[0-9][0-9]) -- basic_machine=hppa1.0-hp -- ;; -- hp9k7[0-79][0-9] | hp7[0-79][0-9]) -- basic_machine=hppa1.1-hp -- ;; -- hp9k78[0-9] | hp78[0-9]) -- # FIXME: really hppa2.0-hp -- basic_machine=hppa1.1-hp -- ;; -- hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) -- # FIXME: really hppa2.0-hp -- basic_machine=hppa1.1-hp -- ;; -- hp9k8[0-9][13679] | hp8[0-9][13679]) -- basic_machine=hppa1.1-hp -- ;; -- hp9k8[0-9][0-9] | hp8[0-9][0-9]) -- basic_machine=hppa1.0-hp -- ;; -- hppa-next) -- os=-nextstep3 -- ;; -- hppaosf) -- basic_machine=hppa1.1-hp -- os=-osf -- ;; -- hppro) -- basic_machine=hppa1.1-hp -- os=-proelf -- ;; -- i370-ibm* | ibm*) -- basic_machine=i370-ibm -- ;; -- i*86v32) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-sysv32 -- ;; -- i*86v4*) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-sysv4 -- ;; -- i*86v) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-sysv -- ;; -- i*86sol2) -- basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` -- os=-solaris2 -- ;; -- i386mach) -- basic_machine=i386-mach -- os=-mach -- ;; -- i386-vsta | vsta) -- basic_machine=i386-unknown -- os=-vsta -- ;; -- iris | iris4d) -- basic_machine=mips-sgi -- case $os in -- -irix*) -- ;; -- *) -- os=-irix4 -- ;; -- esac -- ;; -- isi68 | isi) -- basic_machine=m68k-isi -- os=-sysv -- ;; -- m68knommu) -- basic_machine=m68k-unknown -- os=-linux -- ;; -- m68knommu-*) -- basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` -- os=-linux -- ;; -- m88k-omron*) -- basic_machine=m88k-omron -- ;; -- magnum | m3230) -- basic_machine=mips-mips -- os=-sysv -- ;; -- merlin) -- basic_machine=ns32k-utek -- os=-sysv -- ;; -- microblaze*) -- basic_machine=microblaze-xilinx -- ;; -- mingw64) -- basic_machine=x86_64-pc -- os=-mingw64 -- ;; -- mingw32) -- basic_machine=i386-pc -- os=-mingw32 -- ;; -- mingw32ce) -- basic_machine=arm-unknown -- os=-mingw32ce -- ;; -- miniframe) -- basic_machine=m68000-convergent -- ;; -- *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) -- basic_machine=m68k-atari -- os=-mint -- ;; -- mips3*-*) -- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` -- ;; -- mips3*) -- basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown -- ;; -- monitor) -- basic_machine=m68k-rom68k -- os=-coff -- ;; -- morphos) -- basic_machine=powerpc-unknown -- os=-morphos -- ;; -- msdos) -- basic_machine=i386-pc -- os=-msdos -- ;; -- ms1-*) -- basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` -- ;; -- msys) -- basic_machine=i386-pc -- os=-msys -- ;; -- mvs) -- basic_machine=i370-ibm -- os=-mvs -- ;; -- nacl) -- basic_machine=le32-unknown -- os=-nacl -- ;; -- ncr3000) -- basic_machine=i486-ncr -- os=-sysv4 -- ;; -- netbsd386) -- basic_machine=i386-unknown -- os=-netbsd -- ;; -- netwinder) -- basic_machine=armv4l-rebel -- os=-linux -- ;; -- news | news700 | news800 | news900) -- basic_machine=m68k-sony -- os=-newsos -- ;; -- news1000) -- basic_machine=m68030-sony -- os=-newsos -- ;; -- news-3600 | risc-news) -- basic_machine=mips-sony -- os=-newsos -- ;; -- necv70) -- basic_machine=v70-nec -- os=-sysv -- ;; -- next | m*-next ) -- basic_machine=m68k-next -- case $os in -- -nextstep* ) -- ;; -- -ns2*) -- os=-nextstep2 -- ;; -- *) -- os=-nextstep3 -- ;; -- esac -- ;; -- nh3000) -- basic_machine=m68k-harris -- os=-cxux -- ;; -- nh[45]000) -- basic_machine=m88k-harris -- os=-cxux -- ;; -- nindy960) -- basic_machine=i960-intel -- os=-nindy -- ;; -- mon960) -- basic_machine=i960-intel -- os=-mon960 -- ;; -- nonstopux) -- basic_machine=mips-compaq -- os=-nonstopux -- ;; -- np1) -- basic_machine=np1-gould -- ;; -- neo-tandem) -- basic_machine=neo-tandem -- ;; -- nse-tandem) -- basic_machine=nse-tandem -- ;; -- nsr-tandem) -- basic_machine=nsr-tandem -- ;; -- op50n-* | op60c-*) -- basic_machine=hppa1.1-oki -- os=-proelf -- ;; -- openrisc | openrisc-*) -- basic_machine=or32-unknown -- ;; -- os400) -- basic_machine=powerpc-ibm -- os=-os400 -- ;; -- OSE68000 | ose68000) -- basic_machine=m68000-ericsson -- os=-ose -- ;; -- os68k) -- basic_machine=m68k-none -- os=-os68k -- ;; -- pa-hitachi) -- basic_machine=hppa1.1-hitachi -- os=-hiuxwe2 -- ;; -- paragon) -- basic_machine=i860-intel -- os=-osf -- ;; -- parisc) -- basic_machine=hppa-unknown -- os=-linux -- ;; -- parisc-*) -- basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` -- os=-linux -- ;; -- pbd) -- basic_machine=sparc-tti -- ;; -- pbb) -- basic_machine=m68k-tti -- ;; -- pc532 | pc532-*) -- basic_machine=ns32k-pc532 -- ;; -- pc98) -- basic_machine=i386-pc -- ;; -- pc98-*) -- basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentium | p5 | k5 | k6 | nexgen | viac3) -- basic_machine=i586-pc -- ;; -- pentiumpro | p6 | 6x86 | athlon | athlon_*) -- basic_machine=i686-pc -- ;; -- pentiumii | pentium2 | pentiumiii | pentium3) -- basic_machine=i686-pc -- ;; -- pentium4) -- basic_machine=i786-pc -- ;; -- pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) -- basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentiumpro-* | p6-* | 6x86-* | athlon-*) -- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) -- basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pentium4-*) -- basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- pn) -- basic_machine=pn-gould -- ;; -- power) basic_machine=power-ibm -- ;; -- ppc | ppcbe) basic_machine=powerpc-unknown -- ;; -- ppc-* | ppcbe-*) -- basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- ppcle | powerpclittle | ppc-le | powerpc-little) -- basic_machine=powerpcle-unknown -- ;; -- ppcle-* | powerpclittle-*) -- basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- ppc64) basic_machine=powerpc64-unknown -- ;; -- ppc64-* | ppc64p7-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- ppc64le | powerpc64little | ppc64-le | powerpc64-little) -- basic_machine=powerpc64le-unknown -- ;; -- ppc64le-* | powerpc64little-*) -- basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- ps2) -- basic_machine=i386-ibm -- ;; -- pw32) -- basic_machine=i586-unknown -- os=-pw32 -- ;; -- rdos | rdos64) -- basic_machine=x86_64-pc -- os=-rdos -- ;; -- rdos32) -- basic_machine=i386-pc -- os=-rdos -- ;; -- rom68k) -- basic_machine=m68k-rom68k -- os=-coff -- ;; -- rm[46]00) -- basic_machine=mips-siemens -- ;; -- rtpc | rtpc-*) -- basic_machine=romp-ibm -- ;; -- s390 | s390-*) -- basic_machine=s390-ibm -- ;; -- s390x | s390x-*) -- basic_machine=s390x-ibm -- ;; -- sa29200) -- basic_machine=a29k-amd -- os=-udi -- ;; -- sb1) -- basic_machine=mipsisa64sb1-unknown -- ;; -- sb1el) -- basic_machine=mipsisa64sb1el-unknown -- ;; -- sde) -- basic_machine=mipsisa32-sde -- os=-elf -- ;; -- sei) -- basic_machine=mips-sei -- os=-seiux -- ;; -- sequent) -- basic_machine=i386-sequent -- ;; -- sh) -- basic_machine=sh-hitachi -- os=-hms -- ;; -- sh5el) -- basic_machine=sh5le-unknown -- ;; -- sh64) -- basic_machine=sh64-unknown -- ;; -- sparclite-wrs | simso-wrs) -- basic_machine=sparclite-wrs -- os=-vxworks -- ;; -- sps7) -- basic_machine=m68k-bull -- os=-sysv2 -- ;; -- spur) -- basic_machine=spur-unknown -- ;; -- st2000) -- basic_machine=m68k-tandem -- ;; -- stratus) -- basic_machine=i860-stratus -- os=-sysv4 -- ;; -- strongarm-* | thumb-*) -- basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- sun2) -- basic_machine=m68000-sun -- ;; -- sun2os3) -- basic_machine=m68000-sun -- os=-sunos3 -- ;; -- sun2os4) -- basic_machine=m68000-sun -- os=-sunos4 -- ;; -- sun3os3) -- basic_machine=m68k-sun -- os=-sunos3 -- ;; -- sun3os4) -- basic_machine=m68k-sun -- os=-sunos4 -- ;; -- sun4os3) -- basic_machine=sparc-sun -- os=-sunos3 -- ;; -- sun4os4) -- basic_machine=sparc-sun -- os=-sunos4 -- ;; -- sun4sol2) -- basic_machine=sparc-sun -- os=-solaris2 -- ;; -- sun3 | sun3-*) -- basic_machine=m68k-sun -- ;; -- sun4) -- basic_machine=sparc-sun -- ;; -- sun386 | sun386i | roadrunner) -- basic_machine=i386-sun -- ;; -- sv1) -- basic_machine=sv1-cray -- os=-unicos -- ;; -- symmetry) -- basic_machine=i386-sequent -- os=-dynix -- ;; -- t3e) -- basic_machine=alphaev5-cray -- os=-unicos -- ;; -- t90) -- basic_machine=t90-cray -- os=-unicos -- ;; -- tile*) -- basic_machine=$basic_machine-unknown -- os=-linux-gnu -- ;; -- tx39) -- basic_machine=mipstx39-unknown -- ;; -- tx39el) -- basic_machine=mipstx39el-unknown -- ;; -- toad1) -- basic_machine=pdp10-xkl -- os=-tops20 -- ;; -- tower | tower-32) -- basic_machine=m68k-ncr -- ;; -- tpf) -- basic_machine=s390x-ibm -- os=-tpf -- ;; -- udi29k) -- basic_machine=a29k-amd -- os=-udi -- ;; -- ultra3) -- basic_machine=a29k-nyu -- os=-sym1 -- ;; -- v810 | necv810) -- basic_machine=v810-nec -- os=-none -- ;; -- vaxv) -- basic_machine=vax-dec -- os=-sysv -- ;; -- vms) -- basic_machine=vax-dec -- os=-vms -- ;; -- vpp*|vx|vx-*) -- basic_machine=f301-fujitsu -- ;; -- vxworks960) -- basic_machine=i960-wrs -- os=-vxworks -- ;; -- vxworks68) -- basic_machine=m68k-wrs -- os=-vxworks -- ;; -- vxworks29k) -- basic_machine=a29k-wrs -- os=-vxworks -- ;; -- w65*) -- basic_machine=w65-wdc -- os=-none -- ;; -- w89k-*) -- basic_machine=hppa1.1-winbond -- os=-proelf -- ;; -- xbox) -- basic_machine=i686-pc -- os=-mingw32 -- ;; -- xps | xps100) -- basic_machine=xps100-honeywell -- ;; -- xscale-* | xscalee[bl]-*) -- basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` -- ;; -- ymp) -- basic_machine=ymp-cray -- os=-unicos -- ;; -- z8k-*-coff) -- basic_machine=z8k-unknown -- os=-sim -- ;; -- z80-*-coff) -- basic_machine=z80-unknown -- os=-sim -- ;; -- none) -- basic_machine=none-none -- os=-none -- ;; -- --# Here we handle the default manufacturer of certain CPU types. It is in --# some cases the only manufacturer, in others, it is the most popular. -- w89k) -- basic_machine=hppa1.1-winbond -- ;; -- op50n) -- basic_machine=hppa1.1-oki -- ;; -- op60c) -- basic_machine=hppa1.1-oki -- ;; -- romp) -- basic_machine=romp-ibm -- ;; -- mmix) -- basic_machine=mmix-knuth -- ;; -- rs6000) -- basic_machine=rs6000-ibm -- ;; -- vax) -- basic_machine=vax-dec -- ;; -- pdp10) -- # there are many clones, so DEC is not a safe bet -- basic_machine=pdp10-unknown -- ;; -- pdp11) -- basic_machine=pdp11-dec -- ;; -- we32k) -- basic_machine=we32k-att -- ;; -- sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) -- basic_machine=sh-unknown -- ;; -- sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) -- basic_machine=sparc-sun -- ;; -- cydra) -- basic_machine=cydra-cydrome -- ;; -- orion) -- basic_machine=orion-highlevel -- ;; -- orion105) -- basic_machine=clipper-highlevel -- ;; -- mac | mpw | mac-mpw) -- basic_machine=m68k-apple -- ;; -- pmac | pmac-mpw) -- basic_machine=powerpc-apple -- ;; -- *-unknown) -- # Make sure to match an already-canonicalized machine name. -- ;; -- *) -- echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 -- exit 1 -- ;; --esac -- --# Here we canonicalize certain aliases for manufacturers. --case $basic_machine in -- *-digital*) -- basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` -- ;; -- *-commodore*) -- basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` -- ;; -- *) -- ;; --esac -- --# Decode manufacturer-specific aliases for certain operating systems. -- --if [ x"$os" != x"" ] --then --case $os in -- # First match some system type aliases -- # that might get confused with valid system types. -- # -solaris* is a basic system type, with this one exception. -- -auroraux) -- os=-auroraux -- ;; -- -solaris1 | -solaris1.*) -- os=`echo $os | sed -e 's|solaris1|sunos4|'` -- ;; -- -solaris) -- os=-solaris2 -- ;; -- -svr4*) -- os=-sysv4 -- ;; -- -unixware*) -- os=-sysv4.2uw -- ;; -- -gnu/linux*) -- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` -- ;; -- # First accept the basic system types. -- # The portable systems comes first. -- # Each alternative MUST END IN A *, to match a version number. -- # -sysv* is not here because it comes later, after sysvr4. -- -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ -- | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ -- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ -- | -sym* | -kopensolaris* | -plan9* \ -- | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ -- | -aos* | -aros* \ -- | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ -- | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ -- | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ -- | -bitrig* | -openbsd* | -solidbsd* \ -- | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ -- | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ -- | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ -- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ -- | -chorusos* | -chorusrdb* | -cegcc* \ -- | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ -- | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ -- | -linux-newlib* | -linux-musl* | -linux-uclibc* \ -- | -uxpv* | -beos* | -mpeix* | -udk* \ -- | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ -- | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ -- | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ -- | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ -- | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ -- | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ -- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) -- # Remember, each alternative MUST END IN *, to match a version number. -- ;; -- -qnx*) -- case $basic_machine in -- x86-* | i*86-*) -- ;; -- *) -- os=-nto$os -- ;; -- esac -- ;; -- -nto-qnx*) -- ;; -- -nto*) -- os=`echo $os | sed -e 's|nto|nto-qnx|'` -- ;; -- -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ -- | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ -- | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) -- ;; -- -mac*) -- os=`echo $os | sed -e 's|mac|macos|'` -- ;; -- -linux-dietlibc) -- os=-linux-dietlibc -- ;; -- -linux*) -- os=`echo $os | sed -e 's|linux|linux-gnu|'` -- ;; -- -sunos5*) -- os=`echo $os | sed -e 's|sunos5|solaris2|'` -- ;; -- -sunos6*) -- os=`echo $os | sed -e 's|sunos6|solaris3|'` -- ;; -- -opened*) -- os=-openedition -- ;; -- -os400*) -- os=-os400 -- ;; -- -wince*) -- os=-wince -- ;; -- -osfrose*) -- os=-osfrose -- ;; -- -osf*) -- os=-osf -- ;; -- -utek*) -- os=-bsd -- ;; -- -dynix*) -- os=-bsd -- ;; -- -acis*) -- os=-aos -- ;; -- -atheos*) -- os=-atheos -- ;; -- -syllable*) -- os=-syllable -- ;; -- -386bsd) -- os=-bsd -- ;; -- -ctix* | -uts*) -- os=-sysv -- ;; -- -nova*) -- os=-rtmk-nova -- ;; -- -ns2 ) -- os=-nextstep2 -- ;; -- -nsk*) -- os=-nsk -- ;; -- # Preserve the version number of sinix5. -- -sinix5.*) -- os=`echo $os | sed -e 's|sinix|sysv|'` -- ;; -- -sinix*) -- os=-sysv4 -- ;; -- -tpf*) -- os=-tpf -- ;; -- -triton*) -- os=-sysv3 -- ;; -- -oss*) -- os=-sysv3 -- ;; -- -svr4) -- os=-sysv4 -- ;; -- -svr3) -- os=-sysv3 -- ;; -- -sysvr4) -- os=-sysv4 -- ;; -- # This must come after -sysvr4. -- -sysv*) -- ;; -- -ose*) -- os=-ose -- ;; -- -es1800*) -- os=-ose -- ;; -- -xenix) -- os=-xenix -- ;; -- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) -- os=-mint -- ;; -- -aros*) -- os=-aros -- ;; -- -zvmoe) -- os=-zvmoe -- ;; -- -dicos*) -- os=-dicos -- ;; -- -nacl*) -- ;; -- -none) -- ;; -- *) -- # Get rid of the `-' at the beginning of $os. -- os=`echo $os | sed 's/[^-]*-//'` -- echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 -- exit 1 -- ;; --esac --else -- --# Here we handle the default operating systems that come with various machines. --# The value should be what the vendor currently ships out the door with their --# machine or put another way, the most popular os provided with the machine. -- --# Note that if you're going to try to match "-MANUFACTURER" here (say, --# "-sun"), then you have to tell the case statement up towards the top --# that MANUFACTURER isn't an operating system. Otherwise, code above --# will signal an error saying that MANUFACTURER isn't an operating --# system, and we'll never get to this point. -- --case $basic_machine in -- score-*) -- os=-elf -- ;; -- spu-*) -- os=-elf -- ;; -- *-acorn) -- os=-riscix1.2 -- ;; -- arm*-rebel) -- os=-linux -- ;; -- arm*-semi) -- os=-aout -- ;; -- c4x-* | tic4x-*) -- os=-coff -- ;; -- hexagon-*) -- os=-elf -- ;; -- tic54x-*) -- os=-coff -- ;; -- tic55x-*) -- os=-coff -- ;; -- tic6x-*) -- os=-coff -- ;; -- # This must come before the *-dec entry. -- pdp10-*) -- os=-tops20 -- ;; -- pdp11-*) -- os=-none -- ;; -- *-dec | vax-*) -- os=-ultrix4.2 -- ;; -- m68*-apollo) -- os=-domain -- ;; -- i386-sun) -- os=-sunos4.0.2 -- ;; -- m68000-sun) -- os=-sunos3 -- ;; -- m68*-cisco) -- os=-aout -- ;; -- mep-*) -- os=-elf -- ;; -- mips*-cisco) -- os=-elf -- ;; -- mips*-*) -- os=-elf -- ;; -- or1k-*) -- os=-elf -- ;; -- or32-*) -- os=-coff -- ;; -- *-tti) # must be before sparc entry or we get the wrong os. -- os=-sysv3 -- ;; -- sparc-* | *-sun) -- os=-sunos4.1.1 -- ;; -- *-be) -- os=-beos -- ;; -- *-haiku) -- os=-haiku -- ;; -- *-ibm) -- os=-aix -- ;; -- *-knuth) -- os=-mmixware -- ;; -- *-wec) -- os=-proelf -- ;; -- *-winbond) -- os=-proelf -- ;; -- *-oki) -- os=-proelf -- ;; -- *-hp) -- os=-hpux -- ;; -- *-hitachi) -- os=-hiux -- ;; -- i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) -- os=-sysv -- ;; -- *-cbm) -- os=-amigaos -- ;; -- *-dg) -- os=-dgux -- ;; -- *-dolphin) -- os=-sysv3 -- ;; -- m68k-ccur) -- os=-rtu -- ;; -- m88k-omron*) -- os=-luna -- ;; -- *-next ) -- os=-nextstep -- ;; -- *-sequent) -- os=-ptx -- ;; -- *-crds) -- os=-unos -- ;; -- *-ns) -- os=-genix -- ;; -- i370-*) -- os=-mvs -- ;; -- *-next) -- os=-nextstep3 -- ;; -- *-gould) -- os=-sysv -- ;; -- *-highlevel) -- os=-bsd -- ;; -- *-encore) -- os=-bsd -- ;; -- *-sgi) -- os=-irix -- ;; -- *-siemens) -- os=-sysv4 -- ;; -- *-masscomp) -- os=-rtu -- ;; -- f30[01]-fujitsu | f700-fujitsu) -- os=-uxpv -- ;; -- *-rom68k) -- os=-coff -- ;; -- *-*bug) -- os=-coff -- ;; -- *-apple) -- os=-macos -- ;; -- *-atari*) -- os=-mint -- ;; -- *) -- os=-none -- ;; --esac --fi -- --# Here we handle the case where we know the os, and the CPU type, but not the --# manufacturer. We pick the logical manufacturer. --vendor=unknown --case $basic_machine in -- *-unknown) -- case $os in -- -riscix*) -- vendor=acorn -- ;; -- -sunos*) -- vendor=sun -- ;; -- -cnk*|-aix*) -- vendor=ibm -- ;; -- -beos*) -- vendor=be -- ;; -- -hpux*) -- vendor=hp -- ;; -- -mpeix*) -- vendor=hp -- ;; -- -hiux*) -- vendor=hitachi -- ;; -- -unos*) -- vendor=crds -- ;; -- -dgux*) -- vendor=dg -- ;; -- -luna*) -- vendor=omron -- ;; -- -genix*) -- vendor=ns -- ;; -- -mvs* | -opened*) -- vendor=ibm -- ;; -- -os400*) -- vendor=ibm -- ;; -- -ptx*) -- vendor=sequent -- ;; -- -tpf*) -- vendor=ibm -- ;; -- -vxsim* | -vxworks* | -windiss*) -- vendor=wrs -- ;; -- -aux*) -- vendor=apple -- ;; -- -hms*) -- vendor=hitachi -- ;; -- -mpw* | -macos*) -- vendor=apple -- ;; -- -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) -- vendor=atari -- ;; -- -vos*) -- vendor=stratus -- ;; -- esac -- basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` -- ;; --esac -- --echo $basic_machine$os --exit -- --# Local variables: --# eval: (add-hook 'write-file-hooks 'time-stamp) --# time-stamp-start: "timestamp='" --# time-stamp-format: "%:y-%02m-%02d" --# time-stamp-end: "'" --# End: -+echo arm-linux-androideabi diff --git a/recipes/python2/patches/fix-configure-darwin.patch b/recipes/python2/patches/fix-configure-darwin.patch deleted file mode 100644 index 93a1fe3d..00000000 --- a/recipes/python2/patches/fix-configure-darwin.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- Python-2.7.2.orig/configure 2012-07-09 23:48:02.000000000 +0200 -+++ Python-2.7.2/configure 2012-07-09 23:47:34.000000000 +0200 -@@ -4927,7 +4927,7 @@ - RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} - INSTSONAME="$LDLIBRARY".$SOVERSION - ;; -- Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*) -+ Linux*|GNU*|NetBSD*|FreeBSD*|DragonFly*|Darwin*) - LDLIBRARY='libpython$(VERSION).so' - BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=LD_LIBRARY_PATH=`pwd`:${LD_LIBRARY_PATH} -@@ -4960,7 +4960,7 @@ - BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED=DLL_PATH=`pwd`:${DLL_PATH:-/atheos/sys/libs:/atheos/autolnk/lib} - ;; -- Darwin*) -+ DDarwin*) - LDLIBRARY='libpython$(VERSION).dylib' - BLDLIBRARY='-L. -lpython$(VERSION)' - RUNSHARED='DYLD_LIBRARY_PATH=`pwd`:${DYLD_LIBRARY_PATH}' -@@ -7625,6 +7625,9 @@ - LDSHARED='ld -b' - fi ;; - OSF*) LDSHARED="ld -shared -expect_unresolved \"*\"";; -+ Darwin*|Linux*|GNU*|QNX*) -+ LDSHARED='$(CC) -shared' -+ LDCXXSHARED='$(CXX) -shared';; - Darwin/1.3*) - LDSHARED='$(CC) -bundle' - LDCXXSHARED='$(CXX) -bundle' -@@ -7680,9 +7683,6 @@ - fi - fi - ;; -- Linux*|GNU*|QNX*) -- LDSHARED='$(CC) -shared' -- LDCXXSHARED='$(CXX) -shared';; - BSD/OS*/4*) - LDSHARED="gcc -shared" - LDCXXSHARED="g++ -shared";; diff --git a/recipes/python2/patches/fix-distutils-darwin.patch b/recipes/python2/patches/fix-distutils-darwin.patch deleted file mode 100644 index 40836348..00000000 --- a/recipes/python2/patches/fix-distutils-darwin.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- Python-2.7.2.orig/Lib/distutils/command/build_ext.py 2011-06-11 17:46:24.000000000 +0200 -+++ Python-2.7.2/Lib/distutils/command/build_ext.py 2012-08-01 18:32:13.000000000 +0200 -@@ -236,7 +236,7 @@ - # Python's library directory must be appended to library_dirs - sysconfig.get_config_var('Py_ENABLE_SHARED') - if ((sys.platform.startswith('linux') or sys.platform.startswith('gnu') -- or sys.platform.startswith('sunos')) -+ or sys.platform.startswith('sunos') or sys.platform.startswith('darwin')) - and sysconfig.get_config_var('Py_ENABLE_SHARED')): - if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")): - # building third party extensions -@@ -750,9 +750,9 @@ - # extensions, it is a reference to the original list - return ext.libraries + [pythonlib, "m"] + extra - -- elif sys.platform == 'darwin': -- # Don't use the default code below -- return ext.libraries -+ #elif sys.platform == 'darwin': -+ # # Don't use the default code below -+ # return ext.libraries - elif sys.platform[:3] == 'aix': - # Don't use the default code below - return ext.libraries diff --git a/recipes/python2/patches/fix-dlfcn.patch b/recipes/python2/patches/fix-dlfcn.patch deleted file mode 100644 index 7a685cad..00000000 --- a/recipes/python2/patches/fix-dlfcn.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff -Naur Python-2.7.2.orig/Lib/plat-linux2/DLFCN.py Python-2.7.2/Lib/plat-linux2/DLFCN.py ---- Python-2.7.2.orig/Lib/plat-linux2/DLFCN.py 2011-06-11 17:46:24.000000000 +0200 -+++ Python-2.7.2/Lib/plat-linux2/DLFCN.py 2013-07-29 16:34:45.318131844 +0200 -@@ -74,10 +74,17 @@ - # Included from gnu/stubs.h - - # Included from bits/dlfcn.h -+# PATCHED FOR ANDROID (the only supported symbols are): -+# enum { -+# RTLD_NOW = 0, -+# RTLD_LAZY = 1, -+# RTLD_LOCAL = 0, -+# RTLD_GLOBAL = 2, -+# }; - RTLD_LAZY = 0x00001 --RTLD_NOW = 0x00002 --RTLD_BINDING_MASK = 0x3 --RTLD_NOLOAD = 0x00004 --RTLD_GLOBAL = 0x00100 -+RTLD_NOW = 0x00000 -+RTLD_BINDING_MASK = 0x0 -+RTLD_NOLOAD = 0x00000 -+RTLD_GLOBAL = 0x00002 - RTLD_LOCAL = 0 --RTLD_NODELETE = 0x01000 -+RTLD_NODELETE = 0x00000 diff --git a/recipes/python2/patches/fix-dynamic-lookup.patch b/recipes/python2/patches/fix-dynamic-lookup.patch deleted file mode 100644 index cd88fb1b..00000000 --- a/recipes/python2/patches/fix-dynamic-lookup.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Python-2.7.13/Makefile.pre.in 2016-12-17 21:05:06.000000000 +0100 -+++ Python-2.7.13/Makefile.pre.in.dyn 2017-08-10 22:09:59.311219406 +0100 -@@ -568,7 +568,7 @@ - fi - - libpython$(VERSION).dylib: $(LIBRARY_OBJS) -- $(CC) -dynamiclib -Wl,-single_module $(LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ -+ $(CC) -dynamiclib -Wl,-single_module $(LDFLAGS) -Wl,-install_name,$(prefix)/lib/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \ - - - libpython$(VERSION).sl: $(LIBRARY_OBJS) diff --git a/recipes/python2/patches/fix-filesystemdefaultencoding.patch b/recipes/python2/patches/fix-filesystemdefaultencoding.patch deleted file mode 100644 index cacd72cf..00000000 --- a/recipes/python2/patches/fix-filesystemdefaultencoding.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Python-2.7.13/Python/bltinmodule.c 2016-12-17 21:05:07.000000000 +0100 -+++ Python-2.7.13-modified/Python/bltinmodule.c 2017-08-10 22:14:26.490843018 +0100 -@@ -22,7 +22,7 @@ - #elif defined(__APPLE__) - const char *Py_FileSystemDefaultEncoding = "utf-8"; - #else --const char *Py_FileSystemDefaultEncoding = NULL; /* use default */ -+const char *Py_FileSystemDefaultEncoding = "utf-8"; /* use default */ - #endif - - /* Forward */ diff --git a/recipes/python2/patches/fix-gethostbyaddr.patch b/recipes/python2/patches/fix-gethostbyaddr.patch deleted file mode 100644 index 7b04250a..00000000 --- a/recipes/python2/patches/fix-gethostbyaddr.patch +++ /dev/null @@ -1,12 +0,0 @@ ---- Python-2.7.2/Modules/socketmodule.c.orig 2012-01-06 01:40:09.915694810 +0100 -+++ Python-2.7.2/Modules/socketmodule.c 2012-01-06 01:40:36.967694486 +0100 -@@ -146,6 +146,9 @@ - On the other hand, not all Linux versions agree, so there the settings - computed by the configure script are needed! */ - -+/* Android hack, same reason are what is described above */ -+#undef HAVE_GETHOSTBYNAME_R -+ - #ifndef linux - # undef HAVE_GETHOSTBYNAME_R_3_ARG - # undef HAVE_GETHOSTBYNAME_R_5_ARG diff --git a/recipes/python2/patches/fix-locale-2.7.13.patch b/recipes/python2/patches/fix-locale-2.7.13.patch deleted file mode 100644 index 4ae273b6..00000000 --- a/recipes/python2/patches/fix-locale-2.7.13.patch +++ /dev/null @@ -1,77 +0,0 @@ ---- Python-2.7.9.orig/Modules/posixmodule.c 2010-11-26 18:35:50.000000000 +0100 -+++ Python-2.7.9/Modules/posixmodule.c 2011-04-20 17:52:12.000000000 +0200 -@@ -3775,13 +3775,6 @@ - slave_fd = open(slave_name, O_RDWR | O_NOCTTY); /* open slave */ - if (slave_fd < 0) - return posix_error(); --#if !defined(__CYGWIN__) && !defined(HAVE_DEV_PTC) -- ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */ -- ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */ --#ifndef __hpux -- ioctl(slave_fd, I_PUSH, "ttcompat"); /* push ttcompat */ --#endif /* __hpux */ --#endif /* HAVE_CYGWIN */ - #endif /* HAVE_OPENPTY */ - - return Py_BuildValue("(ii)", master_fd, slave_fd); ---- Python-2.7.9.orig/Objects/stringlib/formatter.h 2010-08-01 12:45:15.000000000 +0200 -+++ Python-2.7.9/Objects/stringlib/formatter.h 2011-04-20 17:52:12.000000000 +0200 -@@ -639,13 +639,7 @@ - get_locale_info(int type, LocaleInfo *locale_info) - { - switch (type) { -- case LT_CURRENT_LOCALE: { -- struct lconv *locale_data = localeconv(); -- locale_info->decimal_point = locale_data->decimal_point; -- locale_info->thousands_sep = locale_data->thousands_sep; -- locale_info->grouping = locale_data->grouping; -- break; -- } -+ case LT_CURRENT_LOCALE: - case LT_DEFAULT_LOCALE: - locale_info->decimal_point = "."; - locale_info->thousands_sep = ","; ---- Python-2.7.9.orig/Objects/stringlib/localeutil.h 2009-04-22 15:29:05.000000000 +0200 -+++ Python-2.7.9/Objects/stringlib/localeutil.h 2011-04-20 17:52:12.000000000 +0200 -@@ -202,9 +202,8 @@ - Py_ssize_t n_digits, - Py_ssize_t min_width) - { -- struct lconv *locale_data = localeconv(); -- const char *grouping = locale_data->grouping; -- const char *thousands_sep = locale_data->thousands_sep; -+ const char *grouping = "\3\0"; -+ const char *thousands_sep = ","; - - return _Py_InsertThousandsGrouping(buffer, n_buffer, digits, n_digits, - min_width, grouping, thousands_sep); ---- Python-2.7.9.orig/Python/pystrtod.c 2010-05-09 16:46:46.000000000 +0200 -+++ Python-2.7.9/Python/pystrtod.c 2011-04-20 17:52:12.000000000 +0200 -@@ -126,7 +126,6 @@ - { - char *fail_pos; - double val = -1.0; -- struct lconv *locale_data; - const char *decimal_point; - size_t decimal_point_len; - const char *p, *decimal_point_pos; -@@ -138,8 +137,7 @@ - - fail_pos = NULL; - -- locale_data = localeconv(); -- decimal_point = locale_data->decimal_point; -+ decimal_point = "."; - decimal_point_len = strlen(decimal_point); - - assert(decimal_point_len != 0); -@@ -375,8 +373,7 @@ - Py_LOCAL_INLINE(void) - change_decimal_from_locale_to_dot(char* buffer) - { -- struct lconv *locale_data = localeconv(); -- const char *decimal_point = locale_data->decimal_point; -+ const char *decimal_point = "."; - - if (decimal_point[0] != '.' || decimal_point[1] != 0) { - size_t decimal_point_len = strlen(decimal_point); diff --git a/recipes/python2/patches/fix-platform-2.7.13.patch b/recipes/python2/patches/fix-platform-2.7.13.patch deleted file mode 100644 index d0093c6e..00000000 --- a/recipes/python2/patches/fix-platform-2.7.13.patch +++ /dev/null @@ -1,32 +0,0 @@ ---- Python-2.7.9/Python/getplatform.c.orig 2014-12-10 16:59:59.000000000 +0100 -+++ Python-2.7.9/Python/getplatform.c 2015-05-03 19:17:58.071596232 +0200 -@@ -1,12 +1,25 @@ - - #include "Python.h" - --#ifndef PLATFORM --#define PLATFORM "unknown" --#endif -+#include -+#include - - const char * - Py_GetPlatform(void) - { -- return PLATFORM; -+ struct utsname u; -+ int i; -+ if ( uname(&u) < 0 ) -+ return "unknown"; -+ -+ char xx[37]; -+ memset(xx, 0, 37); -+ strcat (xx, u.sysname); -+ strcat (xx, "-"); -+ strcat (xx, u.machine); -+ -+ for (i=0; xx[i]; i++) -+ xx[i]=tolower(xx[i]); -+ -+ return xx; - } diff --git a/recipes/python2/patches/fix-platform-processor.patch b/recipes/python2/patches/fix-platform-processor.patch deleted file mode 100644 index 33b8f89f..00000000 --- a/recipes/python2/patches/fix-platform-processor.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- Python-2.7.13/Lib/platform.py 2016-12-17 21:05:06.000000000 +0100 -+++ Python-2.7.13-modified/Lib/platform.py 2017-08-13 00:46:39.161864994 +0100 -@@ -1311,7 +1311,18 @@ - e.g. NetBSD does this. - - """ -- return uname()[5] -+ # Attempt to obtain the processor name from /proc/cpuinfo on Android -+ processor_name = uname()[5] -+ if (processor_name.strip() == ""): -+ cpuinfo = '/proc/cpuinfo' -+ if (os.path.exists(cpuinfo)): -+ lines = tuple(open(cpuinfo, 'r')) -+ for line in lines: -+ if (line.startswith('model name') and line.index(':') > -1): -+ processor_name = line[line.index(':') + 1:].strip() -+ break -+ -+ return processor_name - - ### Various APIs for extracting information from sys.version - diff --git a/recipes/python2/patches/fix-pwdmodule.patch b/recipes/python2/patches/fix-pwdmodule.patch deleted file mode 100644 index 5a89020f..00000000 --- a/recipes/python2/patches/fix-pwdmodule.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- Python-2.7.13/Modules/pwdmodule.c 2016-12-17 21:05:07.000000000 +0100 -+++ Python-2.7.13-modified/Modules/pwdmodule.c 2017-08-10 13:55:19.603089081 +0100 -@@ -75,7 +75,7 @@ - #endif - PyStructSequence_SET_ITEM(v, setIndex++, _PyInt_FromUid(p->pw_uid)); - PyStructSequence_SET_ITEM(v, setIndex++, _PyInt_FromGid(p->pw_gid)); --#ifdef __VMS -+#if defined(__VMS) || defined(ANDROID) - SETS(setIndex++, ""); - #else - SETS(setIndex++, p->pw_gecos); \ No newline at end of file diff --git a/recipes/python2/patches/fix-termios.patch b/recipes/python2/patches/fix-termios.patch deleted file mode 100644 index a114e276..00000000 --- a/recipes/python2/patches/fix-termios.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- Python-2.7.2.orig/Modules/termios.c 2012-06-12 02:49:39.780162534 +0200 -+++ Python-2.7.2/Modules/termios.c 2012-06-12 02:51:52.092157828 +0200 -@@ -227,6 +227,7 @@ - return Py_None; - } - -+#if 0 // No tcdrain defined for Android. - PyDoc_STRVAR(termios_tcdrain__doc__, - "tcdrain(fd) -> None\n\ - \n\ -@@ -246,6 +247,7 @@ - Py_INCREF(Py_None); - return Py_None; - } -+#endif - - PyDoc_STRVAR(termios_tcflush__doc__, - "tcflush(fd, queue) -> None\n\ -@@ -301,8 +303,10 @@ - METH_VARARGS, termios_tcsetattr__doc__}, - {"tcsendbreak", termios_tcsendbreak, - METH_VARARGS, termios_tcsendbreak__doc__}, -+#if 0 // No tcdrain defined for Android. - {"tcdrain", termios_tcdrain, - METH_VARARGS, termios_tcdrain__doc__}, -+#endif - {"tcflush", termios_tcflush, - METH_VARARGS, termios_tcflush__doc__}, - {"tcflow", termios_tcflow, diff --git a/recipes/python2/patches/modules-locales-2.7.13.patch b/recipes/python2/patches/modules-locales-2.7.13.patch deleted file mode 100644 index b3f1d007..00000000 --- a/recipes/python2/patches/modules-locales-2.7.13.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- Python-2.7.9/Modules/_localemodule.c.orig 2013-05-12 05:32:50.000000000 +0200 -+++ Python-2.7.9/Modules/_localemodule.c 2015-05-02 21:33:42.241092717 +0200 -@@ -20,6 +20,8 @@ This software comes with no warranty. Us - #include - #endif - -+#define ANDROID -+ - #ifdef HAVE_LANGINFO_H - #include - #endif -@@ -205,6 +207,7 @@ PyDoc_STRVAR(localeconv__doc__, - static PyObject* - PyLocale_localeconv(PyObject* self) - { -+ #ifndef ANDROID - PyObject* result; - struct lconv *l; - PyObject *x; -@@ -265,6 +268,7 @@ PyLocale_localeconv(PyObject* self) - failed: - Py_XDECREF(result); - Py_XDECREF(x); -+ #endif // ANDROID - return NULL; - } - diff --git a/recipes/python3crystax/__init__.py b/recipes/python3crystax/__init__.py new file mode 100644 index 00000000..9cc6814c --- /dev/null +++ b/recipes/python3crystax/__init__.py @@ -0,0 +1,258 @@ +from pythonforandroid.recipe import TargetPythonRecipe +from pythonforandroid.toolchain import shprint, current_directory, ArchARM +from pythonforandroid.logger import info, error +from pythonforandroid.util import ensure_dir, temp_directory +from os.path import exists, join +import os +import glob +import sh +from sh import Command + +# This is the content of opensslconf.h taken from +# ndkdir/build/tools/build-target-openssl.sh +OPENSSLCONF = """#if defined(__ARM_ARCH_5TE__) +#include "opensslconf_armeabi.h" +#elif defined(__ARM_ARCH_7A__) && !defined(__ARM_PCS_VFP) +#include "opensslconf_armeabi_v7a.h" +#elif defined(__ARM_ARCH_7A__) && defined(__ARM_PCS_VFP) +#include "opensslconf_armeabi_v7a_hard.h" +#elif defined(__aarch64__) +#include "opensslconf_arm64_v8a.h" +#elif defined(__i386__) +#include "opensslconf_x86.h" +#elif defined(__x86_64__) +#include "opensslconf_x86_64.h" +#elif defined(__mips__) && !defined(__mips64) +#include "opensslconf_mips.h" +#elif defined(__mips__) && defined(__mips64) +#include "opensslconf_mips64.h" +#else +#error "Unsupported ABI" +#endif +""" +LATEST_FULL_VERSION = { + '3.5': '3.5.1', + '3.6': '3.6.6', + '3.7': '3.7.0' +} + +def realpath(fname): + """ + Own implementation of os.realpath which may be broken in some python versions + Returns: the absolute path o + + """ + + if not os.path.islink(fname): + return os.path.abspath(fname) + + abs_path = os.path.abspath(fname).split(os.sep)[:-1] + rel_path = os.readlink(fname) + + if os.path.abspath(rel_path) == rel_path: + return rel_path + + rel_path = rel_path.split(os.sep) + for folder in rel_path: + if folder == '..': + abs_path.pop() + else: + abs_path.append(folder) + return os.sep.join(abs_path) + +class Python3Recipe(TargetPythonRecipe): + version = '3.6' + url = '' + name = 'python3crystax' + + depends = ['hostpython3crystax'] + conflicts = ['python2', 'python3'] + + from_crystax = True + + def download_if_necessary(self): + if 'openssl' in self.ctx.recipe_build_order or self.version == '3.6': + full_version = LATEST_FULL_VERSION[self.version] + Python3Recipe.url = 'https://www.python.org/ftp/python/{0}.{1}.{2}/Python-{0}.{1}.{2}.tgz'.format(*full_version.split('.')) + super(Python3Recipe, self).download_if_necessary() + + def get_dir_name(self): + name = super(Python3Recipe, self).get_dir_name() + name += '-version{}'.format(self.version) + return name + + def copy_include_dir(self, source, target): + ensure_dir(target) + for fname in os.listdir(source): + sh.ln('-sf', realpath(join(source, fname)), join(target, fname)) + + def _patch_dev_defaults(self, fp, target_ver): + for line in fp: + if 'OPENSSL_VERSIONS=' in line: + versions = line.split('"')[1].split(' ') + if versions[0] == target_ver: + raise ValueError('Patch not needed') + + if target_ver in versions: + versions.remove(target_ver) + + versions.insert(0, target_ver) + + yield 'OPENSSL_VERSIONS="{}"\n'.format(' '.join(versions)) + else: + yield line + + def patch_dev_defaults(self, ssl_recipe): + def_fname = join(self.ctx.ndk_dir, 'build', 'tools', 'dev-defaults.sh') + try: + with open(def_fname, 'r') as fp: + s = ''.join(self._patch_dev_defaults(fp, + str(ssl_recipe.version))) + with open(def_fname, 'w') as fp: + fp.write(s) + + except ValueError: + pass + + def check_for_sslso(self, ssl_recipe, arch): + # type: (Recipe, str) + dynlib_dir = join(self.ctx.ndk_dir, 'sources', 'python', self.version, + 'libs', arch.arch, 'modules') + + if os.path.exists(join(dynlib_dir, '_ssl.so')): + return 10, 'Shared object exists in ndk' + + # find out why _ssl.so is missing + + source_dir = join(self.ctx.ndk_dir, 'sources', 'openssl', ssl_recipe.version) + if not os.path.exists(source_dir): + return 0, 'Openssl version not present' + + # these two path checks are lifted straight from: + # crystax-ndk/build/tools/build-target-python.sh + if not os.path.exists(join(source_dir, 'Android.mk')): + return 1.1, 'Android.mk is missing in openssl source' + + include_dir = join(source_dir, 'include','openssl') + if not os.path.exists(join(include_dir, 'opensslconf.h')): + return 1.2, 'Openssl include dir missing' + + under_scored_arch = arch.arch.replace('-', '_') + if not os.path.lexists(join(include_dir, + 'opensslconf_{}.h'.format(under_scored_arch))): + return 1.3, 'Opensslconf arch header missing from include' + + + + # lastly a check to see whether shared objects for the correct arch + # is present in the ndk + if not os.path.exists(join(source_dir, 'libs', arch.arch)): + return 2, 'Openssl libs for this arch is missing in ndk' + + return 5, 'Ready to recompile python' + + def find_Android_mk(self): + openssl_dir = join(self.ctx.ndk_dir, 'sources', 'openssl') + for version in os.listdir(openssl_dir): + mk_path = join(openssl_dir, version, 'Android.mk') + if os.path.exists(mk_path): + return mk_path + + def prebuild_arch(self, arch): + super(Python3Recipe, self).prebuild_arch(arch) + if self.version == '3.6': + Python3Recipe.patches = ['patch_python3.6.patch'] + build_dir = self.get_build_dir(arch.arch) + shprint(sh.ln, '-sf', + realpath(join(build_dir, 'Lib/site-packages/README.txt')), + join(build_dir, 'Lib/site-packages/README')) + python_build_files = ['android.mk', 'config.c', 'interpreter.c'] + ndk_build_tools_python_dir = join(self.ctx.ndk_dir, 'build', 'tools', 'build-target-python') + for python_build_file in python_build_files: + shprint(sh.cp, join(ndk_build_tools_python_dir, python_build_file+'.3.5'), + join(ndk_build_tools_python_dir, python_build_file+'.3.6')) + ndk_sources_python_dir = join(self.ctx.ndk_dir, 'sources', 'python') + if not os.path.exists(join(ndk_sources_python_dir, '3.6')): + os.mkdir(join(ndk_sources_python_dir, '3.6')) + sh.sed('s#3.5#3.6#', + join(ndk_sources_python_dir, '3.5/Android.mk'), + _out=join(ndk_sources_python_dir, '3.6/Android.mk')) + + def build_arch(self, arch): + # If openssl is needed we may have to recompile cPython to get the + # ssl.py module working properly + if self.from_crystax and 'openssl' in self.ctx.recipe_build_order: + info('Openssl and crystax-python combination may require ' + 'recompilation of python...') + ssl_recipe = self.get_recipe('openssl', self.ctx) + stage, msg = self.check_for_sslso(ssl_recipe, arch) + stage = 0 if stage < 5 else stage + info(msg) + openssl_build_dir = ssl_recipe.get_build_dir(arch.arch) + openssl_ndk_dir = join(self.ctx.ndk_dir, 'sources', 'openssl', + ssl_recipe.version) + + if stage < 2: + info('Copying openssl headers and Android.mk to ndk') + ensure_dir(openssl_ndk_dir) + if stage < 1.2: + # copy include folder and Android.mk to ndk + mk_path = self.find_Android_mk() + if mk_path is None: + raise IOError('Android.mk file could not be found in ' + 'any versions in ndk->sources->openssl') + shprint(sh.cp, mk_path, openssl_ndk_dir) + + include_dir = join(openssl_build_dir, 'include') + if stage < 1.3: + ndk_include_dir = join(openssl_ndk_dir, 'include', 'openssl') + self.copy_include_dir(join(include_dir, 'openssl'), ndk_include_dir) + + target_conf = join(openssl_ndk_dir, 'include', 'openssl', + 'opensslconf.h') + shprint(sh.rm, '-f', target_conf) + # overwrite opensslconf.h + with open(target_conf, 'w') as fp: + fp.write(OPENSSLCONF) + + if stage < 1.4: + # move current conf to arch specific conf in ndk + under_scored_arch = arch.arch.replace('-', '_') + shprint(sh.ln, '-sf', + realpath(join(include_dir, 'openssl', 'opensslconf.h')), + join(openssl_ndk_dir, 'include', 'openssl', + 'opensslconf_{}.h'.format(under_scored_arch)) + ) + + if stage < 3: + info('Copying openssl libs to ndk') + arch_ndk_lib = join(openssl_ndk_dir, 'libs', arch.arch) + ensure_dir(arch_ndk_lib) + shprint(sh.ln, '-sf', + realpath(join(openssl_build_dir, 'libcrypto{}.so'.format(ssl_recipe.version))), + join(openssl_build_dir, 'libcrypto.so')) + shprint(sh.ln, '-sf', + realpath(join(openssl_build_dir, 'libssl{}.so'.format(ssl_recipe.version))), + join(openssl_build_dir, 'libssl.so')) + libs = ['libcrypto.a', 'libcrypto.so', 'libssl.a', 'libssl.so'] + cmd = [join(openssl_build_dir, lib) for lib in libs] + [arch_ndk_lib] + shprint(sh.cp, '-f', *cmd) + + if stage < 10: + info('Recompiling python-crystax') + self.patch_dev_defaults(ssl_recipe) + build_script = join(self.ctx.ndk_dir, 'build', 'tools', + 'build-target-python.sh') + + shprint(Command(build_script), + '--ndk-dir={}'.format(self.ctx.ndk_dir), + '--abis={}'.format(arch.arch), + '-j5', '--verbose', + self.get_build_dir(arch.arch)) + + info('Extracting CrystaX python3 from NDK package') + dirn = self.ctx.get_python_install_dir() + ensure_dir(dirn) + self.ctx.hostpython = 'python{}'.format(self.version) + +recipe = Python3Recipe() diff --git a/recipes/python3crystax/patch_python3.6.patch b/recipes/python3crystax/patch_python3.6.patch new file mode 100644 index 00000000..4402d1bd --- /dev/null +++ b/recipes/python3crystax/patch_python3.6.patch @@ -0,0 +1,89 @@ +diff --git a/Modules/expat/xmlparse.c b/Modules/expat/xmlparse.c +--- a/Modules/expat/xmlparse.c ++++ b/Modules/expat/xmlparse.c +@@ -84,6 +84,8 @@ + # define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 + #endif + ++#define XML_POOR_ENTROPY 1 ++ + #if !defined(HAVE_GETRANDOM) && !defined(HAVE_SYSCALL_GETRANDOM) \ + && !defined(HAVE_ARC4RANDOM_BUF) && !defined(HAVE_ARC4RANDOM) \ + && !defined(XML_DEV_URANDOM) \ +diff --git a/Modules/getpath.c b/Modules/getpath.c +--- a/Modules/getpath.c ++++ b/Modules/getpath.c +@@ -101,8 +101,35 @@ + #endif + + +-#if !defined(PREFIX) || !defined(EXEC_PREFIX) || !defined(VERSION) || !defined(VPATH) +-#error "PREFIX, EXEC_PREFIX, VERSION, and VPATH must be constant defined" ++ /* These variables were set this way in old versions of Python, but ++ changed somewhere between 3.5.0 and 3.5.3. Here we just force ++ the old way again. A better solution would be to work out where ++ they should be defined, and make the CrystaX build scripts do ++ so. */ ++ ++/* #if !defined(PREFIX) || !defined(EXEC_PREFIX) || !defined(VERSION) || !defined(VPATH) */ ++/* #error "PREFIX, EXEC_PREFIX, VERSION, and VPATH must be constant defined" */ ++/* #endif */ ++ ++#ifndef VERSION ++#define VERSION "2.1" ++#endif ++ ++#ifndef VPATH ++#define VPATH "." ++#endif ++ ++#ifndef PREFIX ++# define PREFIX "/usr/local" ++#endif ++ ++#ifndef EXEC_PREFIX ++#define EXEC_PREFIX PREFIX ++#endif ++ ++#ifndef PYTHONPATH ++#define PYTHONPATH PREFIX "/lib/python" VERSION ":" \ ++ EXEC_PREFIX "/lib/python" VERSION "/lib-dynload" + #endif + + #ifndef LANDMARK +diff --git a/Modules/timemodule.c b/Modules/timemodule.c +--- a/Modules/timemodule.c ++++ b/Modules/timemodule.c +@@ -358,18 +358,20 @@ time_gmtime(PyObject *self, PyObject *args) + #endif + } + +-#ifndef HAVE_TIMEGM +-static time_t +-timegm(struct tm *p) +-{ +- /* XXX: the following implementation will not work for tm_year < 1970. +- but it is likely that platforms that don't have timegm do not support +- negative timestamps anyways. */ +- return p->tm_sec + p->tm_min*60 + p->tm_hour*3600 + p->tm_yday*86400 + +- (p->tm_year-70)*31536000 + ((p->tm_year-69)/4)*86400 - +- ((p->tm_year-1)/100)*86400 + ((p->tm_year+299)/400)*86400; +-} +-#endif ++/* In the Android build, HAVE_TIMEGM apparently should be defined but isn't. A better fix would be to work out why and fix that. */ ++ ++/* #ifndef HAVE_TIMEGM */ ++/* static time_t */ ++/* timegm(struct tm *p) */ ++/* { */ ++/* /\* XXX: the following implementation will not work for tm_year < 1970. */ ++/* but it is likely that platforms that don't have timegm do not support */ ++/* negative timestamps anyways. *\/ */ ++/* return p->tm_sec + p->tm_min*60 + p->tm_hour*3600 + p->tm_yday*86400 + */ ++/* (p->tm_year-70)*31536000 + ((p->tm_year-69)/4)*86400 - */ ++/* ((p->tm_year-1)/100)*86400 + ((p->tm_year+299)/400)*86400; */ ++/* } */ ++/* #endif */ + + PyDoc_STRVAR(gmtime_doc, + "gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n\ diff --git a/recipes/requests/__init__.py b/recipes/requests/__init__.py new file mode 100644 index 00000000..f7a0290f --- /dev/null +++ b/recipes/requests/__init__.py @@ -0,0 +1,12 @@ +from pythonforandroid.recipe import PythonRecipe + + +class RequestsRecipe(PythonRecipe): + version = '2.13.0' + url = 'https://github.com/kennethreitz/requests/archive/v{version}.tar.gz' + depends = [('hostpython2', 'hostpython3crystax'), 'setuptools'] + site_packages_name = 'requests' + call_hostpython_via_targetpython = False + + +recipe = RequestsRecipe() \ No newline at end of file diff --git a/recipes/setuptools/__init__.py b/recipes/setuptools/__init__.py index c67d434a..21e89b17 100644 --- a/recipes/setuptools/__init__.py +++ b/recipes/setuptools/__init__.py @@ -1,23 +1,14 @@ - -from pythonforandroid.toolchain import ( - PythonRecipe, - Recipe, - current_directory, - info, - shprint, -) -from os.path import join -import sh +from pythonforandroid.recipe import PythonRecipe class SetuptoolsRecipe(PythonRecipe): - version = '18.5' - url = 'https://pypi.python.org/packages/source/s/setuptools/setuptools-{version}.tar.gz' + version = '40.0.0' + url = 'https://pypi.python.org/packages/source/s/setuptools/setuptools-{version}.zip' - depends = ['python2'] + depends = [('python2', 'python3crystax')] call_hostpython_via_targetpython = False install_in_hostpython = True -recipe = SetuptoolsRecipe() +recipe = SetuptoolsRecipe() \ No newline at end of file diff --git a/recipes/six/__init__.py b/recipes/six/__init__.py index e03eeb05..92b266f4 100644 --- a/recipes/six/__init__.py +++ b/recipes/six/__init__.py @@ -6,6 +6,5 @@ class SixRecipe(PythonRecipe): version = '1.9.0' url = 'https://pypi.python.org/packages/source/s/six/six-{version}.tar.gz' depends = [('python2', 'python3crystax')] - call_hostpython_via_targetpython = False recipe = SixRecipe() diff --git a/recipes/twisted/__init__.py b/recipes/twisted/__init__.py index 753a107f..852291ac 100644 --- a/recipes/twisted/__init__.py +++ b/recipes/twisted/__init__.py @@ -12,10 +12,10 @@ import sh class TwistedRecipe(CythonRecipe): - version = '16.6.0' + version = '18.7.0' url = 'https://github.com/twisted/twisted/archive/twisted-{version}.tar.gz' - depends = ['setuptools', 'zope_interface'] + depends = ['setuptools', 'zope_interface', 'incremental', 'constantly'] call_hostpython_via_targetpython = False install_in_hostpython = True @@ -29,10 +29,10 @@ class TwistedRecipe(CythonRecipe): env = super(TwistedRecipe, self).get_recipe_env(arch) # TODO: Move this and others to base Recipe class for Cython and CompiledComponent recipes - target_python = Recipe.get_recipe('python2', self.ctx).get_build_dir(arch.arch) + target_python = Recipe.get_recipe('python3crystax', self.ctx).get_build_dir(arch.arch) env['PYTHON_ROOT'] = join(target_python, 'python-install') - env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' - env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython2.7' + env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python3.6' + env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython3.6m' # We add BUILDLIB_PATH to PYTHONPATH so twisted can find _io.so env['PYTHONPATH'] = ':'.join([ diff --git a/recipes/unqlite/__init__.py b/recipes/unqlite/__init__.py deleted file mode 100644 index a47be77a..00000000 --- a/recipes/unqlite/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -import glob -from pythonforandroid.toolchain import ( - CythonRecipe, - Recipe, - current_directory, - info, - shprint, -) -from os.path import join -import sh - - -class UnqliteRecipe(CythonRecipe): - version = '0.6.0' - url = 'https://pypi.python.org/packages/cb/4e/e1f64a3d0f6462167805940b4c72f47bafc1129e363fc4c0f79a1cdc5dd1/unqlite-{version}.tar.gz' - depends = ['python2', 'setuptools'] - call_hostpython_via_targetpython = False - - patches = ['setup.patch'] - - def get_recipe_env(self, arch): - env = super(UnqliteRecipe, self).get_recipe_env(arch) - - target_python = Recipe.get_recipe('python2', self.ctx).get_build_dir(arch.arch) - env['PYTHON_ROOT'] = join(target_python, 'python-install') - env['CFLAGS'] += ' -I' + env['PYTHON_ROOT'] + '/include/python2.7' - env['LDFLAGS'] += ' -L' + env['PYTHON_ROOT'] + '/lib' + ' -lpython2.7' - - return env - - -recipe = UnqliteRecipe() diff --git a/recipes/unqlite/setup.patch b/recipes/unqlite/setup.patch deleted file mode 100644 index 69c865d0..00000000 --- a/recipes/unqlite/setup.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/setup.py 2016-08-22 19:45:52.000000000 +0100 -+++ b/setup.py 2017-09-16 01:35:36.675202502 +0100 -@@ -1,11 +1,7 @@ - import glob --from distutils.core import setup, Extension -- --try: -- from Cython.Build import cythonize --except ImportError: -- raise RuntimeError('Cython must be installed to build unqlite-python.') -- -+from setuptools import setup -+from setuptools.extension import Extension -+from setuptools.command.build_ext import build_ext - - python_source = 'unqlite.pyx' - library_source = glob.glob('src/*.c') -@@ -45,5 +41,7 @@ - 'Topic :: Database :: Database Engines/Servers', - 'Topic :: Software Development :: Embedded Systems', - 'Topic :: Software Development :: Libraries :: Python Modules'], -- ext_modules=cythonize(unqlite_extension) -+ cmdclass = {'build_ext': build_ext}, -+ ext_modules=[unqlite_extension] - ) -+ diff --git a/recipes/zope_interface/__init__.py b/recipes/zope_interface/__init__.py new file mode 100644 index 00000000..3091f2a0 --- /dev/null +++ b/recipes/zope_interface/__init__.py @@ -0,0 +1,21 @@ +from pythonforandroid.recipe import PythonRecipe +from pythonforandroid.toolchain import current_directory +import sh + + +class ZopeInterfaceRecipe(PythonRecipe): + name = 'zope_interface' + version = '4.2.0' + url = 'https://pypi.python.org/packages/source/z/zope.interface/zope.interface-{version}.tar.gz' + site_packages_name = 'zope.interface' + + depends = [('python2', 'python3crystax')] + patches = ['no_tests.patch'] + + def prebuild_arch(self, arch): + super(ZopeInterfaceRecipe, self).prebuild_arch(arch) + with current_directory(self.get_build_dir(arch.arch)): + sh.rm('-rf', 'src/zope/interface/tests', 'src/zope/interface/common/tests') + + +recipe = ZopeInterfaceRecipe() diff --git a/recipes/zope_interface/no_tests.patch b/recipes/zope_interface/no_tests.patch new file mode 100644 index 00000000..289c850b --- /dev/null +++ b/recipes/zope_interface/no_tests.patch @@ -0,0 +1,13 @@ +--- a/setup.py 2016-06-10 14:56:35.000000000 +0100 ++++ b/setup.py 2018-09-29 09:28:25.676203522 +0100 +@@ -139,9 +139,8 @@ + "Topic :: Software Development :: Libraries :: Python Modules", + ], + +- packages = ['zope', 'zope.interface', 'zope.interface.tests'], ++ packages = ['zope', 'zope.interface'], + package_dir = {'': 'src'}, + cmdclass = {'build_ext': optional_build_ext, + }, +- test_suite = 'zope.interface.tests', + **extra) diff --git a/recipes/zope_interface/setuptools.patch b/recipes/zope_interface/setuptools.patch new file mode 100644 index 00000000..957027c4 --- /dev/null +++ b/recipes/zope_interface/setuptools.patch @@ -0,0 +1,10 @@ +--- a/setup.py 2016-12-14 00:02:45.000000000 +0100 ++++ b/setup.py 2018-09-29 00:14:20.235641125 +0100 +@@ -131,7 +131,6 @@ + include_package_data=True, + zip_safe=False, + tests_require=tests_require, +- install_requires=['setuptools'], + extras_require={ + 'docs': ['Sphinx', 'repoze.sphinx.autointerface'], + 'test': tests_require, diff --git a/scripts/build-target-python.sh b/scripts/build-target-python.sh new file mode 100755 index 00000000..04fe3e01 --- /dev/null +++ b/scripts/build-target-python.sh @@ -0,0 +1,921 @@ +#!/bin/bash + +# Copyright (c) 2011-2015 CrystaX. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are +# permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this list of +# conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, this list +# of conditions and the following disclaimer in the documentation and/or other materials +# provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY CrystaX ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CrystaX OR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are those of the +# authors and should not be interpreted as representing official policies, either expressed +# or implied, of CrystaX. + +# include common function and variable definitions +. `dirname $0`/prebuilt-common.sh + +PROGRAM_PARAMETERS="" + +PROGRAM_DESCRIPTION=\ +"Rebuild python libraries for the CrystaX NDK. + +This requires a temporary NDK installation containing +toolchain binaries for all target architectures. + +By default, this will try with the current NDK directory, unless +you use the --ndk-dir= option. + +The output will be placed in appropriate sub-directories of +/$PYTHON_SUBDIR, but you can override this with the --out-dir= +option. +" + +PACKAGE_DIR= +register_var_option "--package-dir=" PACKAGE_DIR "Put prebuilt tarballs into " + +NDK_DIR=$ANDROID_NDK_ROOT +register_var_option "--ndk-dir=" NDK_DIR "Specify NDK root path for the build" + +BUILD_DIR= +OPTION_BUILD_DIR= +register_var_option "--build-dir=" OPTION_BUILD_DIR "Specify temporary build dir" + +ABIS=$PREBUILT_ABIS +register_var_option "--abis=" ABIS "Specify list of target ABIs" + +register_jobs_option + +extract_parameters "$@" + +PYTHON_SRCDIR=$(echo $PARAMETERS | sed 1q) +if [ -z "$PYTHON_SRCDIR" ]; then + echo "ERROR: Please provide the path to the python source tree. See --help" + exit 1 +fi + +if [ ! -d "$PYTHON_SRCDIR" ]; then + echo "ERROR: No such directory: '$PYTHON_SRCDIR'" + exit 1 +fi + +PYTHON_SRCDIR=$(cd $PYTHON_SRCDIR && pwd) + +PYTHON_MAJOR_VERSION=\ +$(cat $PYTHON_SRCDIR/Include/patchlevel.h | sed -n 's/#define[ \t]*PY_MAJOR_VERSION[ \t]*\([0-9]*\).*/\1/p') + +PYTHON_MINOR_VERSION=\ +$(cat $PYTHON_SRCDIR/Include/patchlevel.h | sed -n 's/#define[ \t]*PY_MINOR_VERSION[ \t]*\([0-9]*\).*/\1/p') + +if [ -z "$PYTHON_MAJOR_VERSION" ]; then + echo "ERROR: Can't detect python major version." 1>&2 + exit 1 +fi + +if [ -z "$PYTHON_MINOR_VERSION" ]; then + echo "ERROR: Can't detect python minor version." 1>&2 + exit 1 +fi + +PYTHON_ABI="$PYTHON_MAJOR_VERSION"'.'"$PYTHON_MINOR_VERSION" +PYTHON_DSTDIR=$NDK_DIR/$PYTHON_SUBDIR/$PYTHON_ABI +mkdir -p $PYTHON_DSTDIR +fail_panic "Can't create python destination directory: $PYTHON_DSTDIR" + +PYTHON_BUILD_UTILS_DIR=$(cd $(dirname $0)/build-target-python && pwd) +if [ ! -d "$PYTHON_BUILD_UTILS_DIR" ]; then + echo "ERROR: No such directory: '$PYTHON_BUILD_UTILS_DIR'" + exit 1 +fi + +PY_C_CONFIG_FILE="$PYTHON_BUILD_UTILS_DIR/config.c.$PYTHON_ABI" +if [ ! -f "$PY_C_CONFIG_FILE" ]; then + echo "ERROR: Build of python $PYTHON_ABI is not supported, no such file: $PY_C_CONFIG_FILE" + exit 1 +fi + +PY_C_INTERPRETER_FILE="$PYTHON_BUILD_UTILS_DIR/interpreter.c.$PYTHON_ABI" +if [ ! -f "$PY_C_INTERPRETER_FILE" ]; then + echo "ERROR: Build of python $PYTHON_ABI is not supported, no such file: $PY_C_INTERPRETER_FILE" + exit 1 +fi + +PY_ANDROID_MK_TEMPLATE_FILE="$PYTHON_BUILD_UTILS_DIR/android.mk.$PYTHON_ABI" +if [ ! -f "$PY_ANDROID_MK_TEMPLATE_FILE" ]; then + echo "ERROR: Build of python $PYTHON_ABI is not supported, no such file: $PY_ANDROID_MK_TEMPLATE_FILE" + exit 1 +fi + +ABIS=$(commas_to_spaces $ABIS) + +if [ -z "$OPTION_BUILD_DIR" ]; then + BUILD_DIR=$NDK_TMPDIR/build-python +else + eval BUILD_DIR=$OPTION_BUILD_DIR +fi + +rm -rf "$BUILD_DIR" +mkdir -p "$BUILD_DIR" +fail_panic "Can't create build directory: $BUILD_DIR" + +OPENSSL_HOME='' +if [ -n "$DEFAULT_OPENSSL_VERSION" ]; then + if [ -f "$NDK_DIR/$OPENSSL_SUBDIR/$DEFAULT_OPENSSL_VERSION/Android.mk" \ + -a -f "$NDK_DIR/$OPENSSL_SUBDIR/$DEFAULT_OPENSSL_VERSION/include/openssl/opensslconf.h" ]; then + OPENSSL_HOME="openssl/$DEFAULT_OPENSSL_VERSION" + fi +fi + +# $1: ABI +# $2: build directory +build_python_for_abi () +{ + local ABI="$1" + local BUILDDIR="$2" + local PYBIN_INSTALLDIR=$PYTHON_DSTDIR/libs/$ABI + local PYBIN_INSTALLDIR_MODULES="$PYBIN_INSTALLDIR/modules" + if [ -n "$OPENSSL_HOME" ]; then + log "Building python$PYTHON_ABI for $ABI (with OpenSSL-$DEFAULT_OPENSSL_VERSION)" + else + log "Building python$PYTHON_ABI for $ABI (without OpenSSL support)" + fi + +# Step 1: configure + local BUILDDIR_CONFIG="$BUILDDIR/config" + local BUILDDIR_CORE="$BUILDDIR/core" + local OBJDIR_CORE="$BUILDDIR_CORE/obj/local/$ABI" + + run mkdir -p $BUILDDIR_CONFIG + fail_panic "Can't create directory: $BUILDDIR_CONFIG" + run mkdir -p $BUILDDIR_CORE + fail_panic "Can't create directory: $BUILDDIR_CORE" + + local BUILD_ON_PLATFORM=$($PYTHON_SRCDIR/config.guess) + if [ -z "$BUILD_ON_PLATFORM" ]; then + echo "ERROR: Can't resolve platform being built python on." 1>&2 + exit 1 + fi + + local ARCH + case $ABI in + armeabi*) + ARCH=arm + ;; + arm64*) + ARCH=arm64 + ;; + x86|x86_64|mips|mips64) + ARCH=$ABI + ;; + *) + echo "ERROR: Unknown ABI: '$ABI'" 1>&2 + exit 1 + esac + + local HOST + case $ABI in + armeabi*) + HOST=arm-linux-androideabi + ;; + arm64*) + HOST=aarch64-linux-android + ;; + x86) + HOST=i686-linux-android + ;; + x86_64) + HOST=x86_64-linux-android + ;; + mips) + HOST=mipsel-linux-android + ;; + mips64) + HOST=mips64el-linux-android + ;; + *) + echo "ERROR: Unknown ABI: '$ABI'" 1>&2 + exit 1 + esac + + local APILEVEL + case $ABI in + armeabi*|x86|mips) + APILEVEL=21 + ;; + arm64*|x86_64|mips64) + APILEVEL=21 + ;; + *) + echo "ERROR: Unknown ABI: '$ABI'" 1>&2 + exit 1 + esac + + local TOOLCHAIN + case $ABI in + armeabi*) + TOOLCHAIN=arm-linux-androideabi + ;; + x86) + TOOLCHAIN=x86 + ;; + mips) + TOOLCHAIN=mipsel-linux-android + ;; + arm64-v8a) + TOOLCHAIN=aarch64-linux-android + ;; + x86_64) + TOOLCHAIN=x86_64 + ;; + mips64) + TOOLCHAIN=mips64el-linux-android + ;; + *) + echo "ERROR: Unknown ABI: '$ABI'" 1>&2 + exit 1 + esac + + case $ABI in + armeabi) + CFLAGS="-march=armv5te -mtune=xscale -msoft-float" + ;; + armeabi-v7a) + CFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp" + ;; + armeabi-v7a-hard) + CFLAGS="-march=armv7-a -mfpu=vfpv3-d16 -mhard-float" + ;; + *) + CFLAGS="" + esac + + case $ABI in + armeabi*) + CFLAGS="$CFLAGS -mthumb" + esac + + local CFLAGS="$CFLAGS --sysroot=$NDK_DIR/platforms/android-$APILEVEL/arch-$ARCH" + + local LDFLAGS="" + if [ "$ABI" = "armeabi-v7a-hard" ]; then + LDFLAGS="$LDFLAGS -Wl,--no-warn-mismatch" + fi + LDFLAGS="$LDFLAGS -L$NDK_DIR/sources/crystax/libs/$ABI --sysroot=$NDK_DIR/platforms/android-$APILEVEL/arch-$ARCH" + + local TCPREFIX=$NDK_DIR/toolchains/${TOOLCHAIN}-4.9/prebuilt/$HOST_TAG + + + local CC=$TCPREFIX/bin/${HOST}-gcc + local CPP="$CC $CFLAGS -E" + local AR=$TCPREFIX/bin/${HOST}-ar + local RANLIB=$TCPREFIX/bin/${HOST}-ranlib + local READELF=$TCPREFIX/bin/${HOST}-readelf + local PYTHON_FOR_BUILD=$NDK_DIR/prebuilt/$HOST_TAG/bin/python + local CONFIG_SITE=$PYTHON_TOOLS_DIR/config.site + + local CONFIG_SITE=$BUILDDIR_CONFIG/config.site + { + echo 'ac_cv_file__dev_ptmx=no' + echo 'ac_cv_file__dev_ptc=no' + echo 'ac_cv_func_gethostbyname_r=no' + if [ "$PYTHON_MAJOR_VERSION" == "3" ]; then + echo 'ac_cv_func_faccessat=no' + fi + } >$CONFIG_SITE + fail_panic "Can't create config.site wrapper" + + local CONFIGURE_WRAPPER=$BUILDDIR_CONFIG/configure.sh + { + echo "#!/bin/bash -e" + echo '' + echo "export CC=\"$CC\"" + echo "export CPP=\"$CPP\"" + echo "export AR=\"$AR\"" + echo "export CFLAGS=\"$CFLAGS\"" + echo "export LDFLAGS=\"$LDFLAGS\"" + echo "export RANLIB=\"$RANLIB\"" + echo "export READELF=\"$READELF\"" + echo "export PYTHON_FOR_BUILD=\"$PYTHON_FOR_BUILD\"" + echo "export CONFIG_SITE=\"$CONFIG_SITE\"" + echo '' + echo 'cd $(dirname $0)' + echo '' + if [ "$PYTHON_MAJOR_VERSION" = "2" ]; then + echo "exec $PYTHON_SRCDIR/configure \\" + echo " --host=$HOST \\" + echo " --build=$BUILD_ON_PLATFORM \\" + echo " --prefix=$BUILDDIR_CONFIG/install \\" + echo " --enable-shared \\" + echo " --with-threads \\" + echo " --enable-ipv6 \\" + echo " --enable-unicode=ucs4 \\" + echo " --without-ensurepip" + else + echo "exec $PYTHON_SRCDIR/configure \\" + echo " --host=$HOST \\" + echo " --build=$BUILD_ON_PLATFORM \\" + echo " --prefix=$BUILDDIR_CONFIG/install \\" + echo " --enable-shared \\" + echo " --with-threads \\" + echo " --enable-ipv6 \\" + echo " --with-computed-gotos \\" + echo " --without-ensurepip" + fi + } >$CONFIGURE_WRAPPER + fail_panic "Can't create configure wrapper" + + chmod +x $CONFIGURE_WRAPPER + fail_panic "Can't chmod +x configure wrapper" + + run $CONFIGURE_WRAPPER + fail_panic "Can't configure python$PYTHON_ABI for $ABI" + +# Step 2: build python-core + run mkdir -p $BUILDDIR_CORE/jni + fail_panic "Can't create directory: $BUILDDIR_CORE/jni" + + run cp -p -T $PY_C_CONFIG_FILE "$BUILDDIR_CORE/jni/config.c" && \ + cp -p -t "$BUILDDIR_CORE/jni" "$PYTHON_BUILD_UTILS_DIR/pyconfig.h" + fail_panic "Can't copy config.c pyconfig.h to $BUILDDIR_CORE/jni" + + if [ "$PYTHON_MAJOR_VERSION" = "2" ]; then + local PY_C_GETPATH="$PYTHON_BUILD_UTILS_DIR/getpath.c.$PYTHON_ABI" + run cp -p -T $PY_C_GETPATH "$BUILDDIR_CORE/jni/getpath.c" + fail_panic "Can't copy $PY_C_GETPATH to $BUILDDIR_CORE/jni" + fi + + local PYCONFIG_FOR_ABI="$BUILDDIR_CORE/jni/pyconfig_$(echo $ABI | tr '-' '_').h" + run cp -p -T $BUILDDIR_CONFIG/pyconfig.h $PYCONFIG_FOR_ABI + fail_panic "Can't copy $BUILDDIR_CONFIG/pyconfig.h to $PYCONFIG_FOR_ABI" + + if [ "$PYTHON_MAJOR_VERSION" = "2" ]; then + local PYTHON_CORE_MODULE_NAME='python'"$PYTHON_ABI" + else + local PYTHON_CORE_MODULE_NAME='python'"$PYTHON_ABI"'m' + local PYTHON_SOABI='cpython-'"$PYTHON_ABI"'m' + fi + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo "LOCAL_MODULE := $PYTHON_CORE_MODULE_NAME" + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_C_INCLUDES := $(MY_PYTHON_SRC_ROOT)/Include' + if [ "$PYTHON_MAJOR_VERSION" = "2" ]; then + echo "LOCAL_CFLAGS := -DPy_BUILD_CORE -DPy_ENABLE_SHARED -DPLATFORM=\\\"linux\\\"" + else + echo "LOCAL_CFLAGS := -DSOABI=\\\"$PYTHON_SOABI\\\" -DPy_BUILD_CORE -DPy_ENABLE_SHARED -DPLATFORM=\\\"linux\\\"" + fi + echo 'LOCAL_LDLIBS := -lz' + cat $PY_ANDROID_MK_TEMPLATE_FILE + echo 'include $(BUILD_SHARED_LIBRARY)' + } >$BUILDDIR_CORE/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_CORE/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_CORE -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI core" + + if [ "$PYTHON_HEADERS_INSTALLED" != "yes" ]; then + log "Install python$PYTHON_ABI headers into $PYTHON_DSTDIR" + run rm -Rf $PYTHON_DSTDIR/include + run mkdir -p $PYTHON_DSTDIR/include/python && \ + run cp -p $PYTHON_BUILD_UTILS_DIR/pyconfig.h $PYTHON_SRCDIR/Include/*.h $PYTHON_DSTDIR/include/python + fail_panic "Can't install python$PYTHON_ABI headers" + PYTHON_HEADERS_INSTALLED=yes + export PYTHON_HEADERS_INSTALLED + fi + log "Install $(basename $PYCONFIG_FOR_ABI) into $PYTHON_DSTDIR" + run cp -p $PYCONFIG_FOR_ABI $PYTHON_DSTDIR/include/python + fail_panic "Can't install $PYCONFIG_FOR_ABI" + + run mkdir -p $PYBIN_INSTALLDIR + fail_panic "Can't create $PYBIN_INSTALLDIR" + run mkdir -p $PYBIN_INSTALLDIR_MODULES + fail_panic "Can't create directory: $PYBIN_INSTALLDIR_MODULES" + + log "Install python$PYTHON_ABI-$ABI core in $PYBIN_INSTALLDIR" + run cp -fpH $OBJDIR_CORE/lib$PYTHON_CORE_MODULE_NAME.so $PYBIN_INSTALLDIR + fail_panic "Can't install python$PYTHON_ABI-$ABI core in $PYBIN_INSTALLDIR" + +# Step 3: build python-interpreter + local BUILDDIR_INTERPRETER="$BUILDDIR/interpreter" + local OBJDIR_INTERPRETER="$BUILDDIR_INTERPRETER/obj/local/$ABI" + + run mkdir -p $BUILDDIR_INTERPRETER/jni + fail_panic "Can't create directory: $BUILDDIR_INTERPRETER/jni" + + run cp -p -T $PY_C_INTERPRETER_FILE $BUILDDIR_INTERPRETER/jni/interpreter.c + fail_panic "Can't copy $PY_C_INTERPRETER_FILE to $BUILDDIR_INTERPRETER/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := python' + echo 'LOCAL_SRC_FILES := interpreter.c' + echo 'include $(BUILD_EXECUTABLE)' + } >$BUILDDIR_INTERPRETER/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_INTERPRETER/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_INTERPRETER -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI interpreter" + + log "Install python$PYTHON_ABI-$ABI interpreter in $PYBIN_INSTALLDIR" + run cp -fpH $OBJDIR_INTERPRETER/python $PYBIN_INSTALLDIR + fail_panic "Can't install python$PYTHON_ABI-$ABI interpreter in $PYBIN_INSTALLDIR" + +# Step 4: build python stdlib + local PYSTDLIB_ZIPFILE="$PYBIN_INSTALLDIR/stdlib.zip" + log "Install python$PYTHON_ABI-$ABI stdlib as $PYSTDLIB_ZIPFILE" + if [ "$PYTHON_MAJOR_VERSION" = "2" ]; then + run $PYTHON_FOR_BUILD $PYTHON_BUILD_UTILS_DIR/build_stdlib.py --py2 --pysrc-root $PYTHON_SRCDIR --output-zip $PYSTDLIB_ZIPFILE + fail_panic "Can't install python$PYTHON_ABI-$ABI stdlib" + else + run $PYTHON_FOR_BUILD $PYTHON_BUILD_UTILS_DIR/build_stdlib.py --pysrc-root $PYTHON_SRCDIR --output-zip $PYSTDLIB_ZIPFILE + fail_panic "Can't install python$PYTHON_ABI-$ABI stdlib" + fi + +# Step 5: site-packages + local SITE_README_SRCDIR="$PYTHON_SRCDIR/Lib/site-packages" + local SITE_README_DSTDIR="$PYBIN_INSTALLDIR/site-packages" + log "Install python$PYTHON_ABI-$ABI site-packages" + run mkdir -p $SITE_README_DSTDIR && cp -fpH $SITE_README_SRCDIR/README $SITE_README_DSTDIR + fail_panic "Can't install python$PYTHON_ABI-$ABI site-packages" + +# Step 6: build python modules +# _ctypes + local BUILDDIR_CTYPES="$BUILDDIR/ctypes" + local OBJDIR_CTYPES="$BUILDDIR_CTYPES/obj/local/$ABI" + local BUILDDIR_CTYPES_CONFIG="$BUILDDIR_CTYPES/config" + run mkdir -p $BUILDDIR_CTYPES_CONFIG + fail_panic "Can't create directory: $BUILDDIR_CTYPES_CONFIG" + + local LIBFFI_CONFIGURE_WRAPPER=$BUILDDIR_CTYPES_CONFIG/configure.sh + { + echo "#!/bin/bash -e" + echo '' + echo "export CC=\"$CC\"" + echo "export CFLAGS=\"$CFLAGS\"" + echo "export LDFLAGS=\"$LDFLAGS\"" + echo "export CPP=\"$CPP\"" + echo "export AR=\"$AR\"" + echo "export RANLIB=\"$RANLIB\"" + echo '' + echo 'cd $(dirname $0)' + echo '' + echo "exec $PYTHON_SRCDIR/Modules/_ctypes/libffi/configure \\" + echo " --host=$HOST \\" + echo " --build=$BUILD_ON_PLATFORM \\" + echo " --prefix=$BUILDDIR_CTYPES_CONFIG/install \\" + } >$LIBFFI_CONFIGURE_WRAPPER + fail_panic "Can't create configure wrapper for libffi" + + chmod +x $LIBFFI_CONFIGURE_WRAPPER + fail_panic "Can't chmod +x configure wrapper for libffi" + + run $LIBFFI_CONFIGURE_WRAPPER + fail_panic "Can't configure libffi for $ABI" + + run mkdir -p "$BUILDDIR_CTYPES/jni" + fail_panic "Can't create directory: $BUILDDIR_CTYPES/jni" + + run mkdir -p "$BUILDDIR_CTYPES/jni/include" + fail_panic "Can't create directory: $BUILDDIR_CTYPES/jni/include" + + run cp -p $BUILDDIR_CTYPES_CONFIG/fficonfig.h $BUILDDIR_CTYPES_CONFIG/include/*.h $BUILDDIR_CTYPES/jni/include + fail_panic "Can't copy configured libffi headers" + + local FFI_SRC_LIST + case $ABI in + x86) + FFI_SRC_LIST="src/x86/ffi.c src/x86/sysv.S src/x86/win32.S" + ;; + x86_64) + FFI_SRC_LIST="src/x86/ffi64.c src/x86/unix64.S" + ;; + armeabi*) + FFI_SRC_LIST="src/arm/ffi.c src/arm/sysv.S" + ;; + arm64-v8a) + FFI_SRC_LIST="src/aarch64/ffi.c src/aarch64/sysv.S" + ;; + mips) + FFI_SRC_LIST="src/mips/ffi.c src/mips/o32.S" + ;; + mips64) + FFI_SRC_LIST="src/mips/ffi.c src/mips/o32.S src/mips/n32.S" + ;; + *) + echo "ERROR: Unknown ABI: '$ABI'" 1>&2 + exit 1 + esac + FFI_SRC_LIST="$FFI_SRC_LIST src/prep_cif.c" + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := _ctypes' + echo 'LOCAL_C_INCLUDES := $(LOCAL_PATH)/include' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_SRC_FILES := \' + for ffi_src in $FFI_SRC_LIST; do + echo " \$(MY_PYTHON_SRC_ROOT)/Modules/_ctypes/libffi/$ffi_src \\" + done + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_ctypes/callbacks.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_ctypes/callproc.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_ctypes/cfield.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_ctypes/malloc_closure.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_ctypes/stgdict.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_ctypes/_ctypes.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + } >$BUILDDIR_CTYPES/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_CTYPES/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_CTYPES -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module '_ctypes'" + + log "Install python$PYTHON_ABI-$ABI module '_ctypes' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_CTYPES/lib_ctypes.so $PYBIN_INSTALLDIR_MODULES/_ctypes.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module '_ctypes' in $PYBIN_INSTALLDIR_MODULES" + +# _multiprocessing + local BUILDDIR_MULTIPROCESSING="$BUILDDIR/multiprocessing" + local OBJDIR_MULTIPROCESSING="$BUILDDIR_MULTIPROCESSING/obj/local/$ABI" + + run mkdir -p "$BUILDDIR_MULTIPROCESSING/jni" + fail_panic "Can't create directory: $BUILDDIR_MULTIPROCESSING/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := _multiprocessing' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_SRC_FILES := \' + if [ "$PYTHON_MAJOR_VERSION" = "2" ]; then + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_multiprocessing/socket_connection.c \' + fi + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_multiprocessing/multiprocessing.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_multiprocessing/semaphore.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + } >$BUILDDIR_MULTIPROCESSING/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_MULTIPROCESSING/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_MULTIPROCESSING -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module '_multiprocessing'" + + log "Install python$PYTHON_ABI-$ABI module '_multiprocessing' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_MULTIPROCESSING/lib_multiprocessing.so $PYBIN_INSTALLDIR_MODULES/_multiprocessing.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module '_multiprocessing' in $PYBIN_INSTALLDIR_MODULES" + +# _socket + local BUILDDIR_SOCKET="$BUILDDIR/socket" + local OBJDIR_SOCKET="$BUILDDIR_SOCKET/obj/local/$ABI" + + run mkdir -p "$BUILDDIR_SOCKET/jni" + fail_panic "Can't create directory: $BUILDDIR_SOCKET/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := _socket' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_SRC_FILES := \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/socketmodule.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + } >$BUILDDIR_SOCKET/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_SOCKET/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_SOCKET -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module '_socket'" + + log "Install python$PYTHON_ABI-$ABI module '_socket' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_SOCKET/lib_socket.so $PYBIN_INSTALLDIR_MODULES/_socket.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module '_socket' in $PYBIN_INSTALLDIR_MODULES" + +#_ssl + if [ -n "$OPENSSL_HOME" ]; then + local BUILDDIR_SSL="$BUILDDIR/ssl" + local OBJDIR_SSL="$BUILDDIR_SSL/obj/local/$ABI" + + run mkdir -p "$BUILDDIR_SSL/jni" + fail_panic "Can't create directory: $BUILDDIR_SSL/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := _ssl' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_SRC_FILES := \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_ssl.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared openssl_static opencrypto_static' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + echo "\$(call import-module,$OPENSSL_HOME)" + } >$BUILDDIR_SSL/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_SSL/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_SSL -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module '_ssl'" + + log "Install python$PYTHON_ABI-$ABI module '_ssl' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_SSL/lib_ssl.so $PYBIN_INSTALLDIR_MODULES/_ssl.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module '_ssl' in $PYBIN_INSTALLDIR_MODULES" + fi + +# _hashlib + if [ -n "$OPENSSL_HOME" ]; then + local BUILDDIR_HASHLIB="$BUILDDIR/hashlib" + local OBJDIR_HASHLIB="$BUILDDIR_HASHLIB/obj/local/$ABI" + + run mkdir -p "$BUILDDIR_HASHLIB/jni" + fail_panic "Can't create directory: $BUILDDIR_HASHLIB/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := _hashlib' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_SRC_FILES := \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_hashopenssl.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared openssl_static opencrypto_static' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + echo "\$(call import-module,$OPENSSL_HOME)" + } >$BUILDDIR_HASHLIB/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_HASHLIB/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_HASHLIB -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module '_hashlib'" + + log "Install python$PYTHON_ABI-$ABI module '_hashlib' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_HASHLIB/lib_hashlib.so $PYBIN_INSTALLDIR_MODULES/_hashlib.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module '_hashlib' in $PYBIN_INSTALLDIR_MODULES" + fi + +# _blake2 + if [ -n "$OPENSSL_HOME" ]; then + local BUILDDIR_BLAKE2="$BUILDDIR/blake2" + local OBJDIR_BLAKE2="$BUILDDIR_BLAKE2/obj/local/$ABI" + + run mkdir -p "$BUILDDIR_BLAKE2/jni" + fail_panic "Can't create directory: $BUILDDIR_BLAKE2/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := _blake2' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_SRC_FILES := \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_blake2/blake2module.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_blake2/blake2b_impl.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_blake2/blake2s_impl.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + echo "\$(call import-module,$OPENSSL_HOME)" + } >$BUILDDIR_BLAKE2/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_BLAKE2/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_BLAKE2 -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module '_blake2'" + + log "Install python$PYTHON_ABI-$ABI module '_blake2' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_BLAKE2/lib_blake2.so $PYBIN_INSTALLDIR_MODULES/_blake2.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module '_blake2' in $PYBIN_INSTALLDIR_MODULES" + fi + +# _sha3 + if [ -n "$OPENSSL_HOME" ]; then + local BUILDDIR_SHA3="$BUILDDIR/sha3" + local OBJDIR_SHA3="$BUILDDIR_SHA3/obj/local/$ABI" + + run mkdir -p "$BUILDDIR_SHA3/jni" + fail_panic "Can't create directory: $BUILDDIR_SHA3/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := _sha3' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_SRC_FILES := \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_sha3/sha3module.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + echo "\$(call import-module,$OPENSSL_HOME)" + } >$BUILDDIR_SHA3/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_SHA3/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_SHA3 -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module '_sha3'" + + log "Install python$PYTHON_ABI-$ABI module '_sha3' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_SHA3/lib_sha3.so $PYBIN_INSTALLDIR_MODULES/_sha3.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module '_sha3' in $PYBIN_INSTALLDIR_MODULES" + fi + +# _sqlite3 + local BUILDDIR_SQLITE3="$BUILDDIR/sqlite3" + local OBJDIR_SQLITE3="$BUILDDIR_SQLITE3/obj/local/$ABI" + + run mkdir -p "$BUILDDIR_SQLITE3/jni" + fail_panic "Can't create directory: $BUILDDIR_SQLITE3/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := _sqlite3' + echo 'LOCAL_CFLAGS := -DMODULE_NAME=\"sqlite3\"' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_SRC_FILES := \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_sqlite/cache.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_sqlite/connection.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_sqlite/cursor.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_sqlite/microprotocols.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_sqlite/module.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_sqlite/prepare_protocol.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_sqlite/row.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_sqlite/statement.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/_sqlite/util.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared sqlite3_static' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + echo '$(call import-module,sqlite/3)' + } >$BUILDDIR_SQLITE3/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_SQLITE3/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_SQLITE3 -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module '_sqlite3'" + + log "Install python$PYTHON_ABI-$ABI module '_sqlite3' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_SQLITE3/lib_sqlite3.so $PYBIN_INSTALLDIR_MODULES/_sqlite3.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module '_sqlite3' in $PYBIN_INSTALLDIR_MODULES" + +#pyexpat + local BUILDDIR_PYEXPAT="$BUILDDIR/pyexpat" + local OBJDIR_PYEXPAT="$BUILDDIR_PYEXPAT/obj/local/$ABI" + + run mkdir -p "$BUILDDIR_PYEXPAT/jni" + fail_panic "Can't create directory: $BUILDDIR_PYEXPAT/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := pyexpat' + echo 'LOCAL_CFLAGS := -DHAVE_EXPAT_CONFIG_H -DXML_STATIC' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo "LOCAL_C_INCLUDES := \$(MY_PYTHON_SRC_ROOT)/Modules/expat" + echo 'LOCAL_SRC_FILES := \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/expat/xmlparse.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/expat/xmlrole.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/expat/xmltok.c \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/pyexpat.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + } >$BUILDDIR_PYEXPAT/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_PYEXPAT/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_PYEXPAT -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module 'pyexpat'" + + log "Install python$PYTHON_ABI-$ABI module 'pyexpat' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_PYEXPAT/libpyexpat.so $PYBIN_INSTALLDIR_MODULES/pyexpat.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module 'pyexpat' in $PYBIN_INSTALLDIR_MODULES" + +# select + local BUILDDIR_SELECT="$BUILDDIR/select" + local OBJDIR_SELECT="$BUILDDIR_SELECT/obj/local/$ABI" + + run mkdir -p "$BUILDDIR_SELECT/jni" + fail_panic "Can't create directory: $BUILDDIR_SELECT/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := select' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_SRC_FILES := \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/selectmodule.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + } >$BUILDDIR_SELECT/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_SELECT/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_SELECT -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module 'select'" + + log "Install python$PYTHON_ABI-$ABI module 'select' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_SELECT/libselect.so $PYBIN_INSTALLDIR_MODULES/select.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module 'select' in $PYBIN_INSTALLDIR_MODULES" + +# unicodedata + local BUILDDIR_UNICODEDATA="$BUILDDIR/unicodedata" + local OBJDIR_UNICODEDATA="$BUILDDIR_UNICODEDATA/obj/local/$ABI" + + run mkdir -p "$BUILDDIR_UNICODEDATA/jni" + fail_panic "Can't create directory: $BUILDDIR_UNICODEDATA/jni" + + { + echo 'LOCAL_PATH := $(call my-dir)' + echo 'include $(CLEAR_VARS)' + echo 'LOCAL_MODULE := unicodedata' + echo "MY_PYTHON_SRC_ROOT := $PYTHON_SRCDIR" + echo 'LOCAL_SRC_FILES := \' + echo ' $(MY_PYTHON_SRC_ROOT)/Modules/unicodedata.c' + echo 'LOCAL_STATIC_LIBRARIES := python_shared' + echo 'include $(BUILD_SHARED_LIBRARY)' + echo "\$(call import-module,python/$PYTHON_ABI)" + } >$BUILDDIR_UNICODEDATA/jni/Android.mk + fail_panic "Can't generate $BUILDDIR_UNICODEDATA/jni/Android.mk" + + run $NDK_DIR/ndk-build -C $BUILDDIR_UNICODEDATA -j$NUM_JOBS APP_ABI=$ABI V=1 + fail_panic "Can't build python$PYTHON_ABI-$ABI module 'unicodedata'" + + log "Install python$PYTHON_ABI-$ABI module 'unicodedata' in $PYBIN_INSTALLDIR_MODULES" + run cp -p -T $OBJDIR_UNICODEDATA/libunicodedata.so $PYBIN_INSTALLDIR_MODULES/unicodedata.so + fail_panic "Can't install python$PYTHON_ABI-$ABI module 'unicodedata' in $PYBIN_INSTALLDIR_MODULES" +} + +if [ -n "$PACKAGE_DIR" ]; then + PACKAGE_NAME="python${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}-headers.tar.xz" + echo "Look for: $PACKAGE_NAME" + try_cached_package "$PACKAGE_DIR" "$PACKAGE_NAME" no_exit + if [ $? -eq 0 ]; then + PYTHON_HEADERS_NEED_PACKAGE=no + else + PYTHON_HEADERS_NEED_PACKAGE=yes + fi +fi + +BUILT_ABIS="" +for ABI in $ABIS; do + DO_BUILD_PACKAGE="yes" + if [ -n "$PACKAGE_DIR" ]; then + PACKAGE_NAME="python${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}-libs-${ABI}.tar.xz" + echo "Look for: $PACKAGE_NAME" + try_cached_package "$PACKAGE_DIR" "$PACKAGE_NAME" no_exit + if [ $? -eq 0 ]; then + if [ "$PYTHON_HEADERS_NEED_PACKAGE" = "yes" -a -z "$BUILT_ABIS" ]; then + BUILT_ABIS="$BUILT_ABIS $ABI" + else + DO_BUILD_PACKAGE="no" + fi + else + BUILT_ABIS="$BUILT_ABIS $ABI" + fi + fi + if [ "$DO_BUILD_PACKAGE" = "yes" ]; then + build_python_for_abi $ABI "$BUILD_DIR/$ABI" + fi +done + +if [ -n "$PACKAGE_DIR" ]; then + if [ "$PYTHON_HEADERS_NEED_PACKAGE" = "yes" ]; then + FILES="$PYTHON_SUBDIR/$PYTHON_ABI/include" + PACKAGE_NAME="python${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}-headers.tar.xz" + PACKAGE="$PACKAGE_DIR/$PACKAGE_NAME" + dump "Packaging: $PACKAGE" + pack_archive "$PACKAGE" "$NDK_DIR" "$FILES" + fail_panic "Can't package python headers" + cache_package "$PACKAGE_DIR" "$PACKAGE_NAME" + fi + + for ABI in $BUILT_ABIS; do + FILES="$PYTHON_SUBDIR/$PYTHON_ABI/libs/$ABI" + PACKAGE_NAME="python${PYTHON_MAJOR_VERSION}.${PYTHON_MINOR_VERSION}-libs-${ABI}.tar.xz" + PACKAGE="$PACKAGE_DIR/$PACKAGE_NAME" + dump "Packaging: $PACKAGE" + pack_archive "$PACKAGE" "$NDK_DIR" "$FILES" + fail_panic "Can't package python $ABI libs" + cache_package "$PACKAGE_DIR" "$PACKAGE_NAME" + done +fi + +if [ -z "$OPTION_BUILD_DIR" ]; then + log "Cleaning up..." + rm -rf $BUILD_DIR +else + log "Don't forget to cleanup: $BUILD_DIR" +fi + +log "Done!" diff --git a/src/main/python/lbrynetservice.py b/src/main/python/lbrynetservice.py index d156f440..f95ef63d 100644 --- a/src/main/python/lbrynetservice.py +++ b/src/main/python/lbrynetservice.py @@ -20,6 +20,7 @@ lbrynet.androidhelpers.paths.android_app_external_storage_dir = lambda: lbrynet_ # Retrieve the Anroid keystore ks = lbrynet_utils.initKeyStore(service.getApplicationContext()); +''' import lbrynet.daemon.auth from lbrynet.daemon.auth.util import APIKey, API_KEY_NAME @@ -49,10 +50,10 @@ def initialize_api_key_file(key_path): keys.update({new_api_key.name: new_api_key}) save_api_keys(keys, key_path) - lbrynet.daemon.auth.util.load_api_keys = load_api_keys lbrynet.daemon.auth.util.save_api_keys = save_api_keys lbrynet.daemon.auth.util.initialize_api_key_file = initialize_api_key_file +''' # Keyring backend class LbryAndroidKeyring(keyring.backend.KeyringBackend): @@ -76,7 +77,6 @@ keyring.set_keyring(LbryAndroidKeyring()) import logging.handlers from lbrynet.core import log_support from twisted.internet import defer, reactor -from jsonrpc.proxy import JSONRPCProxy from lbrynet import analytics from lbrynet import conf @@ -128,7 +128,8 @@ def start(): # TODO: specify components, initialise auth conf.settings.update({ 'components_to_skip': [PEER_PROTOCOL_SERVER_COMPONENT, REFLECTOR_COMPONENT], - 'concurrent_announcers': 0 + 'concurrent_announcers': 0, + 'use_upnp': False }) log.info('Final Settings: %s', conf.settings.get_current_settings_dict())