From 551fe0a2c9a12251a1faab0622e55d0407bd7fbb Mon Sep 17 00:00:00 2001 From: Eren Date: Thu, 21 Jun 2018 15:48:13 +0200 Subject: [PATCH] add setup.py --- .gitignore | 3 ++ setup.py | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 1418de63..24b13870 100644 --- a/.gitignore +++ b/.gitignore @@ -116,5 +116,8 @@ venv.bak/ *.pth.tar result/ +# setup.py +version.py + # jupyter dummy files core diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..c3c4c001 --- /dev/null +++ b/setup.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python + +from setuptools import setup, find_packages +import setuptools.command.develop +import setuptools.command.build_py +import os +import subprocess +from os.path import exists + +version = '0.0.1' + +# Adapted from https://github.com/pytorch/pytorch +cwd = os.path.dirname(os.path.abspath(__file__)) +if os.getenv('TTS_PYTORCH_BUILD_VERSION'): + version = os.getenv('TTS_PYTORCH_BUILD_VERSION') +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 + + +class build_py(setuptools.command.build_py.build_py): + + def run(self): + self.create_version_file() + setuptools.command.build_py.build_py.run(self) + + @staticmethod + def create_version_file(): + global version, cwd + 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) + + +def create_readme_rst(): + global cwd + try: + subprocess.check_call( + ["pandoc", "--from=markdown", "--to=rst", "--output=README.rst", + "README.md"], cwd=cwd) + print("Generated README.rst from README.md using pandoc.") + except subprocess.CalledProcessError: + pass + except OSError: + pass + + +setup(name='TTS', + version=version, + url='https://github.com/mozilla/TTS', + description='Text to Speech with Deep Learning', + packages=find_packages(), + cmdclass={ + 'build_py': build_py, + 'develop': develop, + }, + install_requires=[ + "numpy", + "scipy", + "torch >= 0.4.0", + "unidecode", + "tensorboardX", + "matplotlib", + "Pillow", + "flask", + ], + extras_require={ + "bin": [ + "tqdm", + "tensorboardX", + "requests", + ], + }) \ No newline at end of file