setup.py 4.1 KB
Newer Older
H
Hui Zhang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import io
import os
import re

from setuptools import find_packages
from setuptools import setup
H
Hui Zhang 已提交
20 21 22 23 24 25
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__))
H
Hui Zhang 已提交
26 27 28


def read(*names, **kwargs):
H
Hui Zhang 已提交
29 30
    with io.open(os.path.join(os.path.dirname(__file__), *names),
                 encoding=kwargs.get("encoding", "utf8")) as fp:
H
Hui Zhang 已提交
31 32 33
        return fp.read()


H
Hui Zhang 已提交
34
VERSION = '2.1.2'
H
Hui Zhang 已提交
35
long_description = read("README.md")
H
Hui Zhang 已提交
36
deps = [d.strip() for d in read('requirements.txt').split()]
H
Hui Zhang 已提交
37

H
Hui Zhang 已提交
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

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()


H
Hui Zhang 已提交
89 90
setup_info = dict(
    # Metadata
H
Hui Zhang 已提交
91
    name='paddle-speech',
H
Hui Zhang 已提交
92
    version=VERSION,
H
Hui Zhang 已提交
93
    author='PaddleSL Speech Team',
H
Hui Zhang 已提交
94
    author_email='',
H
Hui Zhang 已提交
95
    url='https://github.com/PaddlePaddle/DeepSpeech',
H
Hui Zhang 已提交
96
    license='Apache 2',
H
Hui Zhang 已提交
97
    description='Speech tools and models based on Paddlepaddle',
H
Hui Zhang 已提交
98 99
    long_description=long_description,
    long_description_content_type="text/markdown",
H
Hui Zhang 已提交
100 101 102 103 104 105 106 107 108 109 110 111 112 113
    keywords=[
        "speech",
        "asr",
        "tts",
        "text frontend",
        "MFA",
        "paddlepaddle",
        "transformer",
        "conformer",
        "fastspeech",
        "vocoder",
        "pwgan",
        "gan",
    ],
H
Hui Zhang 已提交
114
    python_requires='>=3.6',
H
Hui Zhang 已提交
115
    install_requires=deps,
H
Hui Zhang 已提交
116
    extras_require={
H
Hui Zhang 已提交
117 118 119 120
        'doc': [
            "sphinx", "sphinx-rtd-theme", "numpydoc", "myst_parser",
            "recommonmark>=0.5.0", "sphinx-markdown-tables", "sphinx-autobuild"
        ],
H
Hui Zhang 已提交
121
    },
H
Hui Zhang 已提交
122 123 124 125 126
    cmdclass={
        'develop': DevelopCommand,
        'install': InstallCommand,
        'upload': UploadCommand,
    },
H
Hui Zhang 已提交
127 128 129 130 131 132 133 134 135 136

    # Package info
    packages=find_packages(exclude=('tests', 'tests.*')),
    zip_safe=True,
    classifiers=[
        'Development Status :: 4 - Beta',
        'Intended Audience :: Developers',
        'Intended Audience :: Science/Research',
        'Topic :: Scientific/Engineering :: Artificial Intelligence',
        'License :: OSI Approved :: Apache Software License',
H
Hui Zhang 已提交
137 138
        'Programming Language :: Python',
        'Programming Language :: Python :: 3',
H
Hui Zhang 已提交
139 140
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
H
Hui Zhang 已提交
141 142 143
        'Programming Language :: Python :: 3.8',
    ],
)
H
Hui Zhang 已提交
144 145

setup(**setup_info)