Skip to content

Commit 7008526

Browse files
committed
More pep8 fixes and code cleaning
1 parent b92b590 commit 7008526

File tree

1 file changed

+16
-42
lines changed

1 file changed

+16
-42
lines changed

pythonforandroid/toolchain.py

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ def append_file(self, filename, dest):
12911291

12921292
@property
12931293
def name(self):
1294+
'''The name of the recipe, the same as the folder containing it.'''
12941295
modname = self.__class__.__module__
12951296
return modname.split(".", 2)[-1]
12961297

@@ -1335,7 +1336,7 @@ def ensure_build_container_dir(self):
13351336

13361337
build_dir = self.get_build_container_dir('armeabi')
13371338
ensure_dir(build_dir)
1338-
1339+
13391340
def download_if_necessary(self):
13401341
info_main('Downloading {}'.format(self.name))
13411342
user_dir = environ.get('P4A_{}_DIR'.format(self.name.lower()))
@@ -1344,7 +1345,7 @@ def download_if_necessary(self):
13441345
self.name, self.name))
13451346
return
13461347
self.download()
1347-
1348+
13481349
def download(self):
13491350
if self.url is None:
13501351
info('Skipping {} download as no URL is set'.format(self.name))
@@ -1450,10 +1451,10 @@ def unpack(self, arch):
14501451
else:
14511452
raise Exception('Could not extract {} download, it must be .zip, '
14521453
'.tar.gz or .tar.bz2')
1453-
1454+
14541455
else:
14551456
info('{} is already unpacked, skipping'.format(self.name))
1456-
1457+
14571458

14581459
def get_recipe_env(self, arch=None):
14591460
"""Return the env specialized for the recipe
@@ -1503,6 +1504,9 @@ def get_recipe_env(self, arch=None):
15031504
# self.postbuild_arch(self.ctx.archs[0])
15041505

15051506
def prebuild_arch(self, arch):
1507+
'''Run any pre-build tasks for the Recipe. By default, this checks if
1508+
any prebuild_archname methods exist for the archname of the current
1509+
architecture, and runs them if so.'''
15061510
prebuild = "prebuild_{}".format(arch.arch)
15071511
if hasattr(self, prebuild):
15081512
getattr(self, prebuild)()
@@ -1518,11 +1522,18 @@ def should_build(self):
15181522
return True
15191523

15201524
def build_arch(self, arch):
1525+
'''Run any build tasks for the Recipe. By default, this checks if
1526+
any build_archname methods exist for the archname of the current
1527+
architecture, and runs them if so.'''
15211528
build = "build_{}".format(arch.arch)
15221529
if hasattr(self, build):
15231530
getattr(self, build)()
15241531

15251532
def postbuild_arch(self, arch):
1533+
'''Run any post-build tasks for the Recipe. By default, this checks if
1534+
any postbuild_archname methods exist for the archname of the
1535+
current architecture, and runs them if so.
1536+
'''
15261537
postbuild = "postbuild_{}".format(arch.arch)
15271538
if hasattr(self, postbuild):
15281539
getattr(self, postbuild)()
@@ -1548,6 +1559,7 @@ def list_recipes(cls):
15481559

15491560
@classmethod
15501561
def get_recipe(cls, name, ctx):
1562+
'''Returns the Recipe with the given name, if it exists.'''
15511563
if not hasattr(cls, "recipes"):
15521564
cls.recipes = {}
15531565
if name in cls.recipes:
@@ -1628,7 +1640,6 @@ def should_build(self):
16281640
if exists(join(self.ctx.get_site_packages_dir(), name)):
16291641
info('Python package already exists in site-packages')
16301642
return False
1631-
print('site packages', self.ctx.get_site_packages_dir())
16321643
info('{} apparently isn\'t already in site-packages'.format(name))
16331644
return True
16341645

@@ -1660,43 +1671,6 @@ def install_python_package(self, name=None, env=None, is_dir=True):
16601671

16611672
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env)
16621673

1663-
# def install_python_package(self, name=None, env=None, is_dir=True):
1664-
# """Automate the installation of a Python package into the target
1665-
# site-packages.
1666-
1667-
# It will works with the first filtered_archs, and the name of the recipe.
1668-
# """
1669-
# arch = self.filtered_archs[0]
1670-
# if name is None:
1671-
# name = self.name
1672-
# if env is None:
1673-
# env = self.get_recipe_env(arch)
1674-
1675-
# print("Install {} into the site-packages".format(name))
1676-
# build_dir = self.get_build_dir(arch.arch)
1677-
# chdir(build_dir)
1678-
# hostpython = sh.Command(self.ctx.hostpython)
1679-
# iosbuild = join(build_dir, "iosbuild")
1680-
# shprint(hostpython, "setup.py", "install", "-O2",
1681-
# "--prefix", iosbuild,
1682-
# _env=env)
1683-
# dest_dir = join(self.ctx.site_packages_dir, name)
1684-
# if is_dir:
1685-
# if exists(dest_dir):
1686-
# shutil.rmtree(dest_dir)
1687-
# func = shutil.copytree
1688-
# else:
1689-
# func = shutil.copy
1690-
# func(
1691-
# join(iosbuild, "lib",
1692-
# self.ctx.python_ver_dir, "site-packages", name),
1693-
# dest_dir)
1694-
1695-
# def reduce_python_package(self):
1696-
# """Feel free to remove things you don't want in the final
1697-
# site-packages.
1698-
# """
1699-
# pass
17001674

17011675
class CompiledComponentsPythonRecipe(PythonRecipe):
17021676
pre_build_ext = False

0 commit comments

Comments
 (0)