<commit_before>from pythonforandroid.recipe import TargetPythonRecipe
from pythonforandroid.toolchain import shprint, current_directory
from pythonforandroid.logger import logger, info
from pythonforandroid.util import ensure_dir, walk_valid_filens
from os.path import exists, join, dirname
from os import environ
import glob
import sh

STDLIB_DIR_BLACKLIST = {
    '__pycache__',
    'test',
    'tests',
    'lib2to3',
    'ensurepip',
    'idlelib',
    'tkinter',
}

STDLIB_FILEN_BLACKLIST = [
    '*.pyc',
    '*.exe',
    '*.whl',
]

# TODO: Move to a generic location so all recipes use the same blacklist
SITE_PACKAGES_DIR_BLACKLIST = {
    '__pycache__',
    'tests'
}

SITE_PACKAGES_FILEN_BLACKLIST = []


class Python3Recipe(TargetPythonRecipe):
    version = '3.7.1'
    url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz'
    name = 'python3'

    depends = ['hostpython3']
    conflicts = ['python3crystax', 'python2']
    # opt_depends = ['openssl', 'sqlite3']

    def build_arch(self, arch):
        recipe_build_dir = self.get_build_dir(arch.arch)

        # Create a subdirectory to actually perform the build
        build_dir = join(recipe_build_dir, 'android-build')
        ensure_dir(build_dir)<commit_msg>Added a minimum supported ndk api check to the python3 recipe<commit_after>from pythonforandroid.recipe import TargetPythonRecipe
from pythonforandroid.toolchain import shprint, current_directory
from pythonforandroid.logger import logger, info, error
from pythonforandroid.util import ensure_dir, walk_valid_filens
from os.path import exists, join, dirname
from os import environ
import glob
import sh

STDLIB_DIR_BLACKLIST = {
    '__pycache__',
    'test',
    'tests',
    'lib2to3',
    'ensurepip',
    'idlelib',
    'tkinter',
}

STDLIB_FILEN_BLACKLIST = [
    '*.pyc',
    '*.exe',
    '*.whl',
]

# TODO: Move to a generic location so all recipes use the same blacklist
SITE_PACKAGES_DIR_BLACKLIST = {
    '__pycache__',
    'tests'
}

SITE_PACKAGES_FILEN_BLACKLIST = []


class Python3Recipe(TargetPythonRecipe):
    version = '3.7.1'
    url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz'
    name = 'python3'

    depends = ['hostpython3']
    conflicts = ['python3crystax', 'python2']

    # This recipe can be built only against API 21+
    MIN_NDK_API = 21

    def build_arch(self, arch):
        if self.ctx.ndk_api < self.MIN_NDK_API:
            error('Target ndk-api is {}, but the python3 recipe supports only {}+'.format(
                self.ctx.ndk_api, self.MIN_NDK_API))
            exit(1)

        recipe_build_dir = self.get_build_dir(arch.arch)

        # Create a subdirectory to actually perform the build
        build_dir = join(recipe_build_dir, 'android-build')
        ensure_dir(build_dir)
{'fraction_non_alphanumeric': 0.10567654409139593, 'fraction_numerical': 0.009996429846483398, 'mean_word_length': 3.5784313725490198, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4431210', 'n_tokens_mistral': 960, 'n_tokens_neox': 930, 'n_words': 224}