Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Garden requirements #41

Merged
merged 11 commits into from Mar 30, 2014
45 changes: 45 additions & 0 deletions buildozer/__init__.py
Expand Up @@ -133,6 +133,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 @@ -386,6 +389,40 @@ 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 -e git+https://github.com/kivy-garden/garden.git@0.1.1#egg=Kivy-Garden-0.1.1',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated this to match the work done to fix kivy/kivy#1580.

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 @@ -529,6 +566,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 @@ -617,6 +655,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'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to make the appropriate changes to let the garden packages in _applibs instead of libs. If you are afraid about the conflict with standard lib, then let's do _applibs/garden and _applibs/system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll look into it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed in irc, I think this would require changes to kivy and garden as well as buildozer. I would prefer to stay with this solution and re-think later if it causes any issues.


def _add_sitecustomize(self):
copyfile(join(dirname(__file__), 'sitecustomize.py'),
join(self.app_dir, 'sitecustomize.py'))
Expand Down Expand Up @@ -651,6 +692,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
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