Skip to content
Browse files

Bug 784841 - Part 5: Integrate virtualenv into SpiderMonkey configure…

…; r=glandium

Python and virtualenv logic is now contained within an m4 file.
SpiderMonkey now requires the mozilla-central virtualenv environment to
build. If SpiderMonkey configure is invoked by mozilla-central's
configure, the virtualenv will be reused. If SpiderMonkey configure is
invoked in isolation, it will search for the virtualenv in the
mozilla-central root.
  • Loading branch information...
1 parent 133aa74 commit 9853130319c803a24a5960ce76bf0d42f3ba77c5 @indygreg indygreg committed Jan 16, 2013
Showing with 161 additions and 40 deletions.
  1. +1 −0 aclocal.m4
  2. +77 −0 build/autoconf/python-virtualenv.m4
  3. +4 −23 configure.in
  4. +1 −0 js/src/aclocal.m4
  5. +77 −0 js/src/build/autoconf/python-virtualenv.m4
  6. +1 −17 js/src/configure.in
View
1 aclocal.m4
@@ -26,6 +26,7 @@ builtin(include, build/autoconf/arch.m4)dnl
builtin(include, build/autoconf/android.m4)dnl
builtin(include, build/autoconf/zlib.m4)dnl
builtin(include, build/autoconf/linux.m4)dnl
+builtin(include, build/autoconf/python-virtualenv.m4)dnl
MOZ_PROG_CHECKMSYS()
View
77 build/autoconf/python-virtualenv.m4
@@ -0,0 +1,77 @@
+dnl This Source Code Form is subject to the terms of the Mozilla Public
+dnl License, v. 2.0. If a copy of the MPL was not distributed with this
+dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+AC_DEFUN([MOZ_PYTHON],
+[
+
+dnl We honor the Python path defined in an environment variable. This is used
+dnl to pass the virtualenv's Python from the main configure to SpiderMonkey's
+dnl configure, for example.
+if test -z "$PYTHON"; then
+ MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python)
+ if test -z "$PYTHON"; then
+ AC_MSG_ERROR([python was not found in \$PATH])
+ fi
+else
+ AC_MSG_RESULT([Using Python from environment variable \$PYTHON])
+fi
+
+_virtualenv_topsrcdir=
+_virtualenv_populate_path=
+
+dnl If this is a mozilla-central, we'll find the virtualenv in the top
+dnl source directory. If this is a SpiderMonkey build, we assume we're at
+dnl js/src and try to find the virtualenv from the mozilla-central root.
+for base in $MOZILLA_CENTRAL_PATH $_topsrcdir $_topsrcdir/../..; do
+ possible=$base/build/virtualenv/populate_virtualenv.py
+
+ if test -e $possible; then
+ _virtualenv_topsrcdir=$base
+ _virtualenv_populate_path=$possible
+ break
+ fi
+done
+
+if test -z $_virtualenv_populate_path; then
+ AC_MSG_ERROR([Unable to find Virtualenv population script. In order
+to build, you will need mozilla-central's virtualenv.
+
+If you are building from a mozilla-central checkout, you should never see this
+message. If you are building from a source archive, the source archive was
+likely not created properly (it is missing the virtualenv files).
+
+If you have a copy of mozilla-central available, define the
+MOZILLA_CENTRAL_PATH environment variable to the top source directory of
+mozilla-central and relaunch configure.])
+
+fi
+
+if test -z $DONT_POPULATE_VIRTUALENV; then
+ AC_MSG_RESULT([Creating Python environment])
+ dnl This verifies our Python version is sane and ensures the Python
+ dnl virtualenv is present and up to date. It sanitizes the environment
+ dnl for us, so we don't need to clean anything out.
+ $PYTHON $_virtualenv_populate_path \
+ $_virtualenv_topsrcdir $MOZ_BUILD_ROOT/_virtualenv || exit 1
+
+ case "$host_os" in
+ mingw*)
+ PYTHON=`cd $MOZ_BUILD_ROOT && pwd -W`/_virtualenv/Scripts/python.exe
+ ;;
+ *)
+ PYTHON=$MOZ_BUILD_ROOT/_virtualenv/bin/python
+ ;;
+ esac
+fi
+
+AC_SUBST(PYTHON)
+
+AC_MSG_CHECKING([Python environment is Mozilla virtualenv])
+$PYTHON -c "import mozbuild.base"
+if test "$?" != 0; then
+ AC_MSG_ERROR([Python environment does not appear to be sane.])
+fi
+AC_MSG_RESULT([yes])
+])
+
View
27 configure.in
@@ -147,29 +147,7 @@ else
touch $_objdir/CLOBBER
fi
-MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python)
-if test -z "$PYTHON"; then
- AC_MSG_ERROR([python was not found in \$PATH])
-fi
-
-AC_MSG_RESULT([Creating Python environment])
-dnl This verifies our Python version is sane and ensures the Python
-dnl virtualenv is present and up to date. It sanitizes the environment
-dnl for us, so we don't need to clean anything out.
-$PYTHON $_topsrcdir/build/virtualenv/populate_virtualenv.py \
- $_topsrcdir $MOZ_BUILD_ROOT/_virtualenv || exit 1
-
-dnl Create a virtualenv where we can install local Python packages
-case "$host_os" in
-mingw*)
- PYTHON=`cd $MOZ_BUILD_ROOT && pwd -W`/_virtualenv/Scripts/python.exe
- ;;
-*)
- PYTHON=$MOZ_BUILD_ROOT/_virtualenv/bin/python
- ;;
-esac
-
-AC_SUBST(PYTHON)
+MOZ_PYTHON
MOZ_DEFAULT_COMPILER
@@ -9347,6 +9325,9 @@ export MOZ_NATIVE_ZLIB
export MOZ_ZLIB_CFLAGS
export MOZ_ZLIB_LIBS
export MOZ_APP_NAME
+export DONT_POPULATE_VIRTUALENV=1
+export PYTHON
+export MOZILLA_CENTRAL_PATH=$_topsrcdir
export STLPORT_CPPFLAGS
export STLPORT_LDFLAGS
export STLPORT_LIBS
View
1 js/src/aclocal.m4
@@ -25,5 +25,6 @@ builtin(include, build/autoconf/arch.m4)dnl
builtin(include, build/autoconf/android.m4)dnl
builtin(include, build/autoconf/zlib.m4)dnl
builtin(include, build/autoconf/linux.m4)dnl
+builtin(include, build/autoconf/python-virtualenv.m4)dnl
MOZ_PROG_CHECKMSYS()
View
77 js/src/build/autoconf/python-virtualenv.m4
@@ -0,0 +1,77 @@
+dnl This Source Code Form is subject to the terms of the Mozilla Public
+dnl License, v. 2.0. If a copy of the MPL was not distributed with this
+dnl file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+AC_DEFUN([MOZ_PYTHON],
+[
+
+dnl We honor the Python path defined in an environment variable. This is used
+dnl to pass the virtualenv's Python from the main configure to SpiderMonkey's
+dnl configure, for example.
+if test -z "$PYTHON"; then
+ MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python)
+ if test -z "$PYTHON"; then
+ AC_MSG_ERROR([python was not found in \$PATH])
+ fi
+else
+ AC_MSG_RESULT([Using Python from environment variable \$PYTHON])
+fi
+
+_virtualenv_topsrcdir=
+_virtualenv_populate_path=
+
+dnl If this is a mozilla-central, we'll find the virtualenv in the top
+dnl source directory. If this is a SpiderMonkey build, we assume we're at
+dnl js/src and try to find the virtualenv from the mozilla-central root.
+for base in $MOZILLA_CENTRAL_PATH $_topsrcdir $_topsrcdir/../..; do
+ possible=$base/build/virtualenv/populate_virtualenv.py
+
+ if test -e $possible; then
+ _virtualenv_topsrcdir=$base
+ _virtualenv_populate_path=$possible
+ break
+ fi
+done
+
+if test -z $_virtualenv_populate_path; then
+ AC_MSG_ERROR([Unable to find Virtualenv population script. In order
+to build, you will need mozilla-central's virtualenv.
+
+If you are building from a mozilla-central checkout, you should never see this
+message. If you are building from a source archive, the source archive was
+likely not created properly (it is missing the virtualenv files).
+
+If you have a copy of mozilla-central available, define the
+MOZILLA_CENTRAL_PATH environment variable to the top source directory of
+mozilla-central and relaunch configure.])
+
+fi
+
+if test -z $DONT_POPULATE_VIRTUALENV; then
+ AC_MSG_RESULT([Creating Python environment])
+ dnl This verifies our Python version is sane and ensures the Python
+ dnl virtualenv is present and up to date. It sanitizes the environment
+ dnl for us, so we don't need to clean anything out.
+ $PYTHON $_virtualenv_populate_path \
+ $_virtualenv_topsrcdir $MOZ_BUILD_ROOT/_virtualenv || exit 1
+
+ case "$host_os" in
+ mingw*)
+ PYTHON=`cd $MOZ_BUILD_ROOT && pwd -W`/_virtualenv/Scripts/python.exe
+ ;;
+ *)
+ PYTHON=$MOZ_BUILD_ROOT/_virtualenv/bin/python
+ ;;
+ esac
+fi
+
+AC_SUBST(PYTHON)
+
+AC_MSG_CHECKING([Python environment is Mozilla virtualenv])
+$PYTHON -c "import mozbuild.base"
+if test "$?" != 0; then
+ AC_MSG_ERROR([Python environment does not appear to be sane.])
+fi
+AC_MSG_RESULT([yes])
+])
+
View
18 js/src/configure.in
@@ -55,7 +55,6 @@ NSPR_VERSION=4
dnl Set the minimum version of toolkit libs used by mozilla
dnl ========================================================
PERL_VERSION=5.006
-PYTHON_VERSION=2.7
WINDRES_VERSION=2.14.90
W32API_VERSION=3.14
@@ -665,10 +664,7 @@ else
AC_MSG_RESULT([yes])
fi
-MOZ_PATH_PROGS(PYTHON, $PYTHON python2.7 python)
-if test -z "$PYTHON"; then
- AC_MSG_ERROR([python was not found in \$PATH])
-fi
+MOZ_PYTHON
if test -z "$COMPILE_ENVIRONMENT"; then
NSINSTALL_BIN='$(PYTHON) $(topsrcdir)/config/nsinstall.py'
@@ -1463,17 +1459,6 @@ case "$host" in
;;
esac
-dnl We require version 2.7 of Python to build.
-AC_MSG_CHECKING([for Python version >= $PYTHON_VERSION but not 3.x])
-changequote(,)
-$PYTHON -c "import sys; sys.exit(sys.version[:3] < sys.argv[1] or sys.version[:2] != '2.')" $PYTHON_VERSION
-_python_res=$?
-changequote([,])
-if test "$_python_res" != 0; then
- AC_MSG_ERROR([Python $PYTHON_VERSION or higher (but not Python 3.x) is required.])
-fi
-AC_MSG_RESULT([yes])
-
dnl Check for using a custom <stdint.h> implementation
dnl ========================================================
AC_MSG_CHECKING(for custom <stdint.h> implementation)
@@ -4268,7 +4253,6 @@ dnl win32 options
AC_SUBST(MOZ_MAPINFO)
AC_SUBST(MOZ_BROWSE_INFO)
AC_SUBST(MOZ_TOOLS_DIR)
-AC_SUBST(PYTHON)
dnl Echo the CFLAGS to remove extra whitespace.
CFLAGS=`echo \

0 comments on commit 9853130

Please sign in to comment.
Something went wrong with that request. Please try again.