8000 Merge branch 'master' of https://github.com/torfinnberset/python-for-… · angshu-min-js/python-for-android@6bf016f · GitHub
[go: up one dir, main page]

Skip to content

Commit 6bf016f

Browse files
kivykivy
authored andcommitted
2 parents d687053 + 318e2ed commit 6bf016f

File tree

10 files changed

+280
-6
lines changed
  • plyvel
  • 10 files changed

    +280
    -6
    lines changed

    recipes/apsw/recipe.sh

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -7,7 +7,7 @@ VERSION_apsw=${VERSION_apsw:-3.8.4.1-r1}
    77
    DEPS_apsw=(python)
    88

    99
    # url of the package
    10-
    URL_apsw=https://github.com/rogerbinns/apsw/releases/download/3.8.4.1-r1/apsw-3.8.4.1-r1.zip
    10+
    URL_apsw=https://github.com/rogerbinns/apsw/releases/download/${VERSION_apsw}/apsw-${VERSION_apsw}.zip
    1111

    1212
    # md5 of the package
    1313
    MD5_apsw=5ad3098489576929b90f4215eb5b2621

    recipes/boost/project-config.jam

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1 @@
    1+
    # Boost.Build Configuration

    recipes/boost/recipe.sh

    Lines changed: 54 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,54 @@
    1+
    #!/bin/bash
    2+
    # This recipe only downloads Boost and builds Boost.Build
    3+
    # Since Boost by default uses version numbers in the library names, it makes linking to them harder (as Android does not accept version numbers)
    4+
    # This is used in the libtorrent recipe and Boost.Build is used to (recursivly) compile Boost from the source here
    5+
    VERSION_boost=${VERSION_boost:-1.58.0}
    6+
    DEPS_boost=(python)
    7+
    URL_boost=http://downloads.sourceforge.net/project/boost/boost/${VERSION_boost}/boost_1_58_0.tar.gz # Don't forget to change the URL when changing the version
    8+
    MD5_boost=5a5d5614d9a07672e1ab2a250b5defc5
    9+
    BUILD_boost=$BUILD_PATH/boost/$(get_directory $URL_boost)
    10+
    RECIPE_boost=$RECIPES_PATH/boost
    11+
    12+
    function prebuild_boost() {
    13+
    cd $BUILD_boost
    14+
    15+
    # Boost config locations
    16+
    RECIPECONFIG=${RECIPE_boost}/user-config.jam
    17+
    BOOSTCONFIG=${BUILD_boost}/tools/build/src/user-config.jam
    18+
    19+
    # Make Boost.Build
    20+
    ./bootstrap.sh --with-python=$HOSTPYTHON --with-python-root=$BUILD_PATH/python-install --with-python-version=2.7
    21+
    22+
    # Place our own user-config in Boost.Build and set the PYTHON_INSTALL variable, delete any previous copy first, so that is can be modified when the build directory still exists
    23+
    if [ -e ${BOOSTCONFIG} ]; then
    24+
    try rm ${BOOSTCONFIG}
    25+
    fi
    26+
    try cp ${RECIPECONFIG} ${BOOSTCONFIG}
    27+
    28+
    # Replace the generated project-config with our own
    29+
    try rm $BUILD_boost/project-config.jam*
    30+
    try cp $RECIPE_boost/project-config.jam $BUILD_boost
    31+
    32+
    # Create Android case for library linking when building Boost.Python
    33+
    #FIXME: Not idempotent
    34+
    try sed -i "622i\ \ \ \ \ \ \ \ case * : return ;" tools/build/src/tools/python.jam
    35+
    }
    36+
    37+
    function build_boost() {
    38+
    cd $BUILD_boost
    39+
    40+
    # Export the Boost location to other recipes that want to know where to find Boost
    41+
    export BOOST_ROOT=$BUILD_boost
    42+
    # Export PYTHON_INSTALL as it is used in user-config
    43+
    export PYTHON_INSTALL="$BUILD_PATH/python-install"
    44+
    45+
    # Also copy libgnustl
    46+
    try cp $ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/libs/$ARCH/libgnustl_shared.so $LIBS_PATH
    47+
    48+
    pop_arm
    49+
    }
    50+
    51+
    function postbuild_boost() {
    52+
    unset BOOST_ROOT
    53+
    unset PYTHONINSTALL
    54+
    }

    recipes/boost/user-config.jam

    Lines changed: 47 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,47 @@
    1+
    import os ;
    2+
    3+
    local ANDROIDNDK = [ os.environ ANDROIDNDK ] ;
    4+
    local ANDROIDAPI = [ os.environ ANDROIDAPI ] ;
    5+
    local TOOLCHAIN_VERSION = [ os.environ TOOLCHAIN_VERSION ] ;
    6+
    local TOOLCHAIN_PREFIX = [ os.environ TOOLCHAIN_PREFIX ] ;
    7+
    local ARCH = [ os.environ ARCH ] ;
    8+
    local PYTHON_INSTALL = [ os.environ PYTHON_INSTALL ] ;
    9+
    10+
    using python : 2.7 : : : : ;
    11+
    12+
    using gcc : android
    13+
    :
    14+
    $(TOOLCHAIN_PREFIX)-g++
    15+
    :
    16+
    <archiver>$(TOOLCHAIN_PREFIX)-ar
    17+
    <compileflags>-fexceptions
    18+
    <compileflags>-frtti
    19+
    <compileflags>-fPIC
    20+
    <compileflags>-ffunction-sections
    21+
    <compileflags>-funwind-tables
    22+
    <compileflags>-Wno-psabi
    23+
    <compileflags>-mtune=xscale
    24+
    <compileflags>-Os
    25+
    <compileflags>-fomit-frame-pointer
    26+
    <compileflags>-fno-strict-aliasing
    27+
    <compileflags>-finline-limit=64
    28+
    <compileflags>-I$(ANDROIDNDK)/platforms/android-$(ANDROIDAPI)/arch-arm/usr/include
    29+
    <compileflags>-Wa,--noexecstack
    30+
    <compileflags>-DANDROID
    31+
    <compileflags>-D__ANDROID__
    32+
    <compileflags>-DNDEBUG
    33+
    <compileflags>-O2
    34+
    <compileflags>-g
    35+
    <compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include
    36+
    <compileflags>-I$(ANDROIDNDK)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(ARCH)/include
    37+
    <architecture>arm
    38+
    <compileflags>-fvisibility=hidden
    39+
    <compileflags>-fvisibility-inlines-hidden
    40+
    <compileflags>-fdata-sections
    41+
    <cxxflags>-D__arm__
    42+
    <cxxflags>-D_REENTRANT
    43+
    <cxxflags>-DBOOST_SP_USE_PTHREADS
    44+
    <cxxflags>-DBOOST_AC_USE_PTHREADS
    45+
    <cxxflags>-D_GLIBCXX__PTHREADS
    46+
    <compileflags>-I$(PYTHON_INSTALL)/include/python2.7
    47+
    ;

    recipes/cherrypy/recipe.sh

    Lines changed: 32 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,32 @@
    1+
    #!/bin/bash
    2+
    3+
    VERSION_cherrypy=3.7.0
    4+
    DEPS_cherrypy=(python)
    5+
    URL_cherrypy=https://pypi.python.org/packages/source/C/CherryPy/CherryPy-$VERSION_cherrypy.tar.gz
    6+
    MD5_cherrypy=fbf36f0b393aee2ebcbc71e3ec6f6832
    7+
    BUILD_cherrypy=$BUILD_PATH/cherrypy/$(get_directory $URL_cherrypy)
    8+
    RECIPE_cherrypy=$RECIPES_PATH/cherrypy
    9+
    10+
    function prebuild_cherrypy() {
    11+
    true
    12+
    }
    13+
    14+
    function shouldbuild_cherrypy() {
    15+
    if [ -d "$BUILD_PATH/python-install/lib/python2.7/site-packages/cherrypy" ]; then
    16+
    DO_BUILD=0
    17+
    fi
    18+
    }
    19+
    20+
    function build_cherrypy() {
    21+
    cd $BUILD_cherrypy
    22+
    23+
    push_arm
    24+
    25+
    try $HOSTPYTHON setup.py install
    26+
    27+
    pop_arm
    28+
    }
    29+
    30+
    function postbuild_cherrypy() {
    31+
    true
    32+
    }

    recipes/leveldb/recipe.sh

    Lines changed: 48 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,48 @@
    1+
    #!/bin/bash
    2+
    VERSION_leveldb=${VERSION_leveldb:-1.18}
    3+
    URL_leveldb=https://github.com/google/leveldb/archive/v${VERSION_leveldb}.tar.gz
    4+
    DEPS_leveldb=()
    5+
    BUILD_leveldb=$BUILD_PATH/leveldb/$(get_directory $URL_leveldb)
    6+
    RECIPE_leveldb=$RECIPES_PATH/leveldb
    7+
    8+
    function prebuild_leveldb() {
    9+
    cp $ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/libs/$ARCH/libgnustl_shared.so $LIBS_PATH
    10+
    }
    11+
    12+
    function shouldbuild_leveldb() {
    13+
    if [ -d "$LIBS_PATH/libleveldb.so" ]; then
    14+
    DO_BUILD=0
    15+
    fi
    16+
    }
    17+
    18+
    function build_leveldb() {
    19+
    cd $BUILD_leveldb
    20+
    21+
    push_arm
    22+
    export CFLAGS="$CFLAGS -I$ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/include/ -I$ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/libs/$ARCH/include/"
    23+
    export CFLAGS="$CFLAGS -fpic -shared"
    24+
    export CXXFLAGS=$CFLAGS
    25+
    export LDFLAGS="$LDFLAGS -L$LIBS_PATH"
    26+
    export LDFLAGS="$LDFLAGS -lgnustl_shared"
    27+
    export LDSHARED=$LIBLINK
    28+
    29+
    # Make sure leveldb is compiled for Android and does not include versioned numbers
    30+
    export TARGET_OS=OS_ANDROID_CROSSCOMPILE
    31+
    #FIXME: Not idempotent
    32+
    try sed -i "127i\ \ \ \ \ \ \ \ PLATFORM_SHARED_VERSIONED=" build_detect_platform
    33+
    34+
    # Build
    35+
    try make
    36+
    37+
    # Copy the shared library
    38+
    try cp -L libleveldb.so $LIBS_PATH
    39+
    40+
    # Unset
    41+
    unset TARGET_OS
    42+
    unset LDSHARED
    43+
    pop_arm
    44+
    }
    45+
    46+
    function postbuild_leveldb() {
    47+
    true
    48+
    }

    recipes/libtorrent/recipe.sh

    Lines changed: 42 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,42 @@
    1+
    #!/bin/bash
    2+
    # This recipe builds libtorrent-rasterbat with it's Python bindings
    3+
    # It depends on Boost.Build and the source of several Boost libraries present in BOOST_ROOT, which is all provided by the boost recipe
    4+
    VERSION_libtorrent=${VERSION_libtorrent:-1.0.5}
    5+
    DEPS_libtorrent=(boost python)
    6+
    URL_libtorrent=http://downloads.sourceforge.net/project/libtorrent/libtorrent/libtorrent-rasterbar-${VERSION_libtorrent}.tar.gz
    7+
    MD5_libtorrent=d09521d34092ba430f430572c9e2b3d3
    8+
    BUILD_libtorrent=$BUILD_PATH/libtorrent/$(get_directory $URL_libtorrent)
    9+
    RECIPE_libtorrent=$RECIPES_PATH/libtorrent
    10+
    11+
    function prebuild_libtorrent() {
    12+
    true
    13+
    }
    14+
    15+
    function shouldbuild_libtorrent() {
    16+
    if [ -f "$SITEPACKAGES_PATH/libtorrent.so" ]; then
    17+
    DO_BUILD=0
    18+
    fi
    19+
    }
    20+
    21+
    function build_libtorrent() {
    22+
    cd $BUILD_libtorrent/bindings/python
    23+
    24+
    push_arm
    25+
    26+
    # Some flags and stuff that I don't want here, but in user-config, but doesn't work otherwise
    27+
    BOOSTSTUFF="--sysroot=$ANDROIDNDK/platforms/android-$ANDROIDAPI/arch-arm -L$ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/libs/$ARCH -L$BUILD_PATH/python-install/lib -lpython2.7 -lgnustl_shared"
    28+
    29+
    # Build the Python bindings with Boost.Build and some dependencies recursively (libtorrent-rasterbar, Boost.*)
    30+
    # Also link to openssl
    31+
    # Hardcoded on -j5 because P4A does it too
    32+
    $BOOST_ROOT/b2 -q -j5 target-os=android link=static boost-link=static boost=source threading=multi toolset=gcc-android geoip=off encryption=tommath linkflags="$BOOSTSTUFF" release
    33+
    34+
    # Copy the module
    35+
    try cp -L libtorrent.so $SITEPACKAGES_PATH
    36+
    37+
    pop_arm
    38+
    }
    39+
    40+
    function postbuild_libtorrent() {
    41+
    true
    42+
    }

    recipes/netifaces/recipe.sh

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,9 +1,9 @@
    11
    #!/bin/bash
    22

    3-
    VERSION_netifaces=0.10.3
    3+
    VERSION_netifaces=0.10.4
    44
    DEPS_netifaces=(hostpython python setuptools)
    55
    URL_netifaces=http://pypi.python.org/packages/source/n/netifaces/netifaces-$VERSION_netifaces.tar.gz
    6-
    MD5_netifaces=b96913473e1dcc3c4a7c43bc15d10e26
    6+
    MD5_netifaces=36da76e2cfadd24cc7510c2c0012eb1e
    77
    BUILD_netifaces=$BUILD_PATH/netifaces/$(get_directory $URL_netifaces)
    88
    RECIPE_netifaces=$RECIPES_PATH/netifaces
    99

    recipes/openssl/recipe.sh

    Lines changed: 3 additions & 3 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,9 +1,9 @@
    11
    #!/bin/bash
    22

    3-
    VERSION_openssl=${VERSION_openssl:-1.0.1g}
    4-
    URL_openssl=http://www.openssl.org/source/openssl-$VERSION_openssl.tar.gz
    3+
    VERSION_openssl=${VERSION_openssl:-1.0.2c}
    4+
    URL_openssl=https://www.openssl.org/source/openssl-$VERSION_openssl.tar.gz
    55
    DEPS_openssl=()
    6-
    MD5_openssl=de62b43dfcd858e66a74bee1c834e959
    6+
    MD5_openssl=8c8d81a9ae7005276e486702edbcd4b6
    77
    BUILD_openssl=$BUILD_PATH/openssl/$(get_directory $URL_openssl)
    88
    RECIPE_openssl=$RECIPES_PATH/openssl
    99

    recipes/plyvel/recipe.sh

    Lines changed: 50 additions & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -0,0 +1,50 @@
    1+
    #!/bin/bash
    2+
    VERSION_plyvel=${VERSION_plyvel:-0.9}
    3+
    URL_plyvel=https://pypi.python.org/packages/source/p/plyvel/plyvel-${VERSION_plyvel}.tar.gz
    4+
    DEPS_plyvel=(python setuptools leveldb)
    5+
    MD5_plyvel=b0f768a07683dad01554b040c6320ed5
    6+
    BUILD_plyvel=$BUILD_PATH/plyvel/$(get_directory $URL_plyvel)
    7+
    RECIPE_plyvel=$RECIPES_PATH/plyvel
    8+
    9+
    function prebuild_plyvel() {
    10+
    true
    11+
    }
    12+
    13+
    function shouldbuild_plyvel() {
    14+
    if [ -d "$SITEPACKAGES_PATH/plyvel" ]; then
    15+
    DO_BUILD=0
    16+
    fi
    17+
    }
    18+
    19+
    function build_plyvel() {
    20+
    cd $BUILD_plyvel
    21+
    22+
    # Add zip_safe=False, if not already there
    23+
    grep -q -e 'zip_safe=False' setup.py || sed -i "30i\ \ \ \ zip_safe=False," setup.py
    24+
    25+
    push_arm
    26+
    27+
    # gnu-libstdc++, leveldb and python
    28+
    export CFLAGS="$CFLAGS -I$BUILD_leveldb/include"
    29+
    export CFLAGS="$CFLAGS -I$ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/include/ -I$ANDROIDNDK/sources/cxx-stl/gnu-libstdc++/$TOOLCHAIN_VERSION/libs/armeabi/include/"
    30+
    export CFLAGS="$CFLAGS -fpic -shared"
    31+
    export CXXFLAGS=$CFLAGS
    32+
    33+
    export LDFLAGS="$LDFLAGS -L$LIBS_PATH"
    34+
    export LDFLAGS="$LDFLAGS -lgnustl_shared -lpython2.7"
    35+
    export LDSHARED=$LIBLINK
    36+
    37+
    export PPO=$PYTHONPATH
    38+
    export PYTHONPATH=$SITEPACKAGES_PATH:$BUILDLIB_PATH
    39+
    40+
    try $HOSTPYTHON setup.py install -O2
    41+
    42+
    export PYTHONPATH=$PPO
    43+
    unset LDSHARED
    44+
    unset PPO
    45+
    pop_arm
    46+
    }
    47+
    48+
    function postbuild_plyvel() {
    49+
    true
    50+
    }

    0 commit comments

    Comments
     (0)
    < 1637 ghcc-consent id="ghcc" class="position-fixed bottom-0 left-0" style="z-index: 999999" data-locale="en" data-initial-cookie-consent-allowed="" data-cookie-consent-required="false" >
    0