From ba28c92b41b6b6440e02be6c3def6ef4c6e01212 Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Tue, 19 Oct 2021 11:24:18 +0000 Subject: [PATCH] setup with ubuntu deps --- .gitignore | 1 + requirements.txt | 2 +- setup.py | 80 +++++++++++++++++++++++++++++++++++++++++++++++- setup.sh | 2 +- 4 files changed, 82 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 535e8d12..cfdf0275 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ *.done *.whl *.egg-info +build docs/build/ diff --git a/requirements.txt b/requirements.txt index 42be6eec..2bad7e9e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -39,4 +39,4 @@ timer pyworld jieba phkit - +yq diff --git a/setup.py b/setup.py index b68f2d2e..2387eadb 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,12 @@ import re from setuptools import find_packages from setuptools import setup +from setuptools import Command +from setuptools.command.develop import develop +from setuptools.command.install import install +import subprocess as sp + +HERE = os.path.abspath(os.path.dirname(__file__)) def read(*names, **kwargs): @@ -29,6 +35,57 @@ VERSION = '2.1.2' long_description = read("README.md") deps = [d.strip() for d in read('requirements.txt').split()] + +def _pre_install(): + sp.check_call("apt-get update -y".split()) + sp.check_call("apt-get install -y".split() + + 'vim tig tree sox pkg-config'.split() + + 'libsndfile1 libflac-dev libogg-dev'.split() + + 'libvorbis-dev libboost-dev swig python3-dev'.split()) + + +def _post_install(install_lib_dir): + pass + + +class DevelopCommand(develop): + def run(self): + _pre_install() + develop.run(self) + self.execute(_post_install, (self.install_lib, ), msg="Post Install...") + + +class InstallCommand(install): + def run(self): + _pre_install() + install.run(self) + self.execute(_post_install, (self.install_lib, ), msg="Post Install...") + + +# cmd: python setup.py upload +class UploadCommand(Command): + description = "Build and publish the package." + user_options = [] + + def initialize_options(self): + pass + + def finalize_options(self): + pass + + def run(self): + try: + print("Removing previous dist/ ...") + shutil.rmtree(os.path.join(HERE, "dist")) + except OSError: + pass + print("Building source distribution...") + sp.check_call([sys.executable, "setup.py", "sdist"]) + print("Uploading package to PyPi...") + sp.check_call(["twine", "upload", "dist/*"]) + sys.exit() + + setup_info = dict( # Metadata name='paddle-speech', @@ -36,10 +93,24 @@ setup_info = dict( author='PaddleSL Speech Team', author_email='', url='https://github.com/PaddlePaddle/DeepSpeech', + license='Apache 2', description='Speech tools and models based on Paddlepaddle', long_description=long_description, long_description_content_type="text/markdown", - license='Apache 2', + keywords=[ + "speech", + "asr", + "tts", + "text frontend", + "MFA", + "paddlepaddle", + "transformer", + "conformer", + "fastspeech", + "vocoder", + "pwgan", + "gan", + ], python_requires='>=3.6', install_requires=deps, extras_require={ @@ -48,6 +119,11 @@ setup_info = dict( "recommonmark>=0.5.0", "sphinx-markdown-tables", "sphinx-autobuild" ], }, + cmdclass={ + 'develop': DevelopCommand, + 'install': InstallCommand, + 'upload': UploadCommand, + }, # Package info packages=find_packages(exclude=('tests', 'tests.*')), @@ -58,6 +134,8 @@ setup_info = dict( 'Intended Audience :: Science/Research', 'Topic :: Scientific/Engineering :: Artificial Intelligence', 'License :: OSI Approved :: Apache Software License', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', diff --git a/setup.sh b/setup.sh index 04ee12b4..d3dd8207 100644 --- a/setup.sh +++ b/setup.sh @@ -26,7 +26,7 @@ source tools/venv/bin/activate # install python dependencies if [ -f "requirements.txt" ]; then - pip3 install -r requirements.txt + pip3 install . fi if [ $? != 0 ]; then error_msg "Install python dependencies failed !!!" -- GitLab