You are not logged in.

#1 2012-08-10 11:25:28

w0dash
Member
Registered: 2012-05-28
Posts: 8

Makefile needs python2

Hi,

I need to build a Makefile which does not work with python3.

It does not work because in archlinux python != python2.

What can I do to make it compile flawless?

Offline

#2 2012-08-10 11:32:28

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,646

Offline

#3 2012-08-10 11:34:04

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: Makefile needs python2

Use python2

$ python --version
Python 3.2.3
$ python2 --version
Python 2.7.3
$ which python
/usr/bin/python
$ which python2
/usr/bin/python2

edit: too slow.

Last edited by Trilby (2012-08-10 11:34:24)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2012-08-10 12:07:04

w0dash
Member
Registered: 2012-05-28
Posts: 8

Re: Makefile needs python2

I get this error:

"Bitbake is not compatible with python v3
Please set up python v2 as your default python interpreter"

Can you tell me exactly what to do?

Offline

#5 2012-08-10 12:22:17

AaronBP
Member
Registered: 2012-08-06
Posts: 149
Website

Re: Makefile needs python2

Looks like there is a package for bitbake in the AUR. If you're wanting to figure out how to do this yourself study the PKGBUILD.

https://aur.archlinux.org/packages.php?ID=9503

Offline

#6 2012-08-10 12:55:33

w0dash
Member
Registered: 2012-05-28
Posts: 8

Re: Makefile needs python2

That package is pretty old.

Is there no easy way to "route" the python calls to /usr/bin/python2 instead of /usr/bin/python?

I don't want to create a symlink, because I read that that could cause even more trouble.

Last edited by w0dash (2012-08-10 12:55:43)

Offline

#7 2012-08-10 13:00:36

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,498
Website

Re: Makefile needs python2

The PKGBUILD in the AUR looks to have the solution....   "python2 setup.py build"

Offline

#8 2012-08-10 14:20:16

progandy
Member
Registered: 2012-05-17
Posts: 5,279

Re: Makefile needs python2

w0dash wrote:

Is there no easy way to "route" the python calls to /usr/bin/python2 instead of /usr/bin/python?

There is no need. Just replace #!/usr/bin/env python with #!/usr/bin/env python2 in all files in ./bin
Edit: And also in setup.py

Last edited by progandy (2012-08-10 14:21:06)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#9 2012-08-10 17:49:55

w0dash
Member
Registered: 2012-05-28
Posts: 8

Re: Makefile needs python2

To make it clear, I don't want to install bitbake. I want to compile the OpenPLi dreambox image, maybe some of you know it.

They distribute bitbake within their git repository.

I think I will install Ubuntu in another partition. smile


Edit:

I've found out that they use a wrapper for bitbake (and I have no idea what I am doing wink)

FYI:

#!/bin/sh

# This is the bitbake wrapper script that ensures everything is set up
# correctly in the environment, builds pseudo separately if it hasn't
# already been built, and then runs bitbake within pseudo.

export BBFETCH2=True
export BB_ENV_EXTRAWHITE="PSEUDO_BUILD PSEUDO_DISABLED $BB_ENV_EXTRAWHITE"

# For certain operations (i.e. that won't be actually running any tasks)
# we don't need pseudo
NO_BUILD_OPTS="--version -h --help -p --parse-only -s --show-versions -e --environment -g --graphviz"

# Some options are useful to pass through to the initial pseudo build if
# that needs to be run (for debugging)
PASSTHROUGH_OPTS="-D -DD -DDD -DDDD -v"

needpseudo="1"
for opt in $@; do
for key in $NO_BUILD_OPTS; do
    if [ $opt = $key ]
    then
        needpseudo="0"
        break
    fi
done
[ $needpseudo = "0" ] && break
done

# Make sure we're not using python v3.x. This check can't go into
# sanity.bbclass because bitbake's source code doesn't even pass
# parsing stage when used with python v3, so we catch it here so we
# can offer a meaningful error message.
py_v3_check=`/usr/bin/env python --version 2>&1 | grep "Python 3"`
if [ "$py_v3_check" != "" ]; then
	echo "Bitbake is not compatible with python v3"
	echo "Please set up python v2 as your default python interpreter"
	exit 1
fi

# Similarly, we now have code that doesn't parse correctly with older
# versions of Python, and rather than fixing that and being eternally
# vigilant for any other new feature use, just check the version here.
py_v26_check=`python -c 'import sys; print sys.version_info >= (2,6,0)'`
if [ "$py_v26_check" != "True" ]; then
	echo "BitBake requires Python 2.6 or later"
	exit 1
fi

if [ ! -e conf/bblayers.conf ] ; then
    BDPRINT=""
    [ -n "$BUILDDIR" ] && BDPRINT=": $BUILDDIR"
    echo "Unable to find conf/bblayers.conf"
    echo "BitBake must be run from within your build directory$BDPRINT"
    exit 1
elif [ -z "$BUILDDIR" ] ; then
    BUILDDIR="`pwd`"
fi

needtar="1"
TARVERSION=`tar --version | head -n 1 | cut -d ' ' -f 4`
float_test() {
     echo | awk 'END { exit ( !( '"$1"')); }'
}

# Tar version 1.24 and onwards handle overwriting symlinks correctly
# but earlier versions do not; this needs to work properly for sstate
float_test "$TARVERSION > 1.23" && needtar="0"

buildpseudo="1"
if [ $needpseudo = "1" ]; then
    if [ -e "$BUILDDIR/pseudodone" ]; then
        PSEUDOBINDIR=`cat $BUILDDIR/pseudodone`
    else
        PSEUDOBINDIR=`bitbake -e | grep STAGING_BINDIR_NATIVE=\" | cut -d '=' -f2 | cut -d '"' -f2`
    fi
    if [ -e "$PSEUDOBINDIR/pseudo" ]; then
        buildpseudo="0"
    fi

    # Verify that the pseudo recipes are older then the pseudodone file
    PSEUDO_RECIPE="`dirname $0`/../meta/recipes-devtools/pseudo"
    if [ $buildpseudo -eq 0 ] && [ ! -d "$PSEUDO_RECIPE" ]; then
        echo "Unable to verify if pseudo-native is up to date..." >&2
    elif [ $buildpseudo -eq 0 ]; then
	PSEUDO_NEWER=`find $PSEUDO_RECIPE -type f -newer $BUILDDIR/pseudodone`
	if [ -n "$PSEUDO_NEWER" ]; then
            buildpseudo="2"
	fi
    fi
    if [ $buildpseudo = "0" -a ! -e "$BUILDDIR/pseudodone" ] ; then
        echo $PSEUDOBINDIR > $BUILDDIR/pseudodone
    fi
fi

# If tar is already built, we don't want to do it again...
if [ -e "$PSEUDOBINDIR/tar" -a "$needtar" = "1" ]; then
    needtar="0"
fi

if [ $needpseudo = "0" ]; then
    buildpseudo="0"
fi

# If pseudo-native is an argument, assume the user wants to build pseudo-native!
if [ $needpseudo != "0" -a $buildpseudo -eq 0 ]; then
    for opt in $@; do
        if [ "$opt" = "pseudo-native" ]; then
            buildpseudo="3"
            break
        fi
    done
fi

OLDPATH=$PATH
export PATH=`echo $PATH | sed s#[^:]*/scripts:##`
if [ $buildpseudo -gt 0 ]; then
    [ $buildpseudo -eq 1 ] && echo "Pseudo is not present but is required, building this first before the main build"
    [ $buildpseudo -eq 2 ] && echo "Pseudo may be out of date, rebuilding pseudo before the main build"
    [ $buildpseudo -eq 3 ] && echo "Building pseudo-native before main build"
    export PSEUDO_BUILD=1
    TARTARGET="tar-replacement-native"
    if [ $needtar = "0" ]; then
        TARTARGET=""
    fi
    # Pass through debug options
    additionalopts=""
    for opt in $@; do
        for key in $PASSTHROUGH_OPTS; do
            if [ $opt = $key ]
            then
                additionalopts="$additionalopts $opt"
                break
            fi
        done
    done
    bitbake pseudo-native $TARTARGET $additionalopts -c populate_sysroot
    ret=$?
    if [ "$ret" != "0" ]; then
        exit 1
    fi
    PSEUDOBINDIR=`bitbake -e | grep STAGING_BINDIR_NATIVE=\" | cut -d '=' -f2 | cut -d '"' -f2`
    ret=$?
    if [ "$ret" != "0" ]; then
        exit 1
    fi
    echo $PSEUDOBINDIR > $BUILDDIR/pseudodone
    # This needs to exist in case pseudo has to log somewhere
    mkdir -p $PSEUDOBINDIR/../../var/pseudo
fi
BITBAKE=`which bitbake`
export PATH=$OLDPATH
if [ $needpseudo = "1" ]; then
    export PSEUDO_BUILD=2
    PSEUDO_BINDIR=$PSEUDOBINDIR PSEUDO_LIBDIR=$PSEUDOBINDIR/../lib/pseudo/lib PSEUDO_PREFIX=$PSEUDOBINDIR/../../ PSEUDO_DISABLED=1 $PSEUDOBINDIR/pseudo $BITBAKE $@
else
    export PSEUDO_BUILD=0
    $BITBAKE $@
fi
ret=$?
exit $ret

Last edited by w0dash (2012-08-10 18:12:58)

Offline

#10 2012-08-10 18:51:59

progandy
Member
Registered: 2012-05-17
Posts: 5,279

Re: Makefile needs python2

Please read the wiki instructions for python2: https://wiki.archlinux.org/index.php/Python#Python_2 Especially the part about modifying the environment for one shell and its subprocesses.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#11 2012-08-10 19:51:26

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,646

Re: Makefile needs python2

progandy wrote:

Please read the wiki instructions for python2: https://wiki.archlinux.org/index.php/Python#Python_2 Especially the part about modifying the environment for one shell and its subprocesses.

The very link I pointed him to in my first reply sad

Offline

#12 2012-08-11 07:50:57

w0dash
Member
Registered: 2012-05-28
Posts: 8

Re: Makefile needs python2

I already read that. I appreciate your answer 2ManyDogs.

But it seems that the scripts also use "#!/usr/bin/python" in which case that env trick is not possible.

Offline

#13 2012-08-11 22:36:51

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,152

Re: Makefile needs python2

So just use a combination: the env trick to deal with the version checks in the wrapper and editing the interpreter line for the scripts. Or change it in the wrapper as well. The wiki offers several methods only one of which won't work with #!/usr/bin/python and it even tells you that...


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

Board footer

Powered by FluxBB