internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: kivy/python-for-android

Issue:
HTTP 302 recipe download file
Downloading from sourceforge autoselecting an mirror results in a HTTP 302 instead of a direct download.
Trying to build this clean recipe below results in:

```
RAN: '/bin/tar xzf ~/.local/share/python-for-android/packages/boost/boost_1_58_0.tar.gz'
  STDOUT:
  STDERR:
gzip: stdin: not in gzip format
/bin/tar: Child returned status 1
/bin/tar: Error is not recoverable: exiting now
```

Because this .tar.gz file is in reality the 302 HTML (ASCII) page.

```
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
from os.path import exists, join

class BoostRecipe(Recipe):
    version = '1.58.0'
    url = 'http://downloads.sourceforge.net/project/boost/boost/{version}/boost_1_58_0.tar.gz'

recipe = BoostRecipe()
```



Discussion:
wget is able to download from the given url so perhaps the ChromeDowloader can be replaced with this:?
https://pypi.python.org/pypi/wget


Resolving patch:
diff --git a/pythonforandroid/util.py b/pythonforandroid/util.py
--- a/pythonforandroid/util.py
+++ b/pythonforandroid/util.py
@@ -21,12 +21,10 @@
     unistr = unicode
 
 
-class ChromeDownloader(FancyURLopener):
-    version = (
-        'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 '
-        '(KHTML, like Gecko) Chrome/28.0.1500.71 Safari/537.36')
+class WgetDownloader(FancyURLopener):
+    version = ('Wget/1.17.1')
 
-urlretrieve = ChromeDownloader().retrieve
+urlretrieve = WgetDownloader().retrieve
 
 
 @contextlib.contextmanager


Test patch:
Repository: kivy/python-for-android

Issue:
OpenSSL 1.0.2e outdated (replaced by 1.0.2f)
A new version has been published today. The recipe no longer can download version 1.0.2e.

Does `disable-solver.patch` still apply?



Discussion:
It's `disable-sover.patch`, and yes. Android won't let you install libs with so versions like libcrypto.so.1.0.2. That patch makes disables the so versioning so you end up with libcrypto.so. The patch could need updating, but the patching has to happen.

Even if there is a new version, the old version will not go away. It will still be downloadable. However, I cannot connect to www.openssl.org at all - so it seems like this is probably just a web server issue.

It appears that both affected lines have shifted 2 lines down.

Why is there --- openssl/Makefile and +++ b/Makefile I expected +++ openssl/Makefile there?

The website is slow for me, probably overloaded.

Because I name the second directory `b` when generating patches. The directory name doesn't matter, as patches will be applied with `-p1` which will strip the first component from the path.


Resolving patch:
diff --git a/pythonforandroid/recipes/openssl/__init__.py b/pythonforandroid/recipes/openssl/__init__.py
--- a/pythonforandroid/recipes/openssl/__init__.py
+++ b/pythonforandroid/recipes/openssl/__init__.py
@@ -5,7 +5,7 @@
 
 
 class OpenSSLRecipe(Recipe):
-    version = '1.0.2e'
+    version = '1.0.2f'
     url = 'https://www.openssl.org/source/openssl-{version}.tar.gz'
 
     def should_build(self, arch):


Test patch:
Repository: kivy/python-for-android

Issue:
Jpeg recipe is broken
It is missing /home/brussee/.local/lib/python2.7/site-packages/pythonforandroid/recipes/jpeg/Application.mk
Perpaps just the path is incorrect?

```
[INFO]:    Prebuilding jpeg for armeabi
[INFO]:    jpeg has no prebuild_armeabi, skipping
[DEBUG]:   -> running cp /home/brussee/.local/lib/python2.7/site-packages/pythonforandroid/recipes/jpeg/Application.mk /home/brussee/.local/share/python-for-android/build/other_builds/jpeg/armeabi/jpeg/Application.mk
[DEBUG]:    /bin/cp: cannot stat ‘/home/brussee/.local/lib/python2.7/site-packages/pythonforandroid/recipes/jpeg/Application.mk’: No such file or directory
Traceback (most recent call last):
  File "/home/brussee/.local/bin/p4a", line 9, in <module>
    load_entry_point('python-for-android==0.3', 'console_scripts', 'p4a')()
  File "/home/brussee/.local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 708, in main
    ToolchainCL()
  File "/home/brussee/.local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 323, in __init__
    getattr(self, args.command)(unknown)
  File "/home/brussee/.local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 105, in wrapper_func
    build_dist_from_args(ctx, dist, dist_args)
  File "/home/brussee/.local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 142, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/home/brussee/.local/lib/python2.7/site-packages/pythonforandroid/build.py", line 543, in build_recipes
    recipe.prebuild_arch(arch)
  File "/home/brussee/.local/lib/python2.7/site-packages/pythonforandroid/recipes/jpeg/__init__.py", line 22, in prebuild_arch
    shprint(sh.cp, join(self.get_recipe_dir(), 'Application.mk'), app_mk)
  File "/home/brussee/.local/lib/python2.7/site-packages/pythonforandroid/logger.py", line 160, in shprint
    for line in output:
  File "/home/brussee/.local/lib/python2.7/site-packages/sh.py", line 565, in next
    self.wait()
  File "/home/brussee/.local/lib/python2.7/site-packages/sh.py", line 500, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/brussee/.local/lib/python2.7/site-packages/sh.py", line 516, in handle_command_exit_code
    raise exc(self.ran, self.process.stdout, self.process.stderr)
sh.ErrorReturnCode_1
```



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -30,7 +30,8 @@ def recursively_include(results, directory, patterns):
             results[directory].append(join(*filename.split(sep)[1:]))
 
 recursively_include(package_data, 'pythonforandroid/recipes',
-                    ['*.patch', 'Setup*', '*.pyx', '*.py', '*.c', '*.h', ])
+                    ['*.patch', 'Setup*', '*.pyx', '*.py', '*.c', '*.h',
+                     '*.mk', ])
 recursively_include(package_data, 'pythonforandroid/bootstraps',
                     ['*.properties', '*.xml', '*.java', '*.tmpl', '*.txt', '*.png',
                      '*.mk', '*.c', '*.h', '*.py', '*.sh', '*.jpg', '*.aidl', ])


Test patch:
Repository: kivy/python-for-android

Issue:
.jam files not installed
The user-config.jam in https://github.com/kivy/python-for-android/tree/master/pythonforandroid/recipes/boost does not show up in the installed p4a recipes folder /home/paul/.local/lib/python2.7/site-packages/pythonforandroid/recipes/boost/

Perhaps .jam files have to be added to this array as well: https://github.com/kived/python-for-android/commit/93fcf656e2aafc6a75ee06dab3e471e1eb509d87



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -31,7 +31,7 @@ def recursively_include(results, directory, patterns):
 
 recursively_include(package_data, 'pythonforandroid/recipes',
                     ['*.patch', 'Setup*', '*.pyx', '*.py', '*.c', '*.h',
-                     '*.mk', ])
+                     '*.mk', '*.jam', ])
 recursively_include(package_data, 'pythonforandroid/bootstraps',
                     ['*.properties', '*.xml', '*.java', '*.tmpl', '*.txt', '*.png',
                      '*.mk', '*.c', '*.h', '*.py', '*.sh', '*.jpg', '*.aidl', ])


Test patch:
Repository: kivy/python-for-android

Issue:
Cryptography recipe does not compile
I'm trying to build Kivy app with:
- sdl2 bootstrap
- recipes python2,kivy,cryptography 
- buildozer 0.32 
- latest python-for-android master branch 

In libffi recipe I had to replace [line](https://github.com/kivy/python-for-android/blob/master/pythonforandroid/recipes/libffi/__init__.py#L43) with:
`shprint(sh.Command('autoreconf'), '-vif', _env=env)`.
Without that change p4a was raising sh.CommandNotFound error. 

Now running `buildozer android_new debug` produces the following error log: http://pastebin.com/22qjBJwL
buildozer.spec file: http://pastebin.com/aLe7nLHG
main.py file: http://pastebin.com/xSReYe6u



Discussion:

Resolving patch:
diff --git a/pythonforandroid/recipes/libffi/__init__.py b/pythonforandroid/recipes/libffi/__init__.py
--- a/pythonforandroid/recipes/libffi/__init__.py
+++ b/pythonforandroid/recipes/libffi/__init__.py
@@ -40,7 +40,7 @@ def build_arch(self, 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('autoreconf'), '-vif', _env=env)
 			shprint(sh.Command('./configure'), '--host=' + arch.toolchain_prefix,
 			        '--prefix=' + self.ctx.get_python_install_dir(),
 			        '--enable-shared', _env=env)


Test patch:
Repository: kivy/python-for-android

Issue:
Openssl recipe crashes on x86 arch
p4a branch: stable
buildozer: 0.33
bootstrap: sdl2
kivy: 1.10.0

Error message i get:
```
arm_arch.h:46:6: error: #error "unsupported ARM architecture"
```


Discussion:

Resolving patch:
diff --git a/pythonforandroid/recipes/openssl/__init__.py b/pythonforandroid/recipes/openssl/__init__.py
--- a/pythonforandroid/recipes/openssl/__init__.py
+++ b/pythonforandroid/recipes/openssl/__init__.py
@@ -36,6 +36,8 @@ def select_build_arch(self, arch):
             return 'android-armv7'
         if 'arm' in aname:
             return 'android'
+        if 'x86' in aname:
+            return 'android-x86'
         return 'linux-armv4'
 
     def build_arch(self, arch):


Test patch:
Repository: kivy/python-for-android

Issue:
Local recipes can not be patched any longer
It seems since commit 9242bea826a2bdc58915d4954343aee5165d9ad4 local recipes which try to patch files can not run any longer. The call to get_recipe_dir() always returns a path in the ctx.root_dir and that is wrong for local recipes.

I tried to revert that commit here locally and now the patching works again.


Discussion:
That's my mistake, sorry about that. I'll aim to push a fix soonish, although probably it's better to fix `get_recipe_dir` than to re-add the old behaviour.

Resolving patch:
diff --git a/pythonforandroid/recipe.py b/pythonforandroid/recipe.py
--- a/pythonforandroid/recipe.py
+++ b/pythonforandroid/recipe.py
@@ -293,6 +293,14 @@ def get_build_dir(self, arch):
         return join(self.get_build_container_dir(arch), self.name)
 
     def get_recipe_dir(self):
+        """
+        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


Test patch:
Repository: kivy/python-for-android

Issue:
libxml2 build broken on latest p4a master with python 3
With latest p4a master & python3crystax & host python 3, the libxml2 recipe gets built inside `/root/.local/share/python-for-android/build/other_builds/libxml2/armeabi-v7a__ndk_target_19/libxml2/ `.

This is a folder name change, previously it used to be in `/root/.local/share/python-for-android/build/other_builds/libxml2/armeabi-v7a/libxml2/` - and as a result, the path detection inside the libxml2 fails for some reason.

### Versions

* Python: host python 3.x, python3crystax target
* OS: ubuntu in docker
* Kivy: not used
* Cython: not sure, but I don't think it's relevant

Edit: corrected lxml -> libxml2


Discussion:
I'll see if I can fix it myself thanks to a hint by inclement of how to do this, hang on

Resolving patch:
diff --git a/pythonforandroid/recipes/libxslt/__init__.py b/pythonforandroid/recipes/libxslt/__init__.py
--- a/pythonforandroid/recipes/libxslt/__init__.py
+++ b/pythonforandroid/recipes/libxslt/__init__.py
@@ -1,5 +1,5 @@
 from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory
-from os.path import exists, join, dirname
+from os.path import exists, join
 import sh
 
 
@@ -22,10 +22,8 @@ def build_arch(self, arch):
             # If the build is done with /bin/sh things blow up,
             # try really hard to use bash
             env["CC"] += " -I%s" % self.get_build_dir(arch.arch)
-            libxml = (
-                dirname(dirname(self.get_build_container_dir(arch.arch)))
-                + "/libxml2/%s/libxml2" % arch.arch
-            )
+            libxml = Recipe.get_recipe(
+                'libxml2', self.ctx).get_build_dir(arch.arch)
             shprint(
                 sh.Command("./configure"),
                 "--build=i686-pc-linux-gnu",


Test patch:
Repository: kivy/python-for-android

Issue:
Didn't find any valid dependency graphs. - Flask and websocket-client
In my app I use both flask and websocket-client. However, when i try to add both of these dependencies to my app, p4a fails. However, when I build my app only with `flask`, or only with `websocket-client` p4a works correctly.
```
p4a apk --private /home/user/sample/ --package=samplepackage --name="Sample app" --version 0.1 --bootstrap=sdl2 --requirements=python2,websocket-client,flask
[ERROR]:   Didn't find any valid dependency graphs.
[ERROR]:   This means that some of your requirements pull in conflicting dependencies.
[ERROR]:   Exiting.```




Discussion:
Assuming websocket-client doesn't really depend on Kivy, the issue is that Kivy is listed in [its requirements](https://github.com/kivy/python-for-android/blob/master/pythonforandroid/recipes/websocket-client/__init__.py#L25).

Resolving patch:
diff --git a/pythonforandroid/recipes/websocket-client/__init__.py b/pythonforandroid/recipes/websocket-client/__init__.py
--- a/pythonforandroid/recipes/websocket-client/__init__.py
+++ b/pythonforandroid/recipes/websocket-client/__init__.py
@@ -15,15 +15,13 @@
 
 class WebSocketClient(Recipe):
 
-    url = 'https://github.com/debauchery1st/websocket-client/raw/master/websocket_client-0.40.0.tar.gz'
+    url = 'https://github.com/websocket-client/websocket-client/archive/v{version}.tar.gz'
 
     version = '0.40.0'
-    # md5sum = 'f1cf4cc7869ef97a98e5f4be25c30986'
 
     # patches = ['websocket.patch']  # Paths relative to the recipe dir
 
-    depends = ['kivy', 'python2', 'android', 'pyjnius',
-               'cryptography', 'pyasn1', 'pyopenssl']
+    depends = ['python2', 'android', 'pyjnius', 'cryptography', 'pyasn1', 'pyopenssl']
 
 
 recipe = WebSocketClient()


Test patch:
Repository: kivy/python-for-android

Issue:
Broken libglob recipe
`libglob` recipe compilation fails for the exact same reason problem as ifaddrs.
See details https://github.com/kivy/python-for-android/issues/1398


Discussion:

Resolving patch:
diff --git a/ci/constants.py b/ci/constants.py
--- a/ci/constants.py
+++ b/ci/constants.py
@@ -25,8 +25,6 @@ class TargetPython(Enum):
     'hostpython3crystax',
     # https://github.com/kivy/python-for-android/issues/1354
     'kiwisolver',
-    # https://github.com/kivy/python-for-android/issues/1399
-    'libglob',
     'libmysqlclient',
     'libsecp256k1',
     'libtribler',
@@ -69,8 +67,6 @@ class TargetPython(Enum):
     # enum34 is not compatible with Python 3.6 standard library
     # https://stackoverflow.com/a/45716067/185510
     'enum34',
-    # https://github.com/kivy/python-for-android/issues/1399
-    'libglob',
     # build_dir = glob.glob('build/lib.*')[0]
     # IndexError: list index out of range
     'secp256k1',
diff --git a/pythonforandroid/recipes/libglob/__init__.py b/pythonforandroid/recipes/libglob/__init__.py
--- a/pythonforandroid/recipes/libglob/__init__.py
+++ b/pythonforandroid/recipes/libglob/__init__.py
@@ -45,32 +45,22 @@ def build_arch(self, arch):
             if not exists(path):
                 info("creating {}".format(path))
                 shprint(sh.mkdir, '-p', path)
-        cli = env['CC'].split()
-        cc = sh.Command(cli[0])
+        cli = env['CC'].split()[0]
+        # makes sure first CC command is the compiler rather than ccache, refs:
+        # https://github.com/kivy/python-for-android/issues/1399
+        if 'ccache' in cli:
+            cli = env['CC'].split()[1]
+        cc = sh.Command(cli)
 
         with current_directory(self.get_build_dir(arch.arch)):
             cflags = env['CFLAGS'].split()
-            cflags.extend(['-I.', '-c', '-l.', 'glob.c', '-I.'])  # , '-o', 'glob.o'])
+            cflags.extend(['-I.', '-c', '-l.', 'glob.c', '-I.'])
             shprint(cc, *cflags, _env=env)
-
             cflags = env['CFLAGS'].split()
-            srindex = cflags.index('--sysroot')
-            if srindex:
-                cflags[srindex+1] = self.ctx.ndk_platform
             cflags.extend(['-shared', '-I.', 'glob.o', '-o', 'libglob.so'])
+            cflags.extend(env['LDFLAGS'].split())
             shprint(cc, *cflags, _env=env)
-
             shprint(sh.cp, 'libglob.so', join(self.ctx.libs_dir, arch.arch))
-            shprint(sh.cp, "libglob.so", join(self.ctx.get_python_install_dir(), 'lib'))
-            # drop header in to the Python include directory
-            shprint(sh.cp, "glob.h", join(self.ctx.get_python_install_dir(),
-                                          'include/python{}'.format(
-                                              self.ctx.python_recipe.version[0:3]
-                                          )
-                                         )
-                   )
-            include_path = join(self.ctx.python_recipe.get_build_dir(arch.arch), 'Include')
-            shprint(sh.cp, "glob.h", include_path)
 
 
 recipe = LibGlobRecipe()


Test patch:
Repository: kivy/python-for-android

Issue:
packaged python is built with IPv6 disabled
Is there any reason for IPv6 being disabled?
https://github.com/kivy/python-for-android/blob/f16a66590c92bb57c69b214b2b69dfaa6dc1e0ed/pythonforandroid/recipes/python3/__init__.py#L37


Discussion:
I think I encountered a build error if I didn't add this, but it's probably something that can be fixed. If you want to investigate it, it would be useful just to try removing the argument and seeing what happens to the build.

Resolving patch:
diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py
--- a/pythonforandroid/recipes/python3/__init__.py
+++ b/pythonforandroid/recipes/python3/__init__.py
@@ -34,7 +34,7 @@ class Python3Recipe(GuestPythonRecipe):
         '--host={android_host}',
         '--build={android_build}',
         '--enable-shared',
-        '--disable-ipv6',
+        '--enable-ipv6',
         'ac_cv_file__dev_ptmx=yes',
         'ac_cv_file__dev_ptc=no',
         '--without-ensurepip',


Test patch:
Repository: kivy/python-for-android

Issue:
TestGetSystemPythonExecutable.test_virtualenv test fail
The `TestGetSystemPythonExecutable.test_virtualenv` and `TestGetSystemPythonExecutable.test_venv` tests started failing all of a sudden.
Error was:
```
ModuleNotFoundError: No module named \'pytoml\'\n'
```
This ca be reproduced in local via:
```sh
pytest tests/test_pythonpackage_basic.py::TestGetSystemPythonExecutable::test_virtualenv
```




Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -23,7 +23,7 @@
 install_reqs = [
     'appdirs', 'colorama>=0.3.3', 'jinja2', 'six',
     'enum34; python_version<"3.4"', 'sh>=1.10; sys_platform!="nt"',
-    'pep517', 'pytoml', 'virtualenv'
+    'pep517<0.7.0"', 'pytoml', 'virtualenv'
 ]
 # (pep517, pytoml and virtualenv are used by pythonpackage.py)
 


Test patch:
diff --git a/tests/test_pythonpackage_basic.py b/tests/test_pythonpackage_basic.py
--- a/tests/test_pythonpackage_basic.py
+++ b/tests/test_pythonpackage_basic.py
@@ -303,7 +303,7 @@ def test_virtualenv(self):
             ])
             subprocess.check_output([
                 os.path.join(test_dir, "virtualenv", "bin", "pip"),
-                "install", "-U", "pep517"
+                "install", "-U", "pep517<0.7.0"
             ])
             sys_python_path = self.run__get_system_python_executable(
                 os.path.join(test_dir, "virtualenv", "bin", "python")
@@ -336,7 +336,7 @@ def test_venv(self):
             ])
             subprocess.check_output([
                 os.path.join(test_dir, "venv", "bin", "pip"),
-                "install", "-U", "pep517"
+                "install", "-U", "pep517<0.7.0"
             ])
             sys_python_path = self.run__get_system_python_executable(
                 os.path.join(test_dir, "venv", "bin", "python")
Repository: kivy/python-for-android

Issue:
TestGetSystemPythonExecutable.test_virtualenv test fail
The `TestGetSystemPythonExecutable.test_virtualenv` and `TestGetSystemPythonExecutable.test_venv` tests started failing all of a sudden.
Error was:
```
ModuleNotFoundError: No module named \'pytoml\'\n'
```
This ca be reproduced in local via:
```sh
pytest tests/test_pythonpackage_basic.py::TestGetSystemPythonExecutable::test_virtualenv
```




Discussion:

Resolving patch:
diff --git a/pythonforandroid/recipes/openssl/__init__.py b/pythonforandroid/recipes/openssl/__init__.py
--- a/pythonforandroid/recipes/openssl/__init__.py
+++ b/pythonforandroid/recipes/openssl/__init__.py
@@ -47,7 +47,7 @@ class OpenSSLRecipe(Recipe):
     version = '1.1'
     '''the major minor version used to link our recipes'''
 
-    url_version = '1.1.1'
+    url_version = '1.1.1f'
     '''the version used to download our libraries'''
 
     url = 'https://www.openssl.org/source/openssl-{url_version}.tar.gz'


Test patch:
Repository: kivy/python-for-android

Issue:
Crashing on phone. SDL Error Could not load any libpythonXXX.so
**Versions**

- Python: 3.7
- OS: Android 9
- Kivy: 1.11.11
- Cython: 0.29.14

**Desription:**
So, my app builded, after that i installed app on my phone and when i run application it is crashing. I dont know why
Phone: Redmi note 7 
OS: Android 9

Variables:
**export ANDROIDAPI="28"  # Target API version of your application
export NDKAPI="21"  # Minimum supported API version of your application
export ANDROIDNDKVER="r19b"  # Version of the NDK you installed**

Error:
### SDL Error
### An error occured while trying to start the application. Please try again and/or reinstall.

### Error: Could not load any libpythonXXX.so


Discussion:
I fixed issue by this command: **p4a clean_builds && p4a clean_dists**

Resolving patch:
diff --git a/pythonforandroid/build.py b/pythonforandroid/build.py
--- a/pythonforandroid/build.py
+++ b/pythonforandroid/build.py
@@ -576,10 +576,10 @@ def build_recipes(build_order, python_modules, ctx, project_dir,
             info_main('Building {} for {}'.format(recipe.name, arch.arch))
             if recipe.should_build(arch):
                 recipe.build_arch(arch)
-                recipe.install_libraries(arch)
             else:
                 info('{} said it is already built, skipping'
                      .format(recipe.name))
+            recipe.install_libraries(arch)
 
         # 4) biglink everything
         info_main('# Biglinking object files')


Test patch: