Skip to content

Fix various issues with graphs and recipes #1669

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

Merged
merged 1 commit into from Feb 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ class Bootstrap(object):
dist_name = None
distribution = None

recipe_depends = ['sdl2']
# All bootstraps should include Python in some way:
recipe_depends = [
("python2", "python2legacy", "python3", "python3crystax"),
]

can_be_chosen_automatically = True
'''Determines whether the bootstrap can be chosen as one that
Expand Down Expand Up @@ -167,15 +170,15 @@ def get_bootstrap_from_recipes(cls, recipes, ctx):
for recipe in recipes:
try:
recipe = Recipe.get_recipe(recipe, ctx)
except IOError:
except ValueError:
conflicts = []
else:
conflicts = recipe.conflicts
if any([conflict in possible_dependencies
for conflict in conflicts]):
ok = False
break
if ok:
if ok and bs not in acceptable_bootstraps:
acceptable_bootstraps.append(bs)
info('Found {} acceptable bootstraps: {}'.format(
len(acceptable_bootstraps),
Expand Down
3 changes: 2 additions & 1 deletion pythonforandroid/bootstraps/common/build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ def parse_args(args=None):

# --private is required unless for sdl2, where there's also --launcher
ap.add_argument('--private', dest='private',
help='the dir of user files',
help='the directory with the app source code files' +
' (containing your main.py entrypoint)',
required=(get_bootstrap_name() != "sdl2"))
ap.add_argument('--package', dest='package',
help=('The name of the java package the project will be'
Expand Down
4 changes: 3 additions & 1 deletion pythonforandroid/bootstraps/sdl2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
class SDL2GradleBootstrap(Bootstrap):
name = 'sdl2'

recipe_depends = ['sdl2']
recipe_depends = list(
set(Bootstrap.recipe_depends).union({'sdl2'})
)

def run_distribute(self):
info_main("# Creating Android project ({})".format(self.name))
Expand Down
4 changes: 3 additions & 1 deletion pythonforandroid/bootstraps/service_only/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ class ServiceOnlyBootstrap(Bootstrap):

name = 'service_only'

recipe_depends = ['genericndkbuild', ('python2', 'python3', 'python3crystax')]
recipe_depends = list(
set(Bootstrap.recipe_depends).union({'genericndkbuild'})
)

def run_distribute(self):
info_main('# Creating Android project from build and {} bootstrap'.format(
Expand Down
4 changes: 3 additions & 1 deletion pythonforandroid/bootstraps/webview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
class WebViewBootstrap(Bootstrap):
name = 'webview'

recipe_depends = ['genericndkbuild', ('python2', 'python3', 'python3crystax')]
recipe_depends = list(
set(Bootstrap.recipe_depends).union({'genericndkbuild'})
)

def run_distribute(self):
info_main('# Creating Android project from build and {} bootstrap'.format(
Expand Down
26 changes: 13 additions & 13 deletions pythonforandroid/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
import sh
import subprocess

from pythonforandroid.util import (ensure_dir, current_directory, BuildInterruptingException)
from pythonforandroid.util import (
current_directory, ensure_dir, get_virtualenv_executable,
BuildInterruptingException
)
from pythonforandroid.logger import (info, warning, info_notify, info_main, shprint)
from pythonforandroid.archs import ArchARM, ArchARMv7_a, ArchAarch_64, Archx86, Archx86_64
from pythonforandroid.recipe import CythonRecipe, Recipe
Expand Down Expand Up @@ -305,13 +308,7 @@ def prepare_build_environment(self,

check_ndk_api(ndk_api, self.android_api)

virtualenv = None
if virtualenv is None:
virtualenv = sh.which('virtualenv2')
if virtualenv is None:
virtualenv = sh.which('virtualenv-2.7')
if virtualenv is None:
virtualenv = sh.which('virtualenv')
virtualenv = get_virtualenv_executable()
if virtualenv is None:
raise IOError('Couldn\'t find a virtualenv executable, '
'you must install this to use p4a.')
Expand Down Expand Up @@ -509,7 +506,7 @@ def has_package(self, name, arch=None):
# Try to look up recipe by name:
try:
recipe = Recipe.get_recipe(name, self)
except IOError:
except ValueError:
pass
else:
name = getattr(recipe, 'site_packages_name', None) or name
Expand Down Expand Up @@ -618,14 +615,15 @@ def run_pymodules_install(ctx, modules):
line = '{}\n'.format(module)
fileh.write(line)

# Prepare base environment and upgrade pip:
base_env = copy.copy(os.environ)
base_env["PYTHONPATH"] = ctx.get_site_packages_dir()

info('Upgrade pip to latest version')
shprint(sh.bash, '-c', (
"source venv/bin/activate && pip install -U pip"
), _env=copy.copy(base_env))

# Install Cython in case modules need it to build:
info('Install Cython in case one of the modules needs it to build')
shprint(sh.bash, '-c', (
"venv/bin/pip install Cython"
Expand All @@ -648,15 +646,17 @@ def run_pymodules_install(ctx, modules):
'changes / workarounds.')

# Make sure our build package dir is available, and the virtualenv
# site packages come FIRST (for the proper pip version):
# site packages come FIRST (so the proper pip version is used):
env["PYTHONPATH"] += ":" + ctx.get_site_packages_dir()
env["PYTHONPATH"] = os.path.abspath(join(
ctx.build_dir, "venv", "lib",
"python" + ctx.python_recipe.major_minor_version_string,
"site-packages")) + ":" + env["PYTHONPATH"]

# Do actual install:
shprint(sh.bash, '-c', (
"source venv/bin/activate && " +
"pip install -v --target '{0}' --no-deps -r requirements.txt"
"venv/bin/pip " +
"install -v --target '{0}' --no-deps -r requirements.txt"
).format(ctx.get_site_packages_dir().replace("'", "'\"'\"'")),
_env=copy.copy(env))

Expand Down
Loading