Merge pull request #41 from Ian-Foote/garden_requirements
Garden requirements
This commit is contained in:
commit
744c03b696
2 changed files with 46 additions and 0 deletions
|
@ -143,6 +143,9 @@ class Buildozer(object):
|
|||
self.info('Check application requirements')
|
||||
self.check_application_requirements()
|
||||
|
||||
self.info('Check garden requirements')
|
||||
self.check_garden_requirements()
|
||||
|
||||
self.info('Compile platform')
|
||||
self.target.compile_platform()
|
||||
|
||||
|
@ -405,6 +408,38 @@ class Buildozer(object):
|
|||
env=self.env_venv,
|
||||
cwd=self.buildozer_dir)
|
||||
|
||||
def check_garden_requirements(self):
|
||||
'''Ensure required garden packages are available to be included.
|
||||
'''
|
||||
garden_requirements = self.config.getlist('app',
|
||||
'garden_requirements', '')
|
||||
|
||||
# have we installed the garden packages?
|
||||
if exists(self.gardenlibs_dir) and \
|
||||
self.state.get('cache.gardenlibs', '') == garden_requirements:
|
||||
self.debug('Garden requirements already installed, pass')
|
||||
return
|
||||
|
||||
self._ensure_virtualenv()
|
||||
self.cmd('pip-2.7 install Kivy-Garden==0.1.1', env=self.env_venv)
|
||||
|
||||
# recreate gardenlibs
|
||||
self.rmdir(self.gardenlibs_dir)
|
||||
self.mkdir(self.gardenlibs_dir)
|
||||
|
||||
for requirement in garden_requirements:
|
||||
self._install_garden_package(requirement)
|
||||
|
||||
# save gardenlibs state
|
||||
self.state['cache.gardenlibs'] = garden_requirements
|
||||
|
||||
def _install_garden_package(self, package):
|
||||
self._ensure_virtualenv()
|
||||
self.debug('Install garden package {} in buildozer_dir'.format(package))
|
||||
self.cmd('garden install --app {}'.format(package),
|
||||
env=self.env_venv,
|
||||
cwd=self.buildozer_dir)
|
||||
|
||||
def _ensure_virtualenv(self):
|
||||
if hasattr(self, 'venv'):
|
||||
return
|
||||
|
@ -561,6 +596,7 @@ class Buildozer(object):
|
|||
def build_application(self):
|
||||
self._copy_application_sources()
|
||||
self._copy_application_libs()
|
||||
self._copy_garden_libs()
|
||||
self._add_sitecustomize()
|
||||
|
||||
def _copy_application_sources(self):
|
||||
|
@ -649,6 +685,9 @@ class Buildozer(object):
|
|||
# copy also the libs
|
||||
copytree(self.applibs_dir, join(self.app_dir, '_applibs'))
|
||||
|
||||
def _copy_garden_libs(self):
|
||||
copytree(self.gardenlibs_dir, join(self.app_dir, 'libs'))
|
||||
|
||||
def _add_sitecustomize(self):
|
||||
copyfile(join(dirname(__file__), 'sitecustomize.py'),
|
||||
join(self.app_dir, 'sitecustomize.py'))
|
||||
|
@ -698,6 +737,10 @@ class Buildozer(object):
|
|||
def applibs_dir(self):
|
||||
return join(self.buildozer_dir, 'applibs')
|
||||
|
||||
@property
|
||||
def gardenlibs_dir(self):
|
||||
return join(self.buildozer_dir, 'libs')
|
||||
|
||||
@property
|
||||
def global_buildozer_dir(self):
|
||||
return join(expanduser('~'), '.buildozer')
|
||||
|
|
|
@ -34,6 +34,9 @@ version.filename = %(source.dir)s/main.py
|
|||
# (list) Application requirements
|
||||
requirements = kivy
|
||||
|
||||
# (list) Garden requirements
|
||||
#garden_requirements =
|
||||
|
||||
# (str) Presplash of the application
|
||||
#presplash.filename = %(source.dir)s/data/presplash.png
|
||||
|
||||
|
|
Loading…
Reference in a new issue