Skip to content

Commit 82da05c

Browse files
committed
add pure-python modules support into distribute -m
1 parent 8f4d23a commit 82da05c

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

distribute.sh

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ DIST_PATH="$ROOT_PATH/dist/default"
3333
export LIBLINK_PATH="$BUILD_PATH/objects"
3434
export LIBLINK="$ROOT_PATH/src/tools/liblink"
3535
export BIGLINK="$ROOT_PATH/src/tools/biglink"
36+
export PIP="pip-2.7"
3637

3738
MD5SUM=$(which md5sum)
3839
if [ "X$MD5SUM" == "X" ]; then
@@ -381,6 +382,7 @@ function run_source_modules() {
381382

382383
needed=($MODULES)
383384
declare -a processed
385+
declare -a pymodules
384386

385387
fn_deps='.deps'
386388
fn_optional_deps='.optional-deps'
@@ -392,6 +394,7 @@ function run_source_modules() {
392394

393395
# pop module from the needed list
394396
module=${needed[0]}
397+
original_module=${needed[0]}
395398
unset needed[0]
396399
needed=( ${needed[@]} )
397400

@@ -414,8 +417,9 @@ function run_source_modules() {
414417
debug "Read $module recipe"
415418
recipe=$RECIPES_PATH/$module/recipe.sh
416419
if [ ! -f $recipe ]; then
417-
error "Recipe $module does not exist"
418-
exit -1
420+
error "Recipe $module does not exist, adding the module as pure-python package"
421+
pymodules+=($original_module)
422+
continue;
419423
fi
420424
source $RECIPES_PATH/$module/recipe.sh
421425

@@ -446,6 +450,10 @@ function run_source_modules() {
446450
MODULES="$($PYTHON tools/depsort.py --optional $fn_optional_deps < $fn_deps)"
447451

448452
info "Modules changed to $MODULES"
453+
454+
PYMODULES="${pymodules[@]}"
455+
456+
info "Pure-Python modules changed to $PYMODULES"
449457
}
450458

451459
function run_get_packages() {
@@ -589,6 +597,40 @@ function run_postbuild() {
589597
done
590598
}
591599

600+
function run_pymodules_install() {
601+
info "Run pymodules install"
602+
if [ "X$PYMODULES" == "X" ]; then
603+
debug "No pymodules to install"
604+
return
605+
fi
606+
607+
cd "$BUILD_PATH"
608+
609+
debug "We want to install: $PYMODULES"
610+
611+
debug "Check if $VIRTUALENV and $PIP are present"
612+
for tool in $VIRTUALENV $PIP; do
613+
which $tool &>/dev/null
614+
if [ $? -ne 0 ]; then
615+
error "Tool $tool is missing"
616+
exit -1
617+
fi
618+
done
619+
620+
debug "Check if virtualenv is existing"
621+
if [ ! -d venv ]; then
622+
debug "Installing virtualenv"
623+
try $VIRTUALENV --python=python2.7 venv
624+
fi
625+
626+
debug "Create a requirement file for pure-python modules"
627+
try echo "$PYMODULES" | try sed 's/\ /\n/g' > requirements.txt
628+
629+
debug "Install pure-python modules via pip in venv"
630+
try bash -c "source venv/bin/activate && env CC=/bin/false CXX=/bin/false $PIP install --target '$BUILD_PATH/python-install/lib/python2.7/site-packages' --download-cache '$PACKAGES_PATH' -r requirements.txt"
631+
632+
}
633+
592634
function run_distribute() {
593635
info "Run distribute"
594636

@@ -669,6 +711,7 @@ function run() {
669711
run_build
670712
run_biglink
671713
run_postbuild
714+
run_pymodules_install
672715
run_distribute
673716
info "All done !"
674717
}

docs/source/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@
4141

4242
# General information about the project.
4343
project = u'Python for Android'
44-
copyright = u'2012, Mathieu Virbel'
44+
copyright = u'2012/2013, Kivy organisation'
4545

4646
# The version info for the project you're documenting, acts as replacement for
4747
# |version| and |release|, also used in various other places throughout the
4848
# built documents.
4949
#
5050
# The short X.Y version.
51-
version = '1.0'
51+
version = '1.1'
5252
# The full version, including alpha/beta/rc tags.
53-
release = '1.0'
53+
release = '1.1'
5454

5555
# The language for content autogenerated by Sphinx. Refer to documentation
5656
# for a list of supported languages.

docs/source/usage.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ version. We also recommand to clean build/ before changing version.::
2727
The list of available recipes is available at:
2828
https://github.com/kivy/python-for-android/tree/master/recipes
2929

30+
From python-for-android 1.1, you can now specify pure-python package into the
31+
-m. It will use virtualenv and pip to install pure-python modules into the
32+
distribution. Please note that compiler are deactivated, and will break any
33+
module who try to compile something. If compilation is needed, write a recipe::
34+
35+
./distribute.sh -m "requests pygments kivy"
36+
3037
.. note::
3138

3239
Recipes download a defined version of their needed package from the

0 commit comments

Comments
 (0)