Skip to content

Commit 25d3c1c

Browse files
authored
feat: modernize package config and build/release workflow
This modernizes the overall project structure. feat: drops support for Python 2.7 (long overdue), Python 3.6 (end-of-life) feat: centralizes project metadata and config into a single `pyproject.toml`
1 parent 3d6cfc9 commit 25d3c1c

12 files changed

+152
-181
lines changed

Diff for: .github/dependabot.yml

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ updates:
99
directory: "/"
1010
schedule:
1111
interval: "weekly"
12-
ignore:
13-
- dependency-name: "pytest"
14-
# Until Python 2 is ripped out
15-
versions: ["5.x", "6.x", "7.x"]
1612

1713
- package-ecosystem: "github-actions"
1814
directory: "/"

Diff for: .github/workflows/publish.yml

-47
This file was deleted.

Diff for: .github/workflows/release.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release-please:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Release Please
14+
uses: google-github-actions/release-please-action@v3
15+
id: release
16+
with:
17+
release-type: python
18+
package-name: gTTS
19+
20+
# Only do the rest (package build/push) if a release was created
21+
- name: Checkout
22+
if: ${{ steps.release.outputs.release_created }}
23+
uses: actions/checkout@v3
24+
- name: Setup Python
25+
if: ${{ steps.release.outputs.release_created }}
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: "3.10"
29+
- name: Install build dependencies
30+
if: ${{ steps.release.outputs.release_created }}
31+
run: |
32+
pip install --upgrade pip
33+
pip install build
34+
- name: Build package
35+
if: ${{ steps.release.outputs.release_created }}
36+
run: python -m build
37+
- name: Publish package
38+
if: ${{ steps.release.outputs.release_created }}
39+
uses: pypa/gh-action-pypi-publish@37f50c210e3d2f9450da2cd423303d6a14a6e29f
40+
with:
41+
user: __token__
42+
password: ${{ secrets.PYPI_API_TOKEN }}
43+
44+
# References:
45+
# * Release Please:
46+
# https://github.com/googleapis/release-please
47+
# * Release Please (GitHub Action)
48+
# https://github.com/google-github-actions/release-please-action
49+
# * Conventional Commits:
50+
# https://www.conventionalcommits.org/

Diff for: .github/workflows/test.yml

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
name: Tests
2+
23
on:
3-
push:
4-
tags-ignore:
5-
- 'v*'
64
pull_request:
75
branches:
8-
- master
6+
- main
97

108
jobs:
119
test:
@@ -15,25 +13,26 @@ jobs:
1513
strategy:
1614
fail-fast: false
1715
matrix:
18-
python-version: ['2.x', 3.6, 3.7, 3.8, 3.9]
16+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
1917
os: [ubuntu-latest, macOS-latest, windows-latest]
2018

2119
steps:
2220
- uses: actions/checkout@v3
2321

24-
- uses: actions/setup-python@v3
22+
- uses: actions/setup-python@v4
2523
with:
2624
python-version: ${{ matrix.python-version }}
2725

2826
- name: Install
2927
run: |
3028
python -m pip install --upgrade pip
31-
pip install -e .[tests]
29+
pip install .[tests]
3230
3331
- name: Unit Tests
34-
run: pytest -v -s gtts/ --cov=gtts --cov-config=setup.cfg --cov-report=xml
32+
run: pytest -v --cov=gtts --cov-report=xml
3533
env:
36-
TEST_LANGS: all
34+
# TODO: Test all langs on release branch
35+
TEST_LANGS: en
3736

3837
- name: Upload Coverage Report
3938
uses: codecov/[email protected]

Diff for: .mypy.ini

-2
This file was deleted.

Diff for: .readthedocs.yml

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# Build PDF as extra
2-
formats:
3-
- pdf
4-
1+
version: 2
52
python:
6-
version: 3.7
7-
pip_install: true
8-
extra_requirements:
9-
- docs
3+
install:
4+
- method: pip
5+
path: .
6+
extra_requirements:
7+
- docs

Diff for: MANIFEST.in

-5
This file was deleted.

Diff for: news/.gitignore

-1
This file was deleted.

Diff for: pyproject.toml

+88-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,89 @@
1+
[project]
2+
name = "gTTS"
3+
description = "gTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate text-to-speech API"
4+
authors = [{name = "Pierre Nicolas Durette", email = "[email protected]"}]
5+
requires-python = ">=3.7"
6+
readme = "README.md"
7+
license = {text = "MIT"}
8+
keywords = [
9+
"gtts",
10+
"text to speech",
11+
"Google Translate",
12+
"TTS",
13+
]
14+
classifiers = [
15+
"Environment :: Console",
16+
"Intended Audience :: Developers",
17+
"License :: OSI Approved :: MIT License",
18+
"Operating System :: MacOS",
19+
"Operating System :: Unix",
20+
"Operating System :: POSIX",
21+
"Operating System :: POSIX :: Linux",
22+
"Operating System :: Microsoft :: Windows",
23+
"Programming Language :: Python :: 3.7",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Topic :: Software Development :: Libraries",
29+
"Topic :: Multimedia :: Sound/Audio :: Speech",
30+
]
31+
dependencies = [
32+
"requests ~= 2.28.0",
33+
"click ~= 8.1.3",
34+
"six ~= 1.16.0"
35+
]
36+
dynamic = ["version"]
37+
38+
[project.optional-dependencies]
39+
tests = [
40+
"pytest ~= 7.1.3",
41+
"pytest-cov",
42+
"testfixtures",
43+
"mock"
44+
]
45+
docs = [
46+
"sphinx",
47+
"sphinx-autobuild",
48+
"sphinx_rtd_theme",
49+
"sphinx-click"
50+
]
51+
52+
[project.scripts]
53+
gtts-cli = "gtts.cli:tts_cli"
54+
55+
[project.urls]
56+
homepage = "https://github.com/pndurette/gTTS"
57+
documentation = "https://gtts.readthedocs.io"
58+
repository = "https://github.com/pndurette/gTTS"
59+
changelog = "https://github.com/pndurette/gTTS/blob/main/CHANGELOG.rst"
60+
61+
[tool.setuptools.dynamic]
62+
version = {attr = "gtts.version.__version__"}
63+
64+
[tool.setuptools.packages.find]
65+
#where = ["src"] # list of folders that contain the packages (["."] by default)
66+
#include = ["my_package*"] # package names should match these glob patterns (["*"] by default)
67+
#exclude = ["my_package.tests*"] # exclude packages matching these glob patterns (empty by default)
68+
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
69+
70+
[tool.coverage.run]
71+
omit = [
72+
"gtts/tests/*",
73+
"gtts/tokenizer/tests/*",
74+
]
75+
76+
[tool.coverage.report]
77+
exclude_lines = [
78+
"pragma: no cover",
79+
"def __repr__",
80+
"log.debug",
81+
"log.warning",
82+
]
83+
84+
[tool.pytest.ini_options]
85+
markers = ["net: marks tests that call use the net (using the URL endpoint, deselect with '-m \"not net\"')"]
86+
187
[build-system]
2-
requires = ["setuptools", "wheel"]
3-
4-
[tool.towncrier]
5-
package = "gtts"
6-
filename = "CHANGELOG.rst"
7-
directory = "news/"
8-
underlines = ["-", "~", "_"]
9-
title_format = "{version} ({project_date})"
10-
issue_format = "`#{issue} <https://github.com/pndurette/gTTS/issues/{issue}>`_"
88+
requires = ["setuptools>=61", "wheel"]
89+
build-backend = "setuptools.build_meta"

Diff for: pytest.ini

-5
This file was deleted.

Diff for: setup.cfg

-78
This file was deleted.

Diff for: setup.py

-13
This file was deleted.

0 commit comments

Comments
 (0)