Skip to content

Commit

Permalink
feat: modernize package config and build/release workflow
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
pndurette committed Nov 21, 2022
1 parent 3d6cfc9 commit 25d3c1c
Show file tree
Hide file tree
Showing 12 changed files with 152 additions and 181 deletions.
4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ updates:
directory: "/"
schedule:
interval: "weekly"
ignore:
- dependency-name: "pytest"
# Until Python 2 is ripped out
versions: ["5.x", "6.x", "7.x"]

- package-ecosystem: "github-actions"
directory: "/"
Expand Down
47 changes: 0 additions & 47 deletions .github/workflows/publish.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Release

on:
push:
branches:
- main

jobs:
release-please:
runs-on: ubuntu-latest

steps:
- name: Release Please
uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: python
package-name: gTTS

# Only do the rest (package build/push) if a release was created
- name: Checkout
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v3
- name: Setup Python
if: ${{ steps.release.outputs.release_created }}
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install build dependencies
if: ${{ steps.release.outputs.release_created }}
run: |
pip install --upgrade pip
pip install build
- name: Build package
if: ${{ steps.release.outputs.release_created }}
run: python -m build
- name: Publish package
if: ${{ steps.release.outputs.release_created }}
uses: pypa/gh-action-pypi-publish@37f50c210e3d2f9450da2cd423303d6a14a6e29f
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

# References:
# * Release Please:
# https://github.com/googleapis/release-please
# * Release Please (GitHub Action)
# https://github.com/google-github-actions/release-please-action
# * Conventional Commits:
# https://www.conventionalcommits.org/
17 changes: 8 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: Tests

on:
push:
tags-ignore:
- 'v*'
pull_request:
branches:
- master
- main

jobs:
test:
Expand All @@ -15,25 +13,26 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['2.x', 3.6, 3.7, 3.8, 3.9]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, macOS-latest, windows-latest]

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install
run: |
python -m pip install --upgrade pip
pip install -e .[tests]
pip install .[tests]
- name: Unit Tests
run: pytest -v -s gtts/ --cov=gtts --cov-config=setup.cfg --cov-report=xml
run: pytest -v --cov=gtts --cov-report=xml
env:
TEST_LANGS: all
# TODO: Test all langs on release branch
TEST_LANGS: en

- name: Upload Coverage Report
uses: codecov/codecov-action@v3.1.0
2 changes: 0 additions & 2 deletions .mypy.ini

This file was deleted.

14 changes: 6 additions & 8 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# Build PDF as extra
formats:
- pdf

version: 2
python:
version: 3.7
pip_install: true
extra_requirements:
- docs
install:
- method: pip
path: .
extra_requirements:
- docs
5 changes: 0 additions & 5 deletions MANIFEST.in

This file was deleted.

1 change: 0 additions & 1 deletion news/.gitignore

This file was deleted.

97 changes: 88 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,89 @@
[project]
name = "gTTS"
description = "gTTS (Google Text-to-Speech), a Python library and CLI tool to interface with Google Translate text-to-speech API"
authors = [{name = "Pierre Nicolas Durette", email = "pndurette@gmail.com"}]
requires-python = ">=3.7"
readme = "README.md"
license = {text = "MIT"}
keywords = [
"gtts",
"text to speech",
"Google Translate",
"TTS",
]
classifiers = [
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS",
"Operating System :: Unix",
"Operating System :: POSIX",
"Operating System :: POSIX :: Linux",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Software Development :: Libraries",
"Topic :: Multimedia :: Sound/Audio :: Speech",
]
dependencies = [
"requests ~= 2.28.0",
"click ~= 8.1.3",
"six ~= 1.16.0"
]
dynamic = ["version"]

[project.optional-dependencies]
tests = [
"pytest ~= 7.1.3",
"pytest-cov",
"testfixtures",
"mock"
]
docs = [
"sphinx",
"sphinx-autobuild",
"sphinx_rtd_theme",
"sphinx-click"
]

[project.scripts]
gtts-cli = "gtts.cli:tts_cli"

[project.urls]
homepage = "https://github.com/pndurette/gTTS"
documentation = "https://gtts.readthedocs.io"
repository = "https://github.com/pndurette/gTTS"
changelog = "https://github.com/pndurette/gTTS/blob/main/CHANGELOG.rst"

[tool.setuptools.dynamic]
version = {attr = "gtts.version.__version__"}

[tool.setuptools.packages.find]
#where = ["src"] # list of folders that contain the packages (["."] by default)
#include = ["my_package*"] # package names should match these glob patterns (["*"] by default)
#exclude = ["my_package.tests*"] # exclude packages matching these glob patterns (empty by default)
namespaces = false # to disable scanning PEP 420 namespaces (true by default)

[tool.coverage.run]
omit = [
"gtts/tests/*",
"gtts/tokenizer/tests/*",
]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"def __repr__",
"log.debug",
"log.warning",
]

[tool.pytest.ini_options]
markers = ["net: marks tests that call use the net (using the URL endpoint, deselect with '-m \"not net\"')"]

[build-system]
requires = ["setuptools", "wheel"]

[tool.towncrier]
package = "gtts"
filename = "CHANGELOG.rst"
directory = "news/"
underlines = ["-", "~", "_"]
title_format = "{version} ({project_date})"
issue_format = "`#{issue} <https://github.com/pndurette/gTTS/issues/{issue}>`_"
requires = ["setuptools>=61", "wheel"]
build-backend = "setuptools.build_meta"
5 changes: 0 additions & 5 deletions pytest.ini

This file was deleted.

78 changes: 0 additions & 78 deletions setup.cfg

This file was deleted.

13 changes: 0 additions & 13 deletions setup.py

This file was deleted.

0 comments on commit 25d3c1c

Please sign in to comment.