Skip to content

Commit

Permalink
Merge pull request #1160 from inclement/cleanup
Browse files Browse the repository at this point in the history
Cleaned up some old comments
  • Loading branch information
inclement authored Nov 12, 2017
2 parents 727b6b2 + ae93673 commit e61c889
Show file tree
Hide file tree
Showing 16 changed files with 20 additions and 79 deletions.
2 changes: 1 addition & 1 deletion pythonforandroid/archs.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def get_env(self, with_flags_in_cc=True):

hostpython_recipe = Recipe.get_recipe('hostpython2', self.ctx)

# AND: This hardcodes python version 2.7, needs fixing
# This hardcodes python version 2.7, needs fixing
env['BUILDLIB_PATH'] = join(
hostpython_recipe.get_build_dir(self.arch),
'build', 'lib.linux-{}-2.7'.format(uname()[-1]))
Expand Down
2 changes: 0 additions & 2 deletions pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ def get_bootstrap(cls, name, ctx):
This is the only way you should access a bootstrap class, as
it sets the bootstrap directory correctly.
'''
# AND: This method will need to check user dirs, and access
# bootstraps in a slightly different way
if name is None:
return None
if not hasattr(cls, 'bootstraps'):
Expand Down
2 changes: 0 additions & 2 deletions pythonforandroid/bootstraps/pygame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def run_distribute(self):

info('Copying python distribution')
hostpython = sh.Command(self.ctx.hostpython)
# AND: This *doesn't* need to be in arm env?
try:
shprint(hostpython, '-OO', '-m', 'compileall', self.ctx.get_python_install_dir(),
_tail=10, _filterout="^Listing")
Expand All @@ -64,7 +63,6 @@ def run_distribute(self):
shprint(sh.cp, '-a', join('python-install', 'lib'), 'private')
shprint(sh.mkdir, '-p', join('private', 'include', 'python2.7'))

# AND: Copylibs stuff should go here
shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/')
shprint(sh.cp, join('python-install', 'include' , 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))

Expand Down
1 change: 0 additions & 1 deletion pythonforandroid/bootstraps/sdl2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def run_distribute(self):
shprint(sh.mkdir, "-p",
join("private", "include", "python2.7"))

# AND: Copylibs stuff should go here
libpymodules_fn = join("libs", arch.arch, "libpymodules.so")
if exists(libpymodules_fn):
shprint(sh.mv, libpymodules_fn, 'private/')
Expand Down
3 changes: 1 addition & 2 deletions pythonforandroid/bootstraps/sdl2/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ def make_package(args):
# construct a python27.zip
make_python_zip()

# Package up the private and public data.
# AND: Just private for now
# Package up the private data (public not supported).
tar_dirs = [args.private]
if exists('private'):
tar_dirs.append('private')
Expand Down
1 change: 0 additions & 1 deletion pythonforandroid/bootstraps/service_only/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def run_distribute(self):
shprint(sh.cp, '-a', join('python-install', 'lib'), 'private')
shprint(sh.mkdir, '-p', join('private', 'include', 'python2.7'))

# AND: Copylibs stuff should go here
if exists(join('libs', arch.arch, 'libpymodules.so')):
shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/')
shprint(sh.cp, join('python-install', 'include', 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))
Expand Down
7 changes: 3 additions & 4 deletions pythonforandroid/bootstraps/service_only/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

# pyc/py
'*.pyc',
# '*.py', # AND: Need to fix this to add it back
# '*.py',

# temp files
'~',
Expand Down Expand Up @@ -204,7 +204,7 @@ def compile_dir(dfn):
Compile *.py in directory `dfn` to *.pyo
'''

return # AND: Currently leaving out the compile to pyo step because it's somehow broken
return # Currently leaving out the compile to pyo step because it's somehow broken
# -OO = strip docstrings
subprocess.call([PYTHON, '-OO', '-m', 'compileall', '-f', dfn])

Expand All @@ -230,8 +230,7 @@ def make_package(args):
# construct a python27.zip
make_python_zip()

# Package up the private and public data.
# AND: Just private for now
# Package up the private data (public not supported).
tar_dirs = [args.private]
if exists('private'):
tar_dirs.append('private')
Expand Down
1 change: 0 additions & 1 deletion pythonforandroid/bootstraps/webview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def run_distribute(self):
shprint(sh.cp, '-a', join('python-install', 'lib'), 'private')
shprint(sh.mkdir, '-p', join('private', 'include', 'python2.7'))

# AND: Copylibs stuff should go here
if exists(join('libs', arch.arch, 'libpymodules.so')):
shprint(sh.mv, join('libs', arch.arch, 'libpymodules.so'), 'private/')
shprint(sh.cp, join('python-install', 'include' , 'python2.7', 'pyconfig.h'), join('private', 'include', 'python2.7/'))
Expand Down
7 changes: 3 additions & 4 deletions pythonforandroid/bootstraps/webview/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# pyc/py
'*.pyc',
# '*.py', # AND: Need to fix this to add it back
# '*.py',

# temp files
'~',
Expand Down Expand Up @@ -203,7 +203,7 @@ def compile_dir(dfn):
Compile *.py in directory `dfn` to *.pyo
'''

return # AND: Currently leaving out the compile to pyo step because it's somehow broken
return # Currently leaving out the compile to pyo step because it's somehow broken
# -OO = strip docstrings
subprocess.call([PYTHON, '-OO', '-m', 'compileall', '-f', dfn])

Expand All @@ -229,8 +229,7 @@ def make_package(args):
# construct a python27.zip
make_python_zip()

# Package up the private and public data.
# AND: Just private for now
# Package up the private data (public not supported).
tar_dirs = [args.private]
if exists('private'):
tar_dirs.append('private')
Expand Down
14 changes: 6 additions & 8 deletions pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
if self._build_env_prepared:
return

# AND: This needs revamping to carefully check each dependency
# in turn
ok = True

# Work out where the Android SDK is
Expand All @@ -186,7 +184,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
if sdk_dir is None: # This seems used more conventionally
sdk_dir = environ.get('ANDROID_HOME', None)
if sdk_dir is None: # Checks in the buildozer SDK dir, useful
# # for debug tests of p4a
# for debug tests of p4a
possible_dirs = glob.glob(expanduser(join(
'~', '.buildozer', 'android', 'platform', 'android-sdk-*')))
possible_dirs = [d for d in possible_dirs if not
Expand Down Expand Up @@ -325,8 +323,9 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
warning('If the NDK dir result is correct, you don\'t '
'need to manually set the NDK ver.')
if ndk_ver is None:
warning('Android NDK version could not be found, exiting.')
exit(1)
warning('Android NDK version could not be found. This probably'
'won\'t cause any problems, but if necessary you can'
'set it with `--ndk-version=...`.')
self.ndk_ver = ndk_ver

info('Using {} NDK {}'.format(self.ndk.capitalize(), self.ndk_ver))
Expand Down Expand Up @@ -361,7 +360,7 @@ def prepare_build_environment(self, user_sdk_dir, user_ndk_dir,
ok = False
warning("Missing requirement: cython is not installed")

# AND: need to change if supporting multiple archs at once
# This would need to be changed if supporting multiarch APKs
arch = self.archs[0]
platform_dir = arch.platform_dir
toolchain_prefix = arch.toolchain_prefix
Expand Down Expand Up @@ -498,7 +497,7 @@ def get_site_packages_dir(self, arch=None):
dir.
'''

# AND: This *must* be replaced with something more general in
# This needs to be replaced with something more general in
# order to support multiple python versions and/or multiple
# archs.
if self.python_recipe.from_crystax:
Expand Down Expand Up @@ -577,7 +576,6 @@ def build_recipes(build_order, python_modules, ctx):
.format(recipe.name))

# 4) biglink everything
# AND: Should make this optional
info_main('# Biglinking object files')
if not ctx.python_recipe or not ctx.python_recipe.from_crystax:
biglink(ctx, arch)
Expand Down
4 changes: 0 additions & 4 deletions pythonforandroid/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ def get_distribution(cls, ctx, name=None, recipes=[],
correct set of recipes.
'''

# AND: This whole function is a bit hacky, it needs checking
# properly to make sure it follows logically correct
# possibilities

existing_dists = Distribution.get_distributions(ctx)

needs_build = True # whether the dist needs building, will be returned
Expand Down
27 changes: 3 additions & 24 deletions pythonforandroid/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,19 @@ def apply_patch(self, filename, arch):
build directory.
"""
info("Applying patch {}".format(filename))
filename = join(self.recipe_dir, filename)
filename = join(self.get_recipe_dir(), filename)
shprint(sh.patch, "-t", "-d", self.get_build_dir(arch), "-p1",
"-i", filename, _tail=10)

def copy_file(self, filename, dest):
info("Copy {} to {}".format(filename, dest))
filename = join(self.recipe_dir, filename)
filename = join(self.get_recipe_dir(), filename)
dest = join(self.build_dir, dest)
shutil.copy(filename, dest)

def append_file(self, filename, dest):
info("Append {} to {}".format(filename, dest))
filename = join(self.recipe_dir, filename)
filename = join(self.get_recipe_dir(), filename)
dest = join(self.build_dir, dest)
with open(filename, "rb") as fd:
data = fd.read()
Expand Down Expand Up @@ -330,7 +330,6 @@ def get_build_dir(self, arch):
return join(self.get_build_container_dir(arch), self.name)

def get_recipe_dir(self):
# AND: Redundant, an equivalent property is already set by get_recipe
return join(self.ctx.root_dir, 'recipes', self.name)

# Public Recipe API to be subclassed if needed
Expand Down Expand Up @@ -412,8 +411,6 @@ def unpack(self, arch):
if user_dir is not None:
info('P4A_{}_DIR exists, symlinking instead'.format(
self.name.lower()))
# AND: Currently there's something wrong if I use ln, fix this
warning('Using cp -a instead of symlink...fix this!')
if exists(self.get_build_dir(arch)):
return
shprint(sh.rm, '-rf', build_dir)
Expand All @@ -436,7 +433,6 @@ def unpack(self, arch):
with current_directory(build_dir):
directory_name = self.get_build_dir(arch)

# AND: Could use tito's get_archive_rootdir here
if not exists(directory_name) or not isdir(directory_name):
extraction_filename = join(
self.ctx.packages_path, self.name, filename)
Expand Down Expand Up @@ -649,7 +645,6 @@ def get_recipe(cls, name, ctx):
if len(logger.handlers) > 1:
logger.removeHandler(logger.handlers[1])
recipe = mod.recipe
recipe.recipe_dir = dirname(recipe_file)
recipe.ctx = ctx
cls.recipes[name] = recipe
return recipe
Expand Down Expand Up @@ -832,26 +827,11 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):


if self.ctx.python_recipe.from_crystax:
# hppath = join(dirname(self.hostpython_location), 'Lib',
# 'site-packages')
hpenv = env.copy()
# if 'PYTHONPATH' in hpenv:
# hpenv['PYTHONPATH'] = ':'.join([hppath] +
# hpenv['PYTHONPATH'].split(':'))
# else:
# hpenv['PYTHONPATH'] = hppath
# hpenv['PYTHONHOME'] = self.ctx.get_python_install_dir()
# shprint(hostpython, 'setup.py', 'build',
# _env=hpenv, *self.setup_extra_args)
shprint(hostpython, 'setup.py', 'install', '-O2',
'--root={}'.format(self.ctx.get_python_install_dir()),
'--install-lib=.',
# AND: will need to unhardcode the 3.5 when adding 2.7 (and other crystax supported versions)
_env=hpenv, *self.setup_extra_args)
# site_packages_dir = self.ctx.get_site_packages_dir()
# built_files = glob.glob(join('build', 'lib*', '*'))
# for filen in built_files:
# shprint(sh.cp, '-r', filen, join(site_packages_dir, split(filen)[-1]))
elif self.call_hostpython_via_targetpython:
shprint(hostpython, 'setup.py', 'install', '-O2', _env=env,
*self.setup_extra_args)
Expand All @@ -868,7 +848,6 @@ def install_python_package(self, arch, name=None, env=None, is_dir=True):
'--root={}'.format(self.ctx.get_python_install_dir()),
'--install-lib=lib/python2.7/site-packages',
_env=hpenv, *self.setup_extra_args)
# AND: Hardcoded python2.7 needs fixing

# If asked, also install in the hostpython build dir
if self.install_in_hostpython:
Expand Down
1 change: 0 additions & 1 deletion pythonforandroid/recipes/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class NumpyRecipe(CompiledComponentsPythonRecipe):
def prebuild_arch(self, arch):
super(NumpyRecipe, self).prebuild_arch(arch)

# AND: Fix this warning!
warning('Numpy is built assuming the archiver name is '
'arm-linux-androideabi-ar, which may not always be true!')

Expand Down
7 changes: 2 additions & 5 deletions pythonforandroid/recipes/pygame/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

from pythonforandroid.recipe import Recipe
from pythonforandroid.util import current_directory, ensure_dir
from pythonforandroid.logger import debug, shprint, info
from pythonforandroid.logger import debug, shprint, info, warning
from os.path import exists, join
import sh
import glob
Expand Down Expand Up @@ -39,8 +39,6 @@ def prebuild_arch(self, arch):
join(self.get_build_dir(arch.arch), 'Setup'))

def build_arch(self, arch):
# AND: I'm going to ignore any extra pythonrecipe or cythonrecipe behaviour for now

env = self.get_recipe_env(arch)

env['CFLAGS'] = env['CFLAGS'] + ' -I{jni_path}/png -I{jni_path}/jpeg'.format(
Expand Down Expand Up @@ -71,8 +69,7 @@ def build_arch(self, arch):
env['STRIP'], '{}', ';')

python_install_path = join(self.ctx.build_dir, 'python-install')
# AND: Should do some deleting here!
print('Should remove pygame tests etc. here, but skipping for now')
warning('Should remove pygame tests etc. here, but skipping for now')


recipe = PygameRecipe()
6 changes: 1 addition & 5 deletions pythonforandroid/recipes/python2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ def do_python_build(self, arch):

env = arch.get_env()

# AND: Should probably move these to get_recipe_env for
# neatness, but the whole recipe needs tidying along these
# lines
env['HOSTARCH'] = 'arm-eabi'
env['BUILDARCH'] = shprint(sh.gcc, '-dumpmachine').stdout.decode('utf-8').split('\n')[0]
env['CFLAGS'] = ' '.join([env['CFLAGS'], '-DNO_MALLINFO'])
Expand Down Expand Up @@ -114,7 +111,6 @@ def do_python_build(self, arch):
# NDK has langinfo.h but doesn't define nl_langinfo()
env['ac_cv_header_langinfo_h'] = 'no'
configure = sh.Command('./configure')
# AND: OFLAG isn't actually set, should it be?
shprint(configure,
'--host={}'.format(env['HOSTARCH']),
'--build={}'.format(env['BUILDARCH']),
Expand All @@ -125,7 +121,7 @@ def do_python_build(self, arch):
'--disable-framework',
_env=env)

# AND: tito left this comment in the original source. It's still true!
# tito left this comment in the original source. It's still true!
# FIXME, the first time, we got a error at:
# python$EXE ../../Tools/scripts/h2py.py -i '(u_long)' /usr/include/netinet/in.h
# /home/tito/code/python-for-android/build/python/Python-2.7.2/python: 1: Syntax error: word unexpected (expecting ")")
Expand Down
14 changes: 0 additions & 14 deletions pythonforandroid/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def dist_from_args(ctx, args):
ctx,
name=args.dist_name,
recipes=split_argument_list(args.requirements),
extra_dist_dirs=split_argument_list(args.extra_dist_dirs),
require_perfect_match=args.require_perfect_match)


Expand Down Expand Up @@ -279,8 +278,6 @@ def __init__(self):
help=('Primary storage directory for downloads and builds '
'(default: {})'.format(default_storage_dir)))

# AND: This option doesn't really fit in the other categories, the
# arg structure needs a rethink
generic_parser.add_argument(
'--arch',
help='The archs to build for, separated by commas.',
Expand Down Expand Up @@ -313,11 +310,6 @@ def __init__(self):
default=False,
description='Whether to force compilation of a new distribution:')

generic_parser.add_argument(
'--extra-dist-dirs', '--extra_dist_dirs',
dest='extra_dist_dirs', default='',
help='Directories in which to look for distributions')

add_boolean_option(
generic_parser, ["require-perfect-match"],
default=False,
Expand Down Expand Up @@ -513,12 +505,6 @@ def add_parser(subparsers, *args, **kwargs):

self._archs = split_argument_list(args.arch)

# AND: Fail nicely if the args aren't handled yet
if args.extra_dist_dirs:
warning('Received --extra_dist_dirs but this arg currently is not '
'handled, exiting.')
exit(1)

self.ctx.local_recipes = args.local_recipes
self.ctx.copy_libs = args.copy_libs

Expand Down

0 comments on commit e61c889

Please sign in to comment.