auto upload to pypi on release

pull/532/head
Eren Gölge 2021-06-04 10:10:51 +02:00
parent e66753bd0d
commit ba9bcf7c6b
5 changed files with 90 additions and 49 deletions

38
.github/workflows/pypi-release.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: Publish Python 🐍 distributions 📦 to PyPI
on:
release:
types: [published]
defaults:
run:
shell:
bash
jobs:
build-package:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Verify tag matches version
run: |
set -ex
version=$(cat TTS/VERSION)
tag="${GITHUB_REF/refs\/tags\/}"
if [[ "v$version" != "$tag" ]]; then
exit 1
fi
- uses: actions/setup-python@v2
with:
python-version: 3.8
- run: |
python -m pip install -U pip setuptools twine toml
python -c 'import toml; c = toml.load("pyproject.toml"); print("\n".join(c["build-system"]["requires"]))' | pip install -r /dev/stdin
- run: |
python setup.py sdist
- name: Setup PyPI config
run: |
cat << EOF > ~/.pypirc
[pypi]
username=__token__
password=${{ secrets.PYPI_TOKEN }}
EOF
- run: |
twine upload --repository pypi dist/*.tar.gz

1
TTS/VERSION Normal file
View File

@ -0,0 +1 @@
0.0.14.1-alpha.2

View File

@ -1 +1,7 @@
from ._version import __version__
import os
with open(os.path.join(os.path.dirname(__file__), "VERSION")) as f:
version = f.read().strip()
__version__ = version

View File

@ -1 +0,0 @@
__version__ = "0.0.15"

View File

@ -4,7 +4,6 @@ import os
import subprocess
import sys
from distutils.version import LooseVersion
from TTS._version import __version__
import numpy
import setuptools.command.build_py
@ -12,82 +11,85 @@ import setuptools.command.develop
from Cython.Build import cythonize
from setuptools import Extension, find_packages, setup
if LooseVersion(sys.version) < LooseVersion("3.6") or LooseVersion(sys.version) > LooseVersion("3.9"):
raise RuntimeError(
"TTS requires python >= 3.6 and <3.9 "
"but your Python version is {}".format(sys.version)
)
raise RuntimeError("TTS requires python >= 3.6 and <3.9 " "but your Python version is {}".format(sys.version))
version = __version__
cwd = os.path.dirname(os.path.abspath(__file__))
cwd = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(cwd, "TTS", "VERSION")) as fin:
version = fin.read().strip()
class build_py(setuptools.command.build_py.build_py): # pylint: disable=too-many-ancestors
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
package_data = ['TTS/server/templates/*']
package_data = ["TTS/server/templates/*"]
def pip_install(package_name):
subprocess.call([sys.executable, '-m', 'pip', 'install', package_name])
subprocess.call([sys.executable, "-m", "pip", "install", package_name])
requirements = open(os.path.join(cwd, 'requirements.txt'), 'r').readlines()
with open(os.path.join(cwd, 'requirements.notebooks.txt'), 'r') as f:
requirements = open(os.path.join(cwd, "requirements.txt"), "r").readlines()
with open(os.path.join(cwd, "requirements.notebooks.txt"), "r") as f:
requirements_notebooks = f.readlines()
with open(os.path.join(cwd, 'requirements.dev.txt'), 'r') as f:
with open(os.path.join(cwd, "requirements.dev.txt"), "r") as f:
requirements_dev = f.readlines()
with open(os.path.join(cwd, 'requirements.tf.txt'), 'r') as f:
with open(os.path.join(cwd, "requirements.tf.txt"), "r") as f:
requirements_tf = f.readlines()
requirements_all = requirements_dev + requirements_notebooks + requirements_tf
with open('README.md', "r", encoding="utf-8") as readme_file:
with open("README.md", "r", encoding="utf-8") as readme_file:
README = readme_file.read()
exts = [Extension(name='TTS.tts.layers.glow_tts.monotonic_align.core',
sources=["TTS/tts/layers/glow_tts/monotonic_align/core.pyx"])]
exts = [
Extension(
name="TTS.tts.layers.glow_tts.monotonic_align.core",
sources=["TTS/tts/layers/glow_tts/monotonic_align/core.pyx"],
)
]
setup(
name='TTS',
name="TTS",
version=version,
url='https://github.com/coqui-ai/TTS',
author='Eren Gölge',
author_email='egolge@coqui.ai',
description='Deep learning for Text to Speech by Coqui.',
url="https://github.com/coqui-ai/TTS",
author="Eren Gölge",
author_email="egolge@coqui.ai",
description="Deep learning for Text to Speech by Coqui.",
long_description=README,
long_description_content_type="text/markdown",
license='MPL-2.0',
license="MPL-2.0",
# cython
include_dirs=numpy.get_include(),
ext_modules=cythonize(exts, language_level=3),
# ext_modules=find_cython_extensions(),
# package
include_package_data=True,
packages=find_packages(include=['TTS*']),
packages=find_packages(include=["TTS*"]),
package_data={
"TTS": [
"VERSION",
]
},
project_urls={
'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',
"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",
},
cmdclass={
'build_py': build_py,
'develop': develop,
"build_py": build_py,
"develop": develop,
# 'build_ext': build_ext
},
install_requires=requirements,
@ -97,30 +99,25 @@ setup(
"notebooks": requirements_notebooks,
"tf": requirements_tf,
},
python_requires='>=3.6.0, <3.9',
entry_points={
'console_scripts': [
'tts=TTS.bin.synthesize:main',
'tts-server = TTS.server.server:main'
]
},
python_requires=">=3.6.0, <3.9",
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',
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"Operating System :: POSIX :: Linux",
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
"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"
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
zip_safe=False
zip_safe=False,
)