Skip to content

Commit

Permalink
Added venvs scripts. Removed speect example from tests. Better docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto Pettarin committed Nov 23, 2016
1 parent 1983b37 commit 7351894
Show file tree
Hide file tree
Showing 8 changed files with 337 additions and 29 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ bak
build
dist
docs/build
venvs
tmp

# service scripts
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ aeneas
synchronize audio and text (aka forced alignment).

- Version: 1.7.0
- Date: 2016-11-??
- Date: 2016-12-??
- Developed by: `ReadBeyond <http://www.readbeyond.it/>`__
- Lead Developer: `Alberto Pettarin <http://www.albertopettarin.it/>`__
- License: the GNU Affero General Public License Version 3 (AGPL v3)
Expand Down
17 changes: 9 additions & 8 deletions aeneas/tests/tool_test_execute_task_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ def test_example_ctw_espeak(self):
("", "--example-ctw-espeak")
], 0)

def test_example_ctw_speect(self):
# unable to run speect with Python 3,
# perform the test only on Python 2
if gf.PY2:
self.execute([
("", "--example-ctw-speect")
], 0)

def test_example_eaf(self):
self.execute([
("", "--example-eaf")
Expand Down Expand Up @@ -223,6 +215,15 @@ def zzz_test_example_youtube(self):
("", "--example-youtube")
], 0)

# NOTE disabling this one as it requires speect
def zzz_test_example_ctw_speect(self):
# unable to run speect with Python 3,
# perform the test only on Python 2
if gf.PY2:
self.execute([
("", "--example-ctw-speect")
], 0)


if __name__ == "__main__":
unittest.main()
3 changes: 3 additions & 0 deletions venvs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ignore any actual venv
venv_*
zzz_*
73 changes: 73 additions & 0 deletions venvs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Virtual Environments

This directory contains Bash scripts automating the creation
of virtual environments ("venv"s) using ``virtualenv``
for testing purposes.


## Requirements

1. The OS requirements of ``aeneas`` (``espeak``, ``ffmpeg``, etc.)
2. ``virtualenv``, version 15.0.3 or later
3. Your choice of Python interpreters, available on the command line (e.g., ``python2.7``, ``python3.5``, ``pypy``, etc.)

## Usage

In the examples, ``python3.5`` is assumed to be the target interpreter.

### Uninstall existing venv

```bash
$ bash manage_venvs.sh python3.5 uninstall
```

### Install new venv

```bash
$ bash manage_venvs.sh python3.5 install
```

### Install Python dependencies inside the venv

```bash
$ bash manage_venvs.sh python3.5 deps
```

Note: the above will perform a ``pip install -U ...`` (upgrade).

### Install new version of aeneas from sdist tar.gz

```bash
$ bash manage_venvs.sh python3.5 install
$ cd venv_python3.5
$ source bin/activate
$ bash install_aeneas_from_sdist_tar_gz.sh
$ deactivate
```

This procedure will:

1. create the venv, if not already existing
2. activate the venv
3. uninstall ``aeneas``, if already installed
4. copy the tar.gz and install it
5. perform a couple of quick tests
6. deactivate the venv

Note: specify ``bash install_aeneas_from_sdist_tar_gz.sh --remove``
to just uninstall ``aeneas`` from the venv and exit.

### Install aeneas for full (local) testing

```bash
$ bash manage_venvs.sh python3.5 install
$ bash manage_venvs.sh python3.5 deps
$ bash manage_venvs.sh python3.5 tests
$ cd venv_python3.5
$ source bin/activate
$ cd tests
$ python run_all_unit_tests.py
$ cd ../..
$ deactivate
```

79 changes: 79 additions & 0 deletions venvs/install_aeneas_from_sdist_tar_gz.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

# __author__ = "Alberto Pettarin"
# __copyright__ = """
# Copyright 2012-2013, Alberto Pettarin (www.albertopettarin.it)
# Copyright 2013-2015, ReadBeyond Srl (www.readbeyond.it)
# Copyright 2015-2016, Alberto Pettarin (www.albertopettarin.it)
# """
# __license__ = "GNU AGPL 3"
# __version__ = "1.7.0"
# __email__ = "aeneas@readbeyond.it"
# __status__ = "Production"

# check that the sdist is in place
if [ ! -e ../../dist/aeneas*.tar.gz ]
then
echo "[ERRO] No .tar.gz found in the dist/ directory, aborting!"
exit 1
fi

# check that we are running in a venv
python -c 'import sys; sys.exit(0) if hasattr(sys, "real_prefix") else sys.exit(1)'
if [ "$?" -eq 1 ]
then
echo "[ERRO] This script should be run in a venv only!"
echo "[INFO] Try:"
echo "[INFO] $ source bin/activate"
echo ""
exit 1
fi
echo ""

echo "[INFO] Uninstalling..."
rm -f aeneas*.tar.gz
rm -rf output
mkdir output
pip uninstall aeneas -y
echo "[INFO] Uninstalling... done"
echo ""

if [ "$#" -ge 1 ]
then
echo "[INFO] Quitting before installing aeneas."
echo ""
exit 0
fi

echo "[INFO] Installing..."
cp ../../dist/aeneas*.tar.gz .
pip install numpy
pip install aeneas*.tar.gz
rm aeneas*.tar.gz
echo "[INFO] Installing... done"
echo ""

echo "[INFO] Diagnostics..."
python -m aeneas.diagnostics
echo "[INFO] Diagnostics... done"
echo ""

echo "[INFO] Running some examples..."
echo ""
python -m aeneas.tools.execute_task --example-smil
echo ""
python -m aeneas.tools.execute_task --example-json
echo ""
python -m aeneas.tools.execute_task --example-festival
echo ""
python -m aeneas.tools.execute_task --example-ctw-espeak
echo ""
python -m aeneas.tools.execute_task --example-textgrid
echo ""
echo "[INFO] Running some examples... done"
echo ""

echo "[INFO] Testing CFW..."
python -c 'import aeneas.globalfunctions as gf; print(gf.can_run_c_extension("cfw"))'
echo "[INFO] Testing CFW... done"

147 changes: 147 additions & 0 deletions venvs/manage_venvs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#!/bin/bash

# __author__ = "Alberto Pettarin"
# __copyright__ = """
# Copyright 2012-2013, Alberto Pettarin (www.albertopettarin.it)
# Copyright 2013-2015, ReadBeyond Srl (www.readbeyond.it)
# Copyright 2015-2016, Alberto Pettarin (www.albertopettarin.it)
# """
# __license__ = "GNU AGPL 3"
# __version__ = "1.7.0"
# __email__ = "aeneas@readbeyond.it"
# __status__ = "Production"

usage() {
echo ""
echo "Usage: bash $0 [python2.7|python3.4|python3.5|pypy] [uninstall|install|deps|tests|full]"
echo ""
}

uninstall() {
echo "[INFO] Removing venv $1 ..."
rm -rf "$1"
echo "[INFO] Removing venv $1 ... done"
}

create() {
if [ -e "$1" ]
then
echo "[INFO] venv $1 already exists."
echo "[INFO] Use 'uninstall' to remove it before reinstalling it."
else
echo "[INFO] Creating venv $1 ..."
# create virtualenv
virtualenv -p "$2" "$1"
# create symlink for testing sdist tar.gz
cd $1
ln -s "../install_aeneas_from_sdist_tar_gz.sh" "install_aeneas_from_sdist_tar_gz.sh"
cd ..
echo "[INFO] Creating venv $1 ... done"
fi
}

deps() {
if [ ! -e "$1" ]
then
echo "[INFO] venv $1 does not exist."
echo "[INFO] Use 'install' or 'full' to create it."
else
echo "[INFO] Installing Python dependencies in $1 ..."
cd $1
source bin/activate
pip install -U pip
pip install -U numpy
pip install -U lxml BeautifulSoup4
pip install -U pafy requests tgt youtube-dl
# NOTE Pillow might cause errors with pypy: try installing it as last
pip install -U Pillow
deactivate
cd ..
echo "[INFO] Installing Python dependencies in $1 ... done"
fi
}

copytests() {
if [ ! -e "$1" ]
then
echo "[INFO] venv $1 does not exist."
echo "[INFO] Use 'install' or 'full' to create it."
else
echo "[INFO] Copying tests in $1 ..."
cd $1
source bin/activate

# delete old stuff, if any
rm -rf tests
mkdir tests

# copy current code locally and set it up
cp -r ../../aeneas ../../*.py tests/
cd tests
pip install numpy
python setup.py build_ext --inplace
cd ..

deactivate
cd ..
echo "[INFO] Copying tests in $1 ... done"
fi
}


# check that we have at least two arguments,
# otherwise show usage and exit
if [ "$#" -lt 2 ]
then
usage
exit 1
fi

# get arguments
EX=$1
ACTION=$2

# venv directory name
D="venv_$EX"

# check the full path of the executable
FULLEX=`which $EX`
if [ "$FULLEX" == "" ]
then
echo "[ERRO] Unable to find the full path of executable $EX, aborting."
exit 1
fi

# check the action argument
if [ "$ACTION" != "uninstall" ] && [ "$ACTION" != "install" ] && [ "$ACTION" != "deps" ] && [ "$ACTION" != "tests" ] && [ "$ACTION" != "full" ]
then
usage
exit 1
fi

if [ "$ACTION" == "uninstall" ]
then
uninstall $D
fi

if [ "$ACTION" == "install" ]
then
create $D $FULLEX
fi

if [ "$ACTION" == "deps" ]
then
deps $D
fi

if [ "$ACTION" == "tests" ]
then
copytests $D
fi

if [ "$ACTION" == "full" ]
then
create $D $FULLEX
deps $D
copytests $D
fi
Loading

0 comments on commit 7351894

Please sign in to comment.