2018-11-02 11:44:25 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-11-10 01:40:55 +01:00
|
|
|
import sys
|
2018-11-02 11:44:25 +01:00
|
|
|
from toolchain import Recipe
|
2019-02-07 10:00:23 +01:00
|
|
|
import logging
|
2019-09-16 19:53:15 +02:00
|
|
|
from os.path import join
|
2019-02-07 10:00:23 +01:00
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
2018-11-02 11:44:25 +01:00
|
|
|
|
|
|
|
class PythonAliasRecipe(Recipe):
|
|
|
|
is_alias = True
|
|
|
|
|
|
|
|
def init_after_import(self, ctx):
|
|
|
|
python = ctx.state.get("python")
|
|
|
|
if not python:
|
2018-11-09 19:14:05 +01:00
|
|
|
# search in wanted_recipes if it's the first time
|
|
|
|
if "python2" in ctx.wanted_recipes:
|
|
|
|
python = "python2"
|
|
|
|
elif "python3" in ctx.wanted_recipes:
|
|
|
|
python = "python3"
|
|
|
|
else:
|
2019-02-07 10:00:23 +01:00
|
|
|
logger.error("No Python version set in the build.")
|
|
|
|
logger.error("Add python2 or python3 in your recipes:")
|
|
|
|
logger.error("./toolchain.py build python3 ...")
|
2018-11-10 01:40:55 +01:00
|
|
|
sys.exit(1)
|
2018-11-09 19:14:05 +01:00
|
|
|
if python:
|
2018-11-02 11:44:25 +01:00
|
|
|
self.depends = [python]
|
2019-09-16 19:53:15 +02:00
|
|
|
self.recipe_dir = join(ctx.root_dir, "recipes", python)
|
2018-11-02 11:44:25 +01:00
|
|
|
|
|
|
|
recipe = PythonAliasRecipe()
|