Repository: kivy/python-for-android

Issue:
enaml recipe compilation fails
<!--
The issue tracker is a tool to address bugs.
Please use the Disord community or Stack Overflow for support questions,
more information at https://github.com/kivy/python-for-android#support

Before opening a new issue, make sure you do the following:
    * check that your issue isn't already filed: https://github.com/kivy/python-for-android/issues
    * prepare a short, runnable example that reproduces the issue
    * make sure to have `log_level = 2` in your `buildozer.spec`
    * reproduce the problem with the latest development version (`p4a.branch = master`)
    * double-check that the issue is indeed a bug and not a support request
    * please use backticks to format code or logs
-->

### Versions

* Python: host and target Python2
* OS: Ubuntu Bionic 18.04
* Kivy: N/A
* Cython: 0.21

### Description

enaml recipe fails to patch before compile.
This is most likely because the pin version is not included in the url, see https://github.com/kivy/python-for-android/blob/b3d3d45/pythonforandroid/recipes/enaml/__init__.py#L7

### Command
```sh
python setup_testapp_python2.py apk --sdk-dir $ANDROID_SDK_HOME --ndk-dir $ANDROID_NDK_HOME --bootstrap sdl2 --requirements python2,enaml
```

### Logs

```
[INFO]:    Applying patches for enaml[armeabi]
[INFO]:    Applying patch 0001-Update-setup.py.patch
[DEBUG]:   -> running patch -t -d /home/andre/.local/share/python-for-android/build/other_builds/enaml/armeabi/enaml -p1 -i /home/andre/workspace/python-for-android/pythonforandroid/recipes/enaml/0001-Update-setup.py.patch
[DEBUG]:        patching file setup.py
[DEBUG]:        Hunk #1 FAILED at 72.
[DEBUG]:        1 out of 1 hunk FAILED -- saving rejects to file setup.py.rej
Exception in thread background thread for pid 17781:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 1540, in wrap
    fn(*args, **kwargs)
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 2459, in background_thread
    handle_exit_code(exit_code)
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 2157, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
ErrorReturnCode_1:

  RAN: /usr/bin/patch -t -d /home/andre/.local/share/python-for-android/build/other_builds/enaml/armeabi/enaml -p1 -i /home/andre/workspace/python-for-android/pythonforandroid/recipes/enaml/0001-Update-setup.py.patch

  STDOUT:
patching file setup.py
Hunk #1 FAILED at 72.
1 out of 1 hunk FAILED -- saving rejects to file setup.py.rej


  STDERR:


[INFO]:    STDOUT:
        patching file setup.py
Hunk #1 FAILED at 72.
1 out of 1 hunk FAILED -- saving rejects to file setup.py.rej
[INFO]:    STDERR:

Traceback (most recent call last):
  File "setup_testapp_python2.py", line 30, in <module>
    package_data={'testapp': ['*.py', '*.png']}
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/andre/workspace/python-for-android/pythonforandroid/bdistapk.py", line 81, in run
    main()
  File "/home/andre/workspace/python-for-android/pythonforandroid/toolchain.py", line 999, in main
    ToolchainCL()
  File "/home/andre/workspace/python-for-android/pythonforandroid/toolchain.py", line 532, in __init__
    getattr(self, args.subparser_name.replace('-', '_'))(args)
  File "/home/andre/workspace/python-for-android/pythonforandroid/toolchain.py", line 145, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/andre/workspace/python-for-android/pythonforandroid/toolchain.py", line 189, in build_dist_from_args
    build_recipes(build_order, python_modules, ctx)
  File "/home/andre/workspace/python-for-android/pythonforandroid/build.py", line 573, in build_recipes
    recipe.apply_patches(arch)
  File "/home/andre/workspace/python-for-android/pythonforandroid/recipe.py", line 493, in apply_patches
    arch.arch)
  File "/home/andre/workspace/python-for-android/pythonforandroid/recipe.py", line 192, in apply_patch
    "-i", filename, _tail=10)
  File "/home/andre/workspace/python-for-android/pythonforandroid/logger.py", line 176, in shprint
    for line in output:
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 863, in next
    self.wait()
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 792, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/andre/workspace/python-for-android/venv/local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1:

  RAN: /usr/bin/patch -t -d /home/andre/.local/share/python-for-android/build/other_builds/enaml/armeabi/enaml -p1 -i /home/andre/workspace/python-for-android/pythonforandroid/recipes/enaml/0001-Update-setup.py.patch

  STDOUT:
patching file setup.py
Hunk #1 FAILED at 72.
1 out of 1 hunk FAILED -- saving rejects to file setup.py.rej


  STDERR:
```


Discussion:

Resolving patch:
diff --git a/ci/constants.py b/ci/constants.py
--- a/ci/constants.py
+++ b/ci/constants.py
@@ -16,8 +16,6 @@ class TargetPython(Enum):
     # https://github.com/kivy/python-for-android/issues/550
     'audiostream',
     'brokenrecipe',
-    # https://github.com/kivy/python-for-android/issues/1409
-    'enaml',
     'evdev',
     # distutils.errors.DistutilsError
     # Could not find suitable distribution for Requirement.parse('cython')
diff --git a/pythonforandroid/logger.py b/pythonforandroid/logger.py
--- a/pythonforandroid/logger.py
+++ b/pythonforandroid/logger.py
@@ -44,9 +44,9 @@ def format(self, record):
 
 
 logger = logging.getLogger('p4a')
-if not hasattr(logger, 'touched'):  # Necessary as importlib reloads
-                                    # this, which would add a second
-                                    # handler and reset the level
+# Necessary as importlib reloads this,
+# which would add a second handler and reset the level
+if not hasattr(logger, 'touched'):
     logger.setLevel(logging.INFO)
     logger.touched = True
     ch = logging.StreamHandler(stderr)
diff --git a/pythonforandroid/recipes/enaml/__init__.py b/pythonforandroid/recipes/enaml/__init__.py
--- a/pythonforandroid/recipes/enaml/__init__.py
+++ b/pythonforandroid/recipes/enaml/__init__.py
@@ -4,7 +4,7 @@
 class EnamlRecipe(CppCompiledComponentsPythonRecipe):
     site_packages_name = 'enaml'
     version = '0.9.8'
-    url = 'https://github.com/nucleic/enaml/archive/master.zip'
+    url = 'https://github.com/nucleic/enaml/archive/{version}.zip'
     patches = ['0001-Update-setup.py.patch']  # Remove PyQt dependency
     depends = ['setuptools', 'atom', 'kiwisolver']
 


Test patch: