Skip to content

Commit

Permalink
Merge branch 'issue_52' into 'master'
Browse files Browse the repository at this point in the history
fixed #52

See merge request mbernard/phonemizer!17
  • Loading branch information
Mathieu Bernard committed Aug 13, 2020
2 parents 50fe7e3 + 585c54d commit 4914254
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 24 deletions.
9 changes: 5 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ phonemizer-build:
- conda create --name phonemizer-ci python=3 2> /dev/null || true
- conda activate phonemizer-ci

# install the phonemizer
- pip install coverage
- python setup.py build
# install dependencies for testing
- pip install --upgrade pytest coverage

# install phonemizer
- python setup.py install

.phonemizer-test: &phonemizer-test
# run the unit tests within the CI environment
- conda activate phonemizer-ci
- phonemize --version
- python setup.py test
- coverage run && coverage report

phonemizer-test-espeak-1-48-04:
stage: test
Expand Down
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ before_install:

install:
- pip install --upgrade pip
- pip install pytest-cov codecov joblib segments
- python setup.py build
- python setup.py install
- pip install --upgrade pytest coverage codecov

script:
- phonemize --version
- python setup.py test
- pytest

after_success:
- coverage run
- codecov

cache:
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Version numbers follow [semantic versioning](https://semver.org)

## not yet released

* **bugfixes**

Fixed installation from source (bug introduced in 2.2.1, see
issue [#52](https://github.com/bootphon/phonemizer/issues/52).

## phonemizer-2.2.1

* **improvements**
Expand Down
18 changes: 10 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use this file to build a docker image of phonemizer (using
# festival-2.5 and espeak-ng-1.49.2 from ubuntu repo):
# festival-2.5.0 and espeak-ng-1.50 from ubuntu repo):
#
# sudo docker build -t phonemizer .
#
Expand All @@ -12,11 +12,11 @@


# Use an official Ubuntu as a parent image
FROM ubuntu:18.04
FROM ubuntu:20.04

ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

# Set the working directory to /phonemizer
# set the working directory to /phonemizer
WORKDIR /phonemizer

# install dependencies
Expand All @@ -30,15 +30,17 @@ RUN apt-get update && apt-get upgrade -y && apt-get install -y \
python3-pip && \
apt-get clean

# Pytest needs to be installed through pip to make sure we have a recent version
RUN pip3 install pytest pytest-cov
# pytest needs to be installed through pip to make sure we have a recent version
RUN pip3 install pytest

# Tests expect python to be available as executable 'python' not 'python3'
# tests expect python to be available as executable 'python' not 'python3'
RUN ln -s /usr/bin/python3 /usr/bin/python

# copy the phonemizer code within the docker image
COPY . /phonemizer

# install phonemizer and run the tests
RUN git clone https://github.com/bootphon/phonemizer.git && \
cd phonemizer && \
RUN cd /phonemizer && \
python3 setup.py install && \
phonemize --version && \
python3 -m pytest -v test
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ the phonemizer.

$ git clone https://github.com/bootphon/phonemizer
$ cd phonemizer
$ python setup.py build
$ [sudo] python setup.py install
$ python setup.py test # optionally run the tests

If you experiment an error such as `ImportError: No module named
setuptools` during installation, refeer to [issue
Expand All @@ -89,6 +87,15 @@ Then run an interactive session with:
$ sudo docker run -it phonemizer /bin/bash


### Testing

When installed from sources or whithin a Docker image, you can run the tests
suite from the root `phonemizer` folder (once you installed `pytest`):

$ pip install pytest
$ pytest


## Python usage

In Python import the `phonemize` function with `from phonemizer import
Expand Down
17 changes: 16 additions & 1 deletion phonemizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
# along with phonologizer. If not, see <http://www.gnu.org/licenses/>.
"""Multilingual text to phones converter"""

from .phonemize import phonemize

__version__ = '2.2.1'


try: # pragma: nocover
# This variable is injected in the __builtins__ by the build process. In
# that case we don't want to import phonemize as there are missing
# dependencies.
__PHONEMIZER_SETUP__
except NameError:
__PHONEMIZER_SETUP__ = False


if __PHONEMIZER_SETUP__: # pragma: nocover
import sys
sys.stderr.write('Partial import of phonemizer during the build process.\n')
else:
from .phonemize import phonemize
15 changes: 11 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
[aliases]
test=pytest

[tool:pytest]
addopts = --verbose --doctest-modules --cov=phonemizer --cov-report=html --cov-report=term:skip-covered
minversion = 5.0
testpaths = test
python_files = test/*.py
filterwarnings =
# ignore some deprecation warnings (on regexp escape sequence) for segments
# module and its dependencies
ignore::DeprecationWarning:.*segments.*
ignore::DeprecationWarning:.*csvw.*
ignore::DeprecationWarning:.*clldutils.*

[build_sphinx]
source-dir = doc/source
build-dir = doc/build

[coverage:run]
command_line = -m pytest
source = phonemizer

[coverage:report]
exclude_lines =
pragma: nocover
Expand Down
12 changes: 10 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@
# along with phonemizer. If not, see <http://www.gnu.org/licenses/>.
"""Setup script for the phonemizer package"""

import builtins
import codecs
import setuptools


# This is a bit hackish: we are setting a global variable so that the main
# phonemizer __init__ can detect if it is being loaded by the setup routine, to
# avoid attempting to load components that aren't built yet.
builtins.__PHONEMIZER_SETUP__ = True


import phonemizer


setuptools.setup(
# general description
name='phonemizer',
Expand All @@ -28,8 +38,6 @@

# python package dependancies
install_requires=['joblib', 'segments', 'attrs>=18.1'],
setup_requires=['pytest-runner'],
tests_require=['pytest', 'pytest-cov'],

# include Python code and any files in phonemizer/share
packages=setuptools.find_packages(),
Expand Down

0 comments on commit 4914254

Please sign in to comment.