Repository: kivy/python-for-android

Issue:
Python recipe from Crystax undefined
Apparently self.ctx.python_recipe is not defined in the if statement at line 113 in archs.py

```
  File "./boost/__init__.py", line 49, in get_recipe_env
    env = super(BoostRecipe, self).get_recipe_env(arch)
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/recipe.py", line 474, in get_recipe_env
    return arch.get_env(with_flags_in_cc=with_flags_in_cc)
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/archs.py", line 113, in get_env
    if self.ctx.python_recipe.from_crystax:
AttributeError: 'NoneType' object has no attribute 'from_crystax'
```

AttributeError: 'NoneType' object has no attribute 'from_crystax'
Whenever I build a regular recipe _without a Pythonrecipe in the build order_ I get the following 2 attribute errors in archs.py line 113 and build.py line 568.
The problem is an undefined attribute: self.ctx.python_recipe.from_crystax

```
Traceback (most recent call last):
  File "/home/paul/.local/bin/p4a", line 9, in <module>
    load_entry_point('python-for-android==0.3', 'console_scripts', 'p4a')()
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 708, in main
    ToolchainCL()
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 323, in __init__
    getattr(self, args.command)(unknown)
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 105, in wrapper_func
    build_dist_from_args(ctx, dist, dist_args)
  File "/home/paul/.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/paul/.local/lib/python2.7/site-packages/pythonforandroid/build.py", line 560, in build_recipes
    recipe.build_arch(arch)
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/recipes/leveldb/__init__.py", line 16, in build_arch
    env = self.get_recipe_env(arch)
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/recipes/leveldb/__init__.py", line 30, in get_recipe_env
    env = super(LevelDBRecipe, self).get_recipe_env(arch)
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/recipe.py", line 474, in get_recipe_env
    return arch.get_env(with_flags_in_cc=with_flags_in_cc)
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/archs.py", line 113, in get_env
    if self.ctx.python_recipe.from_crystax:
AttributeError: 'NoneType' object has no attribute 'from_crystax'
```

```
Traceback (most recent call last):
  File "/home/paul/.local/bin/p4a", line 9, in <module>
    load_entry_point('python-for-android==0.3', 'console_scripts', 'p4a')()
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 708, in main
    ToolchainCL()
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 323, in __init__
    getattr(self, args.command)(unknown)
  File "/home/paul/.local/lib/python2.7/site-packages/pythonforandroid/toolchain.py", line 105, in wrapper_func
    build_dist_from_args(ctx, dist, dist_args)
  File "/home/paul/.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/paul/.local/lib/python2.7/site-packages/pythonforandroid/build.py", line 568, in build_recipes
    if not ctx.python_recipe.from_crystax:
AttributeError: 'NoneType' object has no attribute 'from_crystax'
```



Discussion:
Do you remember what p4a command you were using to get this, particularly the --requirements you were using?

I could not reproduce this issue after I commented out line 112 and 113 3 days ago and upgraded p4a from git master today.



Resolving patch:
diff --git a/pythonforandroid/archs.py b/pythonforandroid/archs.py
--- a/pythonforandroid/archs.py
+++ b/pythonforandroid/archs.py
@@ -110,7 +110,7 @@ def get_env(self, with_flags_in_cc=True):
 
         env['ARCH'] = self.arch
 
-        if self.ctx.python_recipe.from_crystax:
+        if self.ctx.python_recipe and self.ctx.python_recipe.from_crystax:
             env['CRYSTAX_PYTHON_VERSION'] = self.ctx.python_recipe.version
 
         return env
diff --git a/pythonforandroid/build.py b/pythonforandroid/build.py
--- a/pythonforandroid/build.py
+++ b/pythonforandroid/build.py
@@ -565,7 +565,7 @@ def build_recipes(build_order, python_modules, ctx):
         # 4) biglink everything
         # AND: Should make this optional
         info_main('# Biglinking object files')
-        if not ctx.python_recipe.from_crystax:
+        if not ctx.python_recipe or not ctx.python_recipe.from_crystax:
             biglink(ctx, arch)
         else:
             info('NDK is crystax, skipping biglink (will this work?)')


Test patch: