Skip to content

Commit

Permalink
Merge pull request #41 from Ian-Foote/garden_requirements
Browse files Browse the repository at this point in the history
Garden requirements
  • Loading branch information
akshayaurora committed Mar 30, 2014
2 parents 87d1462 + 3e6ee48 commit 744c03b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
43 changes: 43 additions & 0 deletions buildozer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ def prepare_for_build(self):
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()

Expand Down Expand Up @@ -405,6 +408,38 @@ def _install_application_requirement(self, module):
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
Expand Down Expand Up @@ -561,6 +596,7 @@ def get_version(self):
def build_application(self):
self._copy_application_sources()
self._copy_application_libs()
self._copy_garden_libs()
self._add_sitecustomize()

def _copy_application_sources(self):
Expand Down Expand Up @@ -649,6 +685,9 @@ def _copy_application_libs(self):
# 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'))
Expand Down Expand Up @@ -698,6 +737,10 @@ def app_dir(self):
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')
Expand Down
3 changes: 3 additions & 0 deletions buildozer/default.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 744c03b

Please sign in to comment.