8000 Merge pull request #579 from kived/recipe-version-env · kived/python-for-android@fc56c99 · GitHub
[go: up one dir, main page]

Skip to content

Commit fc56c99

Browse files
committed
Merge pull request kivy#579 from kived/recipe-version-env
add basic env-based overrides for recipe version and url
2 parents e24007d + 419288c commit fc56c99

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

pythonforandroid/build.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,12 @@ def run_pymodules_install(ctx, modules):
585585
info('Creating a requirements.txt file for the Python modules')
586586
with open('requirements.txt', 'w') as fileh:
587587
for module in modules:
588-
fileh.write('{}\n'.format(module))
588+
key = 'VERSION_' + module
589+
if key in environ:
590+
line = '{}=={}\n'.format(module, environ[key])
591+
else:
592+
line = '{}\n'.format(module)
593+
fileh.write(line)
589594

590595
info('Installing Python modules with pip')
591596
info('If this fails with a message about /bin/false, this '

pythonforandroid/recipe.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import importlib
33
import zipfile
44
import glob
5-
from six import PY2
5+
from six import PY2, with_metaclass
66

77
import sh
88
import shutil
@@ -37,8 +37,19 @@ def import_recipe(module, filename):
3737
return SourceFileLoader(module, filename).load_module()
3838

3939

40-
class Recipe(object):
41-
url = None
40+
class RecipeMeta(type):
41+
def __new__(cls, name, bases, dct):
42+
if name != 'Recipe':
43+
if 'url' in dct:
44+
dct['_url'] = dct.pop('url')
45+
if 'version' in dct:
46+
dct['_version'] = dct.pop('version')
47+
48+
return super(RecipeMeta, cls).__new__(cls, name, bases, dct)
49+
50+
51+
class Recipe(with_metaclass(RecipeMeta)):
52+
_url = None
4253
'''The address from which the recipe may be downloaded. This is not
4354
essential, it may be omitted if the source is available some other
4455
way, such as via the :class:`IncludedFilesBehaviour` mixin.
@@ -52,7 +63,7 @@ class Recipe(object):
5263
if you want.
5364
'''
5465

55-
version = None
66+
_version = None
5667
'''A string giving the version of the software the recipe describes,
5768
e.g. ``2.0.3`` or ``master``.'''
5869

@@ -88,6 +99,16 @@ class Recipe(object):
8899

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

102+
@property
103+
def version(self):
104+
key = 'VERSION_' + self.name
105+
return environ.get(key, self._version)
106+
107+
@property
108+
def url(self):
109+
key = 'URL_' + self.name
110+
return environ.get(key, self._url)
111+
91112
@property
92113
def versioned_url(self):
93114
'''A property returning the url of the recipe with ``{version}``

0 commit comments

Comments
 (0)
0