Merge pull request #38 from Ian-Foote/package_paths

Package paths
This commit is contained in:
Mathieu Virbel 2013-09-16 14:25:42 -07:00
commit 549fbff80b
3 changed files with 9 additions and 19 deletions

View file

@ -529,7 +529,7 @@ class Buildozer(object):
def build_application(self):
self._copy_application_sources()
self._copy_application_libs()
self._patch_application_sources()
self._add_sitecustomize()
def _copy_application_sources(self):
# XXX clean the inclusion/exclusion algo.
@ -617,22 +617,9 @@ class Buildozer(object):
# copy also the libs
copytree(self.applibs_dir, join(self.app_dir, '_applibs'))
def _patch_application_sources(self):
# patch the main.py
main_py = join(self.app_dir, 'main.py')
if not self.file_exists(main_py):
self.error('Unable to patch main_py to add applibs directory.')
return
header = ('import sys, os; '
'sys.path = [os.path.join(os.path.dirname(__file__),'
'"_applibs")] + sys.path\n')
with open(main_py, 'rb') as fd:
data = fd.read()
data = header + data
with open(main_py, 'wb') as fd:
fd.write(data)
self.info('Patched main.py to include applibs')
def _add_sitecustomize(self):
copyfile(join(dirname(__file__), 'sitecustomize.py'),
join(self.app_dir, 'sitecustomize.py'))
def namify(self, name):
'''Return a "valid" name from a name with lot of invalid chars

View file

@ -24,11 +24,11 @@ source.include_exts = py,png,jpg,kv,atlas
# (list) List of exclusions using pattern matching
#source.exclude_patterns = license,images/*/*.jpg
# (str) Application versionning (method 1)
# (str) Application versioning (method 1)
version.regex = __version__ = '(.*)'
version.filename = %(source.dir)s/main.py
# (str) Application versionning (method 2)
# (str) Application versioning (method 2)
# version = 1.2.0
# (list) Application requirements

View file

@ -0,0 +1,3 @@
from os.path import join, dirname
import sys
sys.path.append(join(dirname(__file__), '_applibs'))