diff --git a/buildozer/__init__.py b/buildozer/__init__.py index ab77917..5698bde 100644 --- a/buildozer/__init__.py +++ b/buildozer/__init__.py @@ -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 diff --git a/buildozer/default.spec b/buildozer/default.spec index fbaece4..96dc2ad 100644 --- a/buildozer/default.spec +++ b/buildozer/default.spec @@ -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 diff --git a/buildozer/sitecustomize.py b/buildozer/sitecustomize.py new file mode 100644 index 0000000..6650864 --- /dev/null +++ b/buildozer/sitecustomize.py @@ -0,0 +1,3 @@ +from os.path import join, dirname +import sys +sys.path.append(join(dirname(__file__), '_applibs'))