TTS/setup.py

151 lines
5.0 KiB
Python
Raw Normal View History

2018-06-21 13:48:13 +00:00
#!/usr/bin/env python
2019-11-27 15:40:32 +00:00
import argparse
import os
import shutil
import subprocess
import sys
2021-01-26 01:57:50 +00:00
import numpy
2018-06-21 13:48:13 +00:00
import setuptools.command.build_py
2021-01-26 01:57:50 +00:00
import setuptools.command.develop
2019-11-27 15:40:32 +00:00
2021-01-26 01:57:50 +00:00
from setuptools import find_packages, setup
from distutils.extension import Extension
from Cython.Build import cythonize
2019-11-27 15:40:32 +00:00
2021-01-26 01:57:50 +00:00
# parameters for wheeling server.
parser = argparse.ArgumentParser(add_help=False, allow_abbrev=False)
2020-09-22 01:54:16 +00:00
parser.add_argument('--checkpoint',
type=str,
help='Path to checkpoint file to embed in wheel.')
parser.add_argument('--model_config',
type=str,
help='Path to model configuration file to embed in wheel.')
2019-11-27 15:40:32 +00:00
args, unknown_args = parser.parse_known_args()
# Remove our arguments from argv so that setuptools doesn't see them
sys.argv = [sys.argv[0]] + unknown_args
2018-06-21 13:48:13 +00:00
version = '0.0.9.2'
2018-06-21 13:48:13 +00:00
cwd = os.path.dirname(os.path.abspath(__file__))
2020-08-04 15:44:26 +00:00
# Handle Cython code
2021-01-26 01:57:50 +00:00
# def find_pyx(path='.'):
# pyx_files = []
# for root, _, filenames in os.walk(path):
# for fname in filenames:
# if fname.endswith('.pyx'):
# pyx_files.append(os.path.join(root, fname))
# return pyx_files
2020-08-04 15:44:26 +00:00
2021-01-26 01:57:50 +00:00
# def find_cython_extensions(path="."):
# exts = cythonize(find_pyx(path), language_level=3)
# for ext in exts:
# ext.include_dirs = [numpy.get_include()]
2021-01-26 11:07:18 +00:00
2021-01-26 01:57:50 +00:00
# return exts
2020-08-04 12:07:47 +00:00
class build_py(setuptools.command.build_py.build_py): # pylint: disable=too-many-ancestors
2018-06-21 13:48:13 +00:00
def run(self):
self.create_version_file()
setuptools.command.build_py.build_py.run(self)
@staticmethod
def create_version_file():
print('-- Building version ' + version)
version_path = os.path.join(cwd, 'version.py')
with open(version_path, 'w') as f:
f.write("__version__ = '{}'\n".format(version))
class develop(setuptools.command.develop.develop):
def run(self):
build_py.create_version_file()
setuptools.command.develop.develop.run(self)
# The documentation for this feature is in server/README.md
2020-09-09 10:27:23 +00:00
package_data = ['TTS/server/templates/*']
2018-06-21 13:48:13 +00:00
2019-11-27 15:40:32 +00:00
if 'bdist_wheel' in unknown_args and args.checkpoint and args.model_config:
print('Embedding model in wheel file...')
2020-09-09 10:27:23 +00:00
model_dir = os.path.join('TTS', 'server', 'model')
2020-02-13 16:30:41 +00:00
tts_dir = os.path.join(model_dir, 'tts')
os.makedirs(tts_dir, exist_ok=True)
embedded_checkpoint_path = os.path.join(tts_dir, 'checkpoint.pth.tar')
2019-11-27 15:40:32 +00:00
shutil.copy(args.checkpoint, embedded_checkpoint_path)
2020-02-13 16:30:41 +00:00
embedded_config_path = os.path.join(tts_dir, 'config.json')
2019-11-27 15:40:32 +00:00
shutil.copy(args.model_config, embedded_config_path)
package_data.extend([embedded_checkpoint_path, embedded_config_path])
2018-06-21 13:48:13 +00:00
def pip_install(package_name):
2020-09-22 01:54:16 +00:00
subprocess.call([sys.executable, '-m', 'pip', 'install', package_name])
2021-01-25 12:06:12 +00:00
requirements = open(os.path.join(cwd, 'requirements.txt'), 'r').readlines()
2021-01-25 10:16:20 +00:00
with open('README.md', "r", encoding="utf-8") as readme_file:
README = readme_file.read()
2021-01-26 01:57:50 +00:00
exts = [Extension(name='TTS.tts.layers.glow_tts.monotonic_align.core',
sources=["TTS/tts/layers/glow_tts/monotonic_align/core.pyx"])]
2018-08-02 14:34:17 +00:00
setup(
2020-09-09 10:27:23 +00:00
name='TTS',
2018-08-02 14:34:17 +00:00
version=version,
2021-03-05 01:50:38 +00:00
url='https://github.com/coqui-ai/TTS',
2020-07-16 13:05:36 +00:00
author='Eren Gölge',
2021-03-05 01:50:38 +00:00
author_email='egolge@coqui.ai',
description='Deep learning for Text to Speech by Coqui.',
2021-01-25 12:06:12 +00:00
long_description=README,
long_description_content_type="text/markdown",
2019-08-26 13:18:43 +00:00
license='MPL-2.0',
2021-01-26 01:57:50 +00:00
# cython
include_dirs=numpy.get_include(),
ext_modules=cythonize(exts, language_level=3),
# ext_modules=find_cython_extensions(),
# package
include_package_data=True,
2020-07-16 13:05:36 +00:00
packages=find_packages(include=['TTS*']),
2019-08-26 13:18:43 +00:00
project_urls={
2021-03-05 01:50:38 +00:00
'Documentation': 'https://github.com/coqui-ai/TTS/wiki',
'Tracker': 'https://github.com/coqui-ai/TTS/issues',
'Repository': 'https://github.com/coqui-ai/TTS',
'Discussions': 'https://github.com/coqui-ai/TTS/discussions',
2019-08-30 08:29:22 +00:00
},
2018-08-02 14:34:17 +00:00
cmdclass={
'build_py': build_py,
'develop': develop,
2021-01-26 01:57:50 +00:00
# 'build_ext': build_ext
2018-08-02 14:34:17 +00:00
},
2021-01-25 12:06:12 +00:00
install_requires=requirements,
python_requires='>=3.6.0, <3.9',
2021-01-25 10:16:20 +00:00
entry_points={
'console_scripts': [
'tts=TTS.bin.synthesize:main',
'tts-server = TTS.server.server:main'
]
},
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
'Development Status :: 3 - Alpha',
2021-01-25 10:16:20 +00:00
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Operating System :: POSIX :: Linux",
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
2021-01-25 10:16:20 +00:00
"Topic :: Software Development",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Multimedia :: Sound/Audio :: Speech",
"Topic :: Multimedia :: Sound/Audio",
"Topic :: Multimedia",
"Topic :: Scientific/Engineering :: Artificial Intelligence"
2021-01-26 01:57:50 +00:00
],
zip_safe=False
)