123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- #! /bin/sh
- required='cc python virtualenv'
- . test-init.sh
- CONFIG_SITE=/dev/null; export CONFIG_SITE
- py_version_pre=$($PYTHON -V)
- virtualenv -p"$PYTHON" --verbose virtenv && py_installed virtenv/bin/activate \
- || skip_ "couldn't create python virtual environment"
- . ./virtenv/bin/activate
- if test -z "$VIRTUAL_ENV"; then
- framework_failure_ "can't activate python virtual environment"
- fi
- py_version_post=$(python -V)
- test "$py_version_pre" = "$py_version_post"
- cwd=$(pwd) || fatal_ "getting current working directory"
- py_version=$(python -c 'import sys; print("%u.%u" % tuple(sys.version_info[:2]))')
- py_site=$VIRTUAL_ENV/lib/python$py_version/site-packages
- if python_has_pep3147; then
- : PEP 3147 will be used in installation of ".pyc" files
- fi
- unset PYTHON
- cat > configure.ac << END
- AC_INIT([am_virtenv], [1.0])
- AM_INIT_AUTOMAKE
- AC_CONFIG_FILES([Makefile])
- AC_PROG_CC
- AM_PROG_AR
- AC_PROG_RANLIB
- AM_PATH_PYTHON
- AC_OUTPUT
- END
- cat > Makefile.am << 'END'
- python_PYTHON = am_foo.py
- pkgpython_PYTHON = __init__.py
- pyexec_LIBRARIES = libquux.a
- libquux_a_SOURCES = foo.c
- pkgpyexec_LIBRARIES = libzardoz.a
- libzardoz_a_SOURCES = foo.c
- .PYTHON: debug test-run
- debug:
- @echo PYTHON: $(PYTHON)
- @echo PYTHON_VERSION: $(PYTHON_VERSION)
- @echo prefix: $(prefix)
- @echo pythondir: $(pythondir)
- @echo pkgpythondir: $(pkgpythondir)
- @echo pyexecdir: $(pyexecdir)
- @echo pkgpyexecdir: $(pkgpyexecdir)
- test-run:
-
-
- @: \
- && py1=`python -c 'import sys; print(sys.executable)'` \
- && py2=`$(PYTHON) -c 'import sys; print(sys.executable)'` \
- && echo "py1: $$py1" \
- && echo "py2: $$py2" \
- && test -n "$$py1" \
- && test -n "$$py2" \
- && test x"$$py1" = x"$$py2"
-
-
- python -c 'from am_foo import foo_func; assert (foo_func () == 12345)'
- python -c 'from am_virtenv import old_am; assert (old_am () == "AutoMake")'
- all-local: debug
- END
- cat > am_foo.py << 'END'
- def foo_func ():
- return 12345
- END
- cat > __init__.py << 'END'
- def old_am ():
- return 'AutoMake'
- END
- cat > foo.c << 'END'
- int foo (void)
- {
- return 0;
- }
- END
- check_install ()
- {
- $MAKE install ${1+"$@"}
- test -f "$py_site"/am_foo.py
- py_installed "$py_site"/am_foo.pyc
- py_installed "$py_site"/am_foo.pyo
- py_installed "$py_site"/am_virtenv/__init__.py
- py_installed "$py_site"/am_virtenv/__init__.pyc
- py_installed "$py_site"/am_virtenv/__init__.pyo
- test -f "$py_site"/libquux.a
- test -f "$py_site"/am_virtenv/libzardoz.a
- }
- check_uninstall ()
- {
- $MAKE uninstall ${1+"$@"}
- test ! -e "$py_site"/am_foo.py
- py_installed --not "$py_site"/am_foo.pyc
- py_installed --not "$py_site"/am_foo.pyo
- test ! -e "$py_site"/am_virtenv/__init__.py
- py_installed --not "$py_site"/am_virtenv/__init__.pyc
- py_installed --not "$py_site"/am_virtenv/__init__.pyo
- test ! -e "$py_site"/libquux.a
- test ! -e "$py_site"/am_virtenv/libzardoz.a
- }
- $ACLOCAL
- $AUTOCONF
- $AUTOMAKE --add-missing
- mkdir build
- cd build
- ../configure --prefix="$VIRTUAL_ENV"
- check_install
- $MAKE test-run
- check_uninstall
- cd ..
- ./configure --prefix="$VIRTUAL_ENV"
- check_install
- $MAKE test-run
- check_uninstall
- $MAKE distclean
- ./configure am_cv_python_pythondir="$py_site" \
- am_cv_python_pyexecdir="$py_site"
- check_install
- $MAKE test-run
- check_uninstall
- $MAKE distclean
- ./configure --prefix="$cwd/bad-prefix"
- check_install pythondir="$py_site" pyexecdir="$py_site" \
- AM_MAKEFLAGS="pythondir='$py_site' pyexecdir='$py_site'"
- test ! -e bad-prefix
- $MAKE test-run
- check_uninstall pythondir="$py_site" pyexecdir="$py_site" \
- AM_MAKEFLAGS="pythondir='$py_site' pyexecdir='$py_site'"
- $MAKE distcheck
- cd build
- $MAKE install
- python -c 'import am_foo; print(am_foo.__file__)'
- python -c 'import am_virtenv; print(am_virtenv.__file__)'
- deactivate "nondestructive"
- python -c 'import am_foo' && exit 1
- python -c 'import am_virtenv' && exit 1
- :
|