1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/build/autoconf/python-virtualenv.m4 Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 1.4 +dnl This Source Code Form is subject to the terms of the Mozilla Public 1.5 +dnl License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +AC_DEFUN([MOZ_PYTHON], 1.9 +[ 1.10 + 1.11 +dnl We honor the Python path defined in an environment variable. This is used 1.12 +dnl to pass the virtualenv's Python from the main configure to SpiderMonkey's 1.13 +dnl configure, for example. 1.14 +if test -z "$PYTHON"; then 1.15 + MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python) 1.16 + if test -z "$PYTHON"; then 1.17 + AC_MSG_ERROR([python was not found in \$PATH]) 1.18 + fi 1.19 +else 1.20 + AC_MSG_RESULT([Using Python from environment variable \$PYTHON]) 1.21 +fi 1.22 + 1.23 +_virtualenv_topsrcdir= 1.24 +_virtualenv_populate_path= 1.25 + 1.26 +dnl If this is a mozilla-central, we'll find the virtualenv in the top 1.27 +dnl source directory. If this is a SpiderMonkey build, we assume we're at 1.28 +dnl js/src and try to find the virtualenv from the mozilla-central root. 1.29 +for base in $MOZILLA_CENTRAL_PATH $_topsrcdir $_topsrcdir/../..; do 1.30 + possible=$base/python/mozbuild/mozbuild/virtualenv.py 1.31 + 1.32 + if test -e $possible; then 1.33 + _virtualenv_topsrcdir=$base 1.34 + _virtualenv_populate_path=$possible 1.35 + break 1.36 + fi 1.37 +done 1.38 + 1.39 +if test -z $_virtualenv_populate_path; then 1.40 + AC_MSG_ERROR([Unable to find Virtualenv population script. In order 1.41 +to build, you will need mozilla-central's virtualenv. 1.42 + 1.43 +If you are building from a mozilla-central checkout, you should never see this 1.44 +message. If you are building from a source archive, the source archive was 1.45 +likely not created properly (it is missing the virtualenv files). 1.46 + 1.47 +If you have a copy of mozilla-central available, define the 1.48 +MOZILLA_CENTRAL_PATH environment variable to the top source directory of 1.49 +mozilla-central and relaunch configure.]) 1.50 + 1.51 +fi 1.52 + 1.53 +if test -z $DONT_POPULATE_VIRTUALENV; then 1.54 + AC_MSG_RESULT([Creating Python environment]) 1.55 + dnl This verifies our Python version is sane and ensures the Python 1.56 + dnl virtualenv is present and up to date. It sanitizes the environment 1.57 + dnl for us, so we don't need to clean anything out. 1.58 + $PYTHON $_virtualenv_populate_path \ 1.59 + $_virtualenv_topsrcdir $MOZ_BUILD_ROOT $MOZ_BUILD_ROOT/_virtualenv \ 1.60 + $_virtualenv_topsrcdir/build/virtualenv_packages.txt || exit 1 1.61 + 1.62 + case "$host_os" in 1.63 + mingw*) 1.64 + PYTHON=`cd $MOZ_BUILD_ROOT && pwd -W`/_virtualenv/Scripts/python.exe 1.65 + ;; 1.66 + *) 1.67 + PYTHON=$MOZ_BUILD_ROOT/_virtualenv/bin/python 1.68 + ;; 1.69 + esac 1.70 +fi 1.71 + 1.72 +AC_SUBST(PYTHON) 1.73 + 1.74 +AC_MSG_CHECKING([Python environment is Mozilla virtualenv]) 1.75 +$PYTHON -c "import mozbuild.base" 1.76 +if test "$?" != 0; then 1.77 + AC_MSG_ERROR([Python environment does not appear to be sane.]) 1.78 +fi 1.79 +AC_MSG_RESULT([yes]) 1.80 + 1.81 +PYTHON_SITE_PACKAGES=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib()"` 1.82 +if test -z "$PYTHON_SITE_PACKAGES"; then 1.83 + AC_MSG_ERROR([Could not determine python site packages directory.]) 1.84 +fi 1.85 +AC_SUBST([PYTHON_SITE_PACKAGES]) 1.86 + 1.87 +]) 1.88 +