-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added venvs scripts. Removed speect example from tests. Better docs.
- Loading branch information
Alberto Pettarin
committed
Nov 23, 2016
1 parent
1983b37
commit 7351894
Showing
8 changed files
with
337 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ bak | |
build | ||
dist | ||
docs/build | ||
venvs | ||
tmp | ||
|
||
# service scripts | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ignore any actual venv | ||
venv_* | ||
zzz_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.