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
|
|
|
|
|
2018-06-21 13:48:13 +00:00
|
|
|
from setuptools import setup, find_packages
|
|
|
|
import setuptools.command.develop
|
|
|
|
import setuptools.command.build_py
|
2019-11-27 15:40:32 +00:00
|
|
|
|
|
|
|
|
2019-11-27 16:14:38 +00:00
|
|
|
parser = argparse.ArgumentParser(add_help=False, allow_abbrev=False)
|
2019-11-27 15:40:32 +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.')
|
|
|
|
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
|
|
|
|
2020-07-16 13:05:36 +00:00
|
|
|
version = '0.0.4'
|
2018-06-21 13:48:13 +00:00
|
|
|
|
|
|
|
# Adapted from https://github.com/pytorch/pytorch
|
|
|
|
cwd = os.path.dirname(os.path.abspath(__file__))
|
2020-08-04 08:32:04 +00:00
|
|
|
if os.getenv('MOZILLA_VOICE_TTS_PYTORCH_BUILD_VERSION'):
|
|
|
|
version = os.getenv('MOZILLA_VOICE_TTS_PYTORCH_BUILD_VERSION')
|
2018-06-21 13:48:13 +00:00
|
|
|
else:
|
|
|
|
try:
|
|
|
|
sha = subprocess.check_output(
|
|
|
|
['git', 'rev-parse', 'HEAD'], cwd=cwd).decode('ascii').strip()
|
|
|
|
version += '+' + sha[:7]
|
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
pass
|
|
|
|
except IOError: # FileNotFoundError for python 3
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
2019-12-09 16:25:49 +00:00
|
|
|
# The documentation for this feature is in server/README.md
|
2020-08-04 08:32:04 +00:00
|
|
|
package_data = ['mozilla_voice_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-08-04 08:32:04 +00:00
|
|
|
model_dir = os.path.join('mozilla_voice_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
|
|
|
|
2020-07-12 13:36:36 +00:00
|
|
|
|
|
|
|
def pip_install(package_name):
|
|
|
|
subprocess.call(
|
|
|
|
[sys.executable, '-m', 'pip', 'install', package_name]
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2020-07-27 12:29:14 +00:00
|
|
|
reqs_from_file = open('requirements.txt').readlines()
|
|
|
|
reqs_without_tf = [r for r in reqs_from_file if not r.startswith('tensorflow')]
|
|
|
|
tf_req = [r for r in reqs_from_file if r.startswith('tensorflow')]
|
|
|
|
|
2020-07-12 13:36:36 +00:00
|
|
|
requirements = {
|
2020-07-27 12:29:14 +00:00
|
|
|
'install_requires': reqs_without_tf,
|
|
|
|
'pip_install': tf_req
|
2020-07-12 13:36:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-02 14:34:17 +00:00
|
|
|
setup(
|
2020-08-04 08:32:04 +00:00
|
|
|
name='mozilla_voice_tts',
|
2018-08-02 14:34:17 +00:00
|
|
|
version=version,
|
|
|
|
url='https://github.com/mozilla/TTS',
|
2020-07-16 13:05:36 +00:00
|
|
|
author='Eren Gölge',
|
|
|
|
author_email='egolge@mozilla.com',
|
2018-08-02 14:34:17 +00:00
|
|
|
description='Text to Speech with Deep Learning',
|
2019-08-26 13:18:43 +00:00
|
|
|
license='MPL-2.0',
|
2020-06-12 23:34:51 +00:00
|
|
|
entry_points={
|
|
|
|
'console_scripts': [
|
2020-08-04 08:32:04 +00:00
|
|
|
'tts-server = mozilla_voice_tts.server.server:main'
|
2020-06-12 23:34:51 +00:00
|
|
|
]
|
|
|
|
},
|
2020-07-16 13:05:36 +00:00
|
|
|
packages=find_packages(include=['TTS*']),
|
2019-08-26 13:18:43 +00:00
|
|
|
project_urls={
|
2019-08-30 08:29:22 +00:00
|
|
|
'Documentation': 'https://github.com/mozilla/TTS/wiki',
|
|
|
|
'Tracker': 'https://github.com/mozilla/TTS/issues',
|
|
|
|
'Repository': 'https://github.com/mozilla/TTS',
|
|
|
|
'Discussions': 'https://discourse.mozilla.org/c/tts',
|
|
|
|
},
|
2018-08-02 14:34:17 +00:00
|
|
|
cmdclass={
|
|
|
|
'build_py': build_py,
|
|
|
|
'develop': develop,
|
|
|
|
},
|
2020-07-12 13:36:36 +00:00
|
|
|
install_requires=requirements['install_requires'],
|
|
|
|
python_requires='>=3.6.0',
|
|
|
|
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',
|
|
|
|
"Intended Audience :: Science/Research :: Developers",
|
|
|
|
"Operating System :: POSIX :: Linux",
|
|
|
|
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
|
|
|
|
"Topic :: Software Development :: Libraries :: Python Modules :: Speech :: Sound/Audio :: Multimedia :: Artificial Intelligence",
|
2019-09-05 10:54:45 +00:00
|
|
|
]
|
2019-08-21 16:46:22 +00:00
|
|
|
)
|
2020-07-12 13:36:36 +00:00
|
|
|
|
|
|
|
# for some reason having tensorflow in 'install_requires'
|
|
|
|
# breaks some of the dependencies.
|
2020-08-03 11:00:44 +00:00
|
|
|
if 'bdist_wheel' not in unknown_args:
|
|
|
|
for module in requirements['pip_install']:
|
|
|
|
pip_install(module)
|