Skip to content

Commit

Permalink
improve installations on optional packages
Browse files Browse the repository at this point in the history
  • Loading branch information
baxtree committed Jul 12, 2021
1 parent 2caaffa commit 02b8573
Show file tree
Hide file tree
Showing 28 changed files with 240 additions and 149 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ jobs:
sudo apt-get -y install libsndfile-dev
python -m pip install --upgrade pip
cat requirements.txt | xargs -L 1 pip install
cat requirements-extra.txt | xargs -L 1 pip install
cat requirements-stretch.txt | xargs -L 1 pip install
cat requirements-translation.txt | xargs -L 1 pip install
cat requirements-dev.txt | xargs -L 1 pip install
pip install -e . --ignore-installed
- name: Linting
Expand Down
38 changes: 31 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ install:
if [ ! -e ".$(PYTHON)" ]; then ~/.pyenv/versions/$(PYTHON)/bin/python3 -m venv .$(PYTHON); fi
.$(PYTHON)/bin/pip install --upgrade pip setuptools wheel; \
cat requirements.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-extra.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-stretch.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-translation.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-dev.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
.$(PYTHON)/bin/pip install -e . --ignore-installed
cp ./bin/subaligner_1pass .$(PYTHON)/bin/subaligner_1pass
Expand All @@ -50,6 +51,24 @@ uninstall:
rm -f .$(PYTHON)/bin/subaligner_train
rm -f .$(PYTHON)/bin/subaligner_tune

install-basic:
.$(PYTHON)/bin/pip install -e '.' --no-cache-dir

install-translation:
.$(PYTHON)/bin/pip install -e '.[translation]' --no-cache-dir

install-stretch:
.$(PYTHON)/bin/pip install -e '.[stretch]' --no-cache-dir

install-dev:
.$(PYTHON)/bin/pip install -e '.[dev]' --no-cache-dir

install-docs:
.$(PYTHON)/bin/pip install -e '.[docs]' --no-cache-dir

install-harmony:
.$(PYTHON)/bin/pip install -e '.[harmony]' --no-cache-dir

build-gzip:
mkdir -p dist
tar -czf dist/subligner.tar.gz subaligner bin requirements.txt setup.py README.md LICENCE
Expand All @@ -62,7 +81,8 @@ test:
if [ ! -e ".$(PYTHON)" ]; then ~/.pyenv/versions/$(PYTHON)/bin/python3 -m venv .$(PYTHON); fi
.$(PYTHON)/bin/pip install --upgrade pip setuptools wheel; \
cat requirements.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-extra.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-stretch.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-translation.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-dev.txt | xargs -L 1 .$(PYTHON)/bin/pip install
PYTHONPATH=. .$(PYTHON)/bin/python -m unittest discover
-.$(PYTHON)/bin/pycodestyle subaligner tests examples misc bin/subaligner bin/subaligner_1pass bin/subaligner_2pass bin/subaligner_batch bin/subaligner_convert bin/subaligner_train bin/subaligner_tune setup.py --ignore=E203,E501,W503 --exclude="subaligner/lib"
Expand All @@ -74,7 +94,8 @@ test-int: ## integration test
if [ ! -e ".$(PYTHON)" ]; then ~/.pyenv/versions/$(PYTHON)/bin/python3 -m venv .$(PYTHON); fi
.$(PYTHON)/bin/pip install --upgrade pip setuptools wheel; \
cat requirements.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-extra.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-stretch.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-translation.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-dev.txt | xargs -L 1 .$(PYTHON)/bin/pip install
.$(PYTHON)/bin/pip install -e . --ignore-installed
( \
Expand All @@ -86,7 +107,8 @@ pydoc: clean-doc ## generate pydoc HTML documentation based on docstrings
if [ ! -e ".$(PYTHON)" ]; then ~/.pyenv/versions/$(PYTHON)/bin/python3 -m venv .$(PYTHON); fi
.$(PYTHON)/bin/pip install --upgrade pip setuptools wheel; \
cat requirements.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-extra.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-stretch.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-translation.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
.$(PYTHON)/bin/python -m pydoc -w subaligner; mv subaligner.html docs/index.html
.$(PYTHON)/bin/python -m pydoc -w subaligner.embedder; mv subaligner.embedder.html docs
.$(PYTHON)/bin/python -m pydoc -w subaligner.exception; mv subaligner.exception.html docs
Expand All @@ -108,7 +130,8 @@ coverage: ## check code coverage quickly with the default Python
if [ ! -e ".$(PYTHON)" ]; then ~/.pyenv/versions/$(PYTHON)/bin/python3 -m venv .$(PYTHON); fi
.$(PYTHON)/bin/pip install --upgrade pip setuptools wheel; \
cat requirements.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-extra.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-stretch.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-translation.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-dev.txt | xargs -L 1 .$(PYTHON)/bin/pip install
.$(PYTHON)/bin/coverage run --source subaligner -m unittest discover
.$(PYTHON)/bin/coverage report
Expand Down Expand Up @@ -143,7 +166,8 @@ profile:
if [ ! -e ".$(PYTHON)" ]; then ~/.pyenv/versions/$(PYTHON)/bin/python3 -m venv .$(PYTHON); fi
.$(PYTHON)/bin/pip install --upgrade pip setuptools wheel; \
cat requirements.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-extra.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-stretch.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-translation.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
cat requirements-dev.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
.$(PYTHON)/bin/python -c "import misc.profiler; misc.profiler.generate_profiles()"
.$(PYTHON)/bin/kernprof -v -l ./misc/profiler.py
Expand All @@ -152,7 +176,7 @@ app: clean-wheels
if [ ! -e ".$(PYTHON)" ]; then ~/.pyenv/versions/$(PYTHON)/bin/python3 -m venv .$(PYTHON); fi
.$(PYTHON)/bin/pip install --upgrade pip setuptools wheel; \
cat requirements-dev.txt | xargs -L 1 .$(PYTHON)/bin/pip install; \
.$(PYTHON)/bin/pip wheel --no-cache-dir --wheel-dir=./wheels -r requirements.txt -r requirements-extra.txt; \
.$(PYTHON)/bin/pip wheel --no-cache-dir --wheel-dir=./wheels -r requirements.txt -r requirements-stretch.txt -r requirements-translation.txt; \
STRETCH_OFF=True .$(PYTHON)/bin/python setup.py bdist_wheel -d ./wheels; \
.$(PYTHON)/bin/pex subaligner==$(SUBALIGNER_VERSION) --repo=./wheels --platform $(PLATFORM) --no-pypi --no-build --python-shebang="/usr/bin/env python3" -e subaligner -o subaligner-$(PLATFORM).app; \

Expand Down
58 changes: 37 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,62 @@
</div>

## Dependencies
[FFmpeg](https://www.ffmpeg.org/) and [eSpeak](http://espeak.sourceforge.net/index.html)
Required by basic: [FFmpeg](https://www.ffmpeg.org/)
```
$ apt-get install ffmpeg espeak libespeak1 libespeak-dev espeak-data
$ apt-get install ffmpeg
```
or
```
$ brew install ffmpeg espeak
$ brew install ffmpeg
```

## Installation
## Basic Installation
```
# Install from PyPI
$ pip install -U pip
$ pip install subaligner
```

## Installation with Optional Packages Supporting Additional Features
```
# Install dependencies for enabling translation
$ pip install 'subaligner[translation]'
```
```
# Install dependencies for enabling forced alignment
$ pip install 'subaligner[stretch]'
```
```
# Install dependencies for enabling the development environment
$ pip install 'subaligner[dev]'
```
Note that both `subaligner[stretch]` and `subaligner[dev]` require additional dependencies to be installed:
```
$ apt-get install espeak libespeak1 libespeak-dev espeak-data
```
or
```
$ brew install espeak
```
To install all supported features:
```
$ pip install 'subaligner[harmony]'
```

## Alternative Installations
```
# Install via pipx
$ pip install -U pip pipx
$ pipx install subaligner
```
or
```
# Install from GitHub via Pipenv
...
[packages]
subaligner = {git = "ssh://[email protected]/baxtree/subaligner.git", ref = "<TAG>"}
...
$ pipenv install subaligner
$ pipenv install 'subaligner[stretch]'
$ pipenv install 'subaligner[dev]'
```
or
```
Expand All @@ -49,18 +77,6 @@ $ python setup.py install
```
or
```
# Install dependencies for enabling extra features
$ pip install subaligner[extra]
```
or
```
# Install dependencies for enabling the development environment
$ pip install subaligner[dev]
```
or
```
# Use dockerised installation
$ docker run -v `pwd`:`pwd` -w `pwd` -it baxtree/subaligner bash
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile-ArchLinux
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ RUN ["/bin/bash", "-c", "pacman --noconfirm -Sy gcc ffmpeg espeak &&\
pacman --noconfirm -Syu python python-pip &&\
ln -s /usr/lib/libffi.so.7 /usr/lib/libffi.so.6 &&\
python -m pip install wheel &&\
python -m pip install subaligner[extra]==${RELEASE_VERSION:1}"]
python -m pip install 'subaligner[harmony]==${RELEASE_VERSION:1}'"]
2 changes: 1 addition & 1 deletion docker/Dockerfile-CentOS7
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ RUN ["/bin/bash", "-c", "yum update -y &&\
yum install -y python36-setuptools &&\
easy_install-3.6 pip &&\
pip install --upgrade pip &&\
python3 -m pip install subaligner[extra]==${RELEASE_VERSION:1}"]
python3 -m pip install 'subaligner[harmony]==${RELEASE_VERSION:1}'"]
2 changes: 1 addition & 1 deletion docker/Dockerfile-CentOS8
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ RUN ["/bin/bash", "-c", "dnf install -y epel-release dnf-utils &&\
dnf install -y python3-devel &&\
dnf install -y python3-pip &&\
pip3 install --upgrade pip &&\
python3 -m pip install subaligner[extra]==${RELEASE_VERSION:1}"]
python3 -m pip install 'subaligner[harmony]==${RELEASE_VERSION:1}'"]
2 changes: 1 addition & 1 deletion docker/Dockerfile-Debian10
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ RUN ["/bin/bash", "-c", "apt-get -y update &&\
apt-get -y install python3-tk &&\
apt-get -y install python3-pip &&\
python3 -m pip install --upgrade pip &&\
python3 -m pip install subaligner[extra]==${RELEASE_VERSION:1}"]
python3 -m pip install 'subaligner[harmony]==${RELEASE_VERSION:1}'"]
2 changes: 1 addition & 1 deletion docker/Dockerfile-Fedora31
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ RUN ["/bin/bash", "-c", "dnf install -y dnf-utils &&\
dnf install -y python3-devel &&\
dnf install -y python3-pip &&\
pip3 install --upgrade pip &&\
python3 -m pip install subaligner[extra]==${RELEASE_VERSION:1}"]
python3 -m pip install 'subaligner[harmony]==${RELEASE_VERSION:1}'"]
2 changes: 1 addition & 1 deletion docker/Dockerfile-Ubuntu18
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ RUN ["/bin/bash", "-c", "apt-get -y update &&\
apt-get -y install python3-tk &&\
apt-get -y install python3-pip &&\
python3 -m pip install --upgrade pip &&\
python3 -m pip install subaligner[extra]==${RELEASE_VERSION:1}"]
python3 -m pip install 'subaligner[harmony]==${RELEASE_VERSION:1}'"]
2 changes: 1 addition & 1 deletion docker/Dockerfile-Ubuntu20
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ RUN ["/bin/bash", "-c", "apt-get -y update &&\
apt-get -y install python3-tk &&\
apt-get -y install python3-pip &&\
python3 -m pip install --upgrade pip &&\
python3 -m pip install subaligner[extra]==${RELEASE_VERSION:1}"]
python3 -m pip install 'subaligner[harmony]==${RELEASE_VERSION:1}'"]
2 changes: 1 addition & 1 deletion misc/profiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def kernprof_target():
output_dir = os.path.join(examples_dir, "tmp")
os.makedirs(output_dir, exist_ok=True)
video_file_path = os.path.join(examples_dir, "..", "video.mp4")
srt_file_path = os.path.join(examples_dir, "..", "subtitle.srt")
srt_file_path = os.path.join(examples_dir, "..", "video.srt")

predictor = Predictor()
predictor.predict_dual_pass(video_file_path, srt_file_path)
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions requirements-translation.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pycountry~=20.7.3
sentencepiece~=0.1.95
six~=1.15.0
torch~=1.8.1
transformers~=4.5.1
5 changes: 0 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ psutil==5.6.7
py==1.10.0
pyasn1==0.4.8
pyasn1-modules==0.2.7
pycountry~=20.7.3
pydot==1.2.4
pydot-ng==1.0.0
pydotplus==2.0.2
Expand All @@ -60,17 +59,13 @@ requests-oauthlib==1.3.0
rsa==4.7
scipy~=1.5.4
scikit-learn>=0.19.1
sentencepiece~=0.1.95
setuptools>=41.0.0
six~=1.15.0
tblib==1.3.2
tensorflow>=1.15.5,<2.6
termcolor==1.1.0
toml==0.10.0
toolz==0.9.0
torch~=1.8.1
tornado==5.1.0
transformers~=4.5.1
typing-extensions~=3.7.0
urllib3~=1.26.5
Werkzeug>=0.15.3
Expand Down
13 changes: 9 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@
with open("requirements.txt") as requirements_file:
requirements = requirements_file.read().splitlines()[::-1]

with open("requirements-extra.txt") as extra_requirements_file:
extra_requirements = extra_requirements_file.read().splitlines()[::-1]
with open("requirements-stretch.txt") as stretch_requirements_file:
stretch_requirements = stretch_requirements_file.read().splitlines()[::-1]

with open("requirements-site.txt") as docs_requirements_file:
docs_requirements = docs_requirements_file.read().splitlines()[::-1]

with open("requirements-translation.txt") as translate_requirements_file:
translate_requirements = translate_requirements_file.read().splitlines()[::-1]

with open("requirements-dev.txt") as dev_requirements_file:
dev_requirements = dev_requirements_file.read().splitlines()[::-1]

EXTRA_DEPENDENCIES = {
"extra": extra_requirements,
"harmony": stretch_requirements + translate_requirements,
"dev": dev_requirements + stretch_requirements + translate_requirements + docs_requirements,
"docs": docs_requirements,
"dev": extra_requirements + dev_requirements,
"stretch": stretch_requirements,
"translation": translate_requirements,
}

setup(name="subaligner",
Expand Down
42 changes: 29 additions & 13 deletions site/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ Installation
**Install necessary dependencies**::

$ apt-get install ffmpeg
$ apt-get install espeak libespeak1 libespeak-dev espeak-data

**or**::

$ brew install ffmpeg espeak
$ brew install ffmpeg

§ You may also need to install `HomeBrew <https://brew.sh/>`_.

Expand All @@ -18,24 +17,41 @@ Installation
$ pip install -U pip
$ pip install subaligner

**Install Subaligner via pipx**::
**Install dependencies for enabling translation**::

$ pip install -U pip pipx
$ pipx install subaligner
$ pip install 'subaligner[translation]'

**Install from GitHub via Pipenv**::
**Install additional required dependencies before installing subaligner[stretch] or subaligner[dev]**::

...
[packages]
subaligner = {git = "ssh://[email protected]/baxtree/subaligner.git", ref = "<TAG>"}
...
$ apt-get install espeak libespeak1 libespeak-dev espeak-data

**Install dependencies for enabling extra features::
**or**::

$ brew install espeak

$ pip install subaligner[extra]
**Install dependencies for enabling forced alignment**::

$ pip install 'subaligner[stretch]'

**Install dependencies for enabling the development environment**::
$ pip install subaligner[dev]

$ pip install 'subaligner[dev]'

**Install all supported features**::

$ pip install 'subaligner[harmony]'

**Install Subaligner via pipx**::

$ pipx install subaligner
$ pipx install 'subaligner[stretch]'
$ pipx install 'subaligner[dev]'

**Install from GitHub via Pipenv**::

$ pipenv install subaligner
$ pipenv install 'subaligner[stretch]'
$ pipenv install 'subaligner[dev]'

**Use dockerised installation**::

Expand Down
7 changes: 4 additions & 3 deletions site/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ Make sure you have got the virtual environment activated upfront.
$ python -m subaligner.subaligner_1pass -v video.mp4 -s subtitle.srt
$ python -m subaligner.subaligner_2pass -v video.mp4 -s subtitle.srt

Currently the stretching is experimental and make sure subaligner[extra] is installed before switching it on as shown below.
Currently the stretching is experimental and make sure subaligner[stretch] is installed before switching it on with `-so`
or `--stretch_on` as shown below.

**Use flag "-so" to switch on stretching when aligning subtitles**::
**Switch on stretching when aligning subtitles**::

(.venv) $ subaligner_2pass -v video.mp4 -s subtitle.srt -so
or
(.venv) $ subaligner -m dual -v video.mp4 -s subtitle.srt -so

**Use flag "-o" to save the aligned subtitle to a specific location**::
**Save the aligned subtitle to a specific location**::

(.venv) $ subaligner_2pass -v video.mp4 -s subtitle.srt -o /path/to/the/output/subtitle.srt
or
Expand Down
Loading

0 comments on commit 02b8573

Please sign in to comment.