Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,12 @@ def run_pymodules_install(ctx, modules):
info('Creating a requirements.txt file for the Python modules')
with open('requirements.txt', 'w') as fileh:
for module in modules:
fileh.write('{}\n'.format(module))
key = 'VERSION_' + module
if key in environ:
line = '{}=={}\n'.format(module, environ[key])
else:
line = '{}\n'.format(module)
fileh.write(line)

info('Installing Python modules with pip')
info('If this fails with a message about /bin/false, this '
Expand Down
29 changes: 25 additions & 4 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import importlib
import zipfile
import glob
from six import PY2
from six import PY2, with_metaclass

import sh
import shutil
Expand Down Expand Up @@ -37,8 +37,19 @@ def import_recipe(module, filename):
return SourceFileLoader(module, filename).load_module()


class Recipe(object):
url = None
class RecipeMeta(type):
def __new__(cls, name, bases, dct):
if name != 'Recipe':
if 'url' in dct:
dct['_url'] = dct.pop('url')
if 'version' in dct:
dct['_version'] = dct.pop('version')

return super(RecipeMeta, cls).__new__(cls, name, bases, dct)


class Recipe(with_metaclass(RecipeMeta)):
_url = None
'''The address from which the recipe may be downloaded. This is not
essential, it may be omitted if the source is available some other
way, such as via the :class:`IncludedFilesBehaviour` mixin.
Expand All @@ -52,7 +63,7 @@ class Recipe(object):
if you want.
'''

version = None
_version = None
'''A string giving the version of the software the recipe describes,
e.g. ``2.0.3`` or ``master``.'''

Expand Down Expand Up @@ -88,6 +99,16 @@ class Recipe(object):

archs = ['armeabi'] # Not currently implemented properly

@property
def version(self):
key = 'VERSION_' + self.name
return environ.get(key, self._version)

@property
def url(self):
key = 'URL_' + self.name
return environ.get(key, self._url)

@property
def versioned_url(self):
'''A property returning the url of the recipe with ``{version}``
Expand Down