|
1 dnl This Source Code Form is subject to the terms of the Mozilla Public |
|
2 dnl License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. |
|
4 |
|
5 AC_DEFUN([MOZ_PYTHON], |
|
6 [ |
|
7 |
|
8 dnl We honor the Python path defined in an environment variable. This is used |
|
9 dnl to pass the virtualenv's Python from the main configure to SpiderMonkey's |
|
10 dnl configure, for example. |
|
11 if test -z "$PYTHON"; then |
|
12 MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python) |
|
13 if test -z "$PYTHON"; then |
|
14 AC_MSG_ERROR([python was not found in \$PATH]) |
|
15 fi |
|
16 else |
|
17 AC_MSG_RESULT([Using Python from environment variable \$PYTHON]) |
|
18 fi |
|
19 |
|
20 _virtualenv_topsrcdir= |
|
21 _virtualenv_populate_path= |
|
22 |
|
23 dnl If this is a mozilla-central, we'll find the virtualenv in the top |
|
24 dnl source directory. If this is a SpiderMonkey build, we assume we're at |
|
25 dnl js/src and try to find the virtualenv from the mozilla-central root. |
|
26 for base in $MOZILLA_CENTRAL_PATH $_topsrcdir $_topsrcdir/../..; do |
|
27 possible=$base/python/mozbuild/mozbuild/virtualenv.py |
|
28 |
|
29 if test -e $possible; then |
|
30 _virtualenv_topsrcdir=$base |
|
31 _virtualenv_populate_path=$possible |
|
32 break |
|
33 fi |
|
34 done |
|
35 |
|
36 if test -z $_virtualenv_populate_path; then |
|
37 AC_MSG_ERROR([Unable to find Virtualenv population script. In order |
|
38 to build, you will need mozilla-central's virtualenv. |
|
39 |
|
40 If you are building from a mozilla-central checkout, you should never see this |
|
41 message. If you are building from a source archive, the source archive was |
|
42 likely not created properly (it is missing the virtualenv files). |
|
43 |
|
44 If you have a copy of mozilla-central available, define the |
|
45 MOZILLA_CENTRAL_PATH environment variable to the top source directory of |
|
46 mozilla-central and relaunch configure.]) |
|
47 |
|
48 fi |
|
49 |
|
50 if test -z $DONT_POPULATE_VIRTUALENV; then |
|
51 AC_MSG_RESULT([Creating Python environment]) |
|
52 dnl This verifies our Python version is sane and ensures the Python |
|
53 dnl virtualenv is present and up to date. It sanitizes the environment |
|
54 dnl for us, so we don't need to clean anything out. |
|
55 $PYTHON $_virtualenv_populate_path \ |
|
56 $_virtualenv_topsrcdir $MOZ_BUILD_ROOT $MOZ_BUILD_ROOT/_virtualenv \ |
|
57 $_virtualenv_topsrcdir/build/virtualenv_packages.txt || exit 1 |
|
58 |
|
59 case "$host_os" in |
|
60 mingw*) |
|
61 PYTHON=`cd $MOZ_BUILD_ROOT && pwd -W`/_virtualenv/Scripts/python.exe |
|
62 ;; |
|
63 *) |
|
64 PYTHON=$MOZ_BUILD_ROOT/_virtualenv/bin/python |
|
65 ;; |
|
66 esac |
|
67 fi |
|
68 |
|
69 AC_SUBST(PYTHON) |
|
70 |
|
71 AC_MSG_CHECKING([Python environment is Mozilla virtualenv]) |
|
72 $PYTHON -c "import mozbuild.base" |
|
73 if test "$?" != 0; then |
|
74 AC_MSG_ERROR([Python environment does not appear to be sane.]) |
|
75 fi |
|
76 AC_MSG_RESULT([yes]) |
|
77 |
|
78 PYTHON_SITE_PACKAGES=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib()"` |
|
79 if test -z "$PYTHON_SITE_PACKAGES"; then |
|
80 AC_MSG_ERROR([Could not determine python site packages directory.]) |
|
81 fi |
|
82 AC_SUBST([PYTHON_SITE_PACKAGES]) |
|
83 |
|
84 ]) |
|
85 |