diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 00000000..041be01c --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,88 @@ +name: CD + +on: + push: + branches: [ master ] + workflow_dispatch: + +permissions: + contents: write + id-token: write + +concurrency: + group: cd-${{ github.ref }} + cancel-in-progress: false + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + cache: "pip" + + - name: Install build tooling + run: | + python -m pip install --upgrade pip + python -m pip install build "setuptools>=69" "setuptools-scm[toml]>=8" wheel + + - name: Find merged PR + id: pr + uses: actions-ecosystem/action-get-merged-pull-request@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Print PR info + run: | + echo "Merged PR number: ${{ steps.pr.outputs.number }}" + echo "Merged PR title : ${{ steps.pr.outputs.title }}" + + - name: Decide bump from labels + id: bump + run: | + lbls="${{ steps.pr.outputs.labels }}" + bump="" + shopt -s nocasematch + if [[ "$lbls" == *"release:major"* ]]; then bump=major; + elif [[ "$lbls" == *"release:minor"* ]]; then bump=minor; + elif [[ "$lbls" == *"release:patch"* ]]; then bump=patch; + fi + echo "force=$bump" >> "$GITHUB_OUTPUT" + + - name: Python Semantic Release + id: release + uses: python-semantic-release/python-semantic-release@v10 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + force: ${{ steps.bump.outputs.force }} + git_committer_name: "github-actions" + git_committer_email: "actions@users.noreply.github.com" + + - name: Build artifacts + if: steps.release.outputs.released == 'true' + run: python -m build --sdist --wheel + + - name: Publish | Upload to GitHub Release Assets + uses: python-semantic-release/publish-action@v10.4.1 + if: steps.release.outputs.released == 'true' + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ steps.release.outputs.tag }} + + - name: Upload | Distribution Artifacts + if: steps.release.outputs.released == 'true' + uses: actions/upload-artifact@v4 + with: + name: distribution-artifacts + path: dist + if-no-files-found: error + + # - name: Publish to PyPI via OIDC + # if: steps.release.outputs.released == 'true' + # uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98eb6259..f745abf6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,9 @@ name: CI +concurrency: + group: ci-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: [pull_request] jobs: @@ -7,13 +11,16 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.8', '3.13'] + python-version: ['3.10', '3.13'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: | + **/pyproject.toml - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/epitran/__init__.py b/epitran/__init__.py index 816d89ac..76d3770f 100644 --- a/epitran/__init__.py +++ b/epitran/__init__.py @@ -1,4 +1,13 @@ +from importlib.metadata import version, PackageNotFoundError + from epitran._epitran import Epitran from epitran.reromanize import ReRomanizer + +try: + __version__ = version("epitran") +except PackageNotFoundError: + # package is not installed + pass + __all__ = ["Epitran", "ReRomanizer"] diff --git a/epitran/_epitran.py b/epitran/_epitran.py index e13e3675..99446319 100644 --- a/epitran/_epitran.py +++ b/epitran/_epitran.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- import logging -from typing import Union import panphon.featuretable from epitran.epihan import Epihan, EpihanTraditional, EpiJpan, EpiCanto diff --git a/epitran/bin/migraterules.py b/epitran/bin/migraterules.py index 09d31969..2aa79a38 100644 --- a/epitran/bin/migraterules.py +++ b/epitran/bin/migraterules.py @@ -4,10 +4,8 @@ import glob import re -import io from typing import List, Optional -import csv def build_rule(fields: List[str]) -> Optional[str]: diff --git a/epitran/epihan.py b/epitran/epihan.py index 6759045e..ca0e2bb7 100644 --- a/epitran/epihan.py +++ b/epitran/epihan.py @@ -1,7 +1,6 @@ # -*- utf-8 -*- import os.path -from typing import Optional, List, Tuple import regex as re @@ -46,6 +45,8 @@ def __init__(self, **kwargs) -> None: cedict_file = kwargs.get('cedict_file', None) rules_file = kwargs.get('rules_file', 'pinyin-to-ipa.txt') tones = kwargs.get('tones', False) + assert ligatures is False, "Ligatures not supported for cmn-Hans" + if not cedict_file: cedict_file = download.cedict() if tones: @@ -119,6 +120,8 @@ def __init__(self, **kwargs) -> None: cedict_file = kwargs.get('cedict_file', None) tones = kwargs.get('tones', False) rules_file = kwargs.get('rules_file', 'pinyin-to-ipa.txt') + assert ligatures is False, "Ligatures not supported for cmn-Hant" + if not cedict_file: cedict_file = download.cedict() if tones: @@ -147,6 +150,8 @@ def __init__(self, **kwargs) -> None: cedict_file = kwargs.get('cedict_file', None) tones = kwargs.get('tones', False) rules_file = kwargs.get('rules_file', 'jyutping-to-ipa.txt') + assert ligatures is False, 'Ligatures not supported for yue-Hant' + if not cedict_file: cedict_file = download.cc_canto() if tones: @@ -172,6 +177,8 @@ def __init__(self, **kwargs) -> None: ligatures = kwargs.get('ligatures', False) cedict_file = kwargs.get('cedict_file', None) tones = kwargs.get('tones', False) + assert ligatures is False, 'Ligatures not supported for jpn-Jpan' + if not cedict_file: cedict_file = download.opendict_ja() self.cedict = cedict.CEDictTrieForJapanese(cedict_file) diff --git a/epitran/flite.py b/epitran/flite.py index 3b1ecbf5..290eabd9 100644 --- a/epitran/flite.py +++ b/epitran/flite.py @@ -3,9 +3,8 @@ import logging import os.path import string -import sys import unicodedata -from typing import Dict, List, Tuple, Any, Optional +from typing import Dict, List, Any import regex as re diff --git a/epitran/ppprocessor.py b/epitran/ppprocessor.py index 29b46516..8133a865 100644 --- a/epitran/ppprocessor.py +++ b/epitran/ppprocessor.py @@ -2,7 +2,6 @@ import logging import os.path -from typing import Union from importlib import resources diff --git a/epitran/rules.py b/epitran/rules.py index 20372ea3..5e2989af 100644 --- a/epitran/rules.py +++ b/epitran/rules.py @@ -6,7 +6,6 @@ from pathlib import Path import regex as re -from importlib import resources from epitran.exceptions import DatafileError diff --git a/epitran/simple.py b/epitran/simple.py index ede1fa04..0140be82 100644 --- a/epitran/simple.py +++ b/epitran/simple.py @@ -5,7 +5,7 @@ import csv import unicodedata from collections import defaultdict -from typing import DefaultDict, Callable, Any, Optional # pylint: disable=unused-import +from typing import DefaultDict, Callable, Any from importlib import resources import regex diff --git a/epitran/vector.py b/epitran/vector.py index c03a9979..3fe89539 100644 --- a/epitran/vector.py +++ b/epitran/vector.py @@ -1,6 +1,6 @@ import logging -from typing import List, Tuple, Any, Optional +from typing import List, Tuple, Optional from epitran import Epitran from epitran.space import Space diff --git a/pyproject.toml b/pyproject.toml index a4e5565f..3f8a6617 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=64", "wheel"] +requires = ["setuptools>=69", "setuptools-scm[toml]>=8", "wheel"] build-backend = "setuptools.build_meta" [project] name = "epitran" -version = "1.25.2" +dynamic = ["version"] description = "Tools for transcribing languages into IPA." readme = "README.md" license = { text = "MIT-Modern-Variant"} @@ -32,7 +32,6 @@ classifiers = [ ] keywords = ["linguistics", "phonetics", "IPA", "transliteration", "phonology"] dependencies = [ - "setuptools", "regex", "panphon>=0.20", "marisa-trie", @@ -42,10 +41,16 @@ dependencies = [ [project.urls] Homepage = "https://github.com/dmort27/epitran" -Repository = "https://github.com/dmort27/epitran" -"Bug Tracker" = "https://github.com/dmort27/epitran/issues" Documentation = "https://github.com/dmort27/epitran#readme" -Download = "https://github.com/dmort27/epitran/archive/1.25.1.tar.gz" +Repository = "https://github.com/dmort27/epitran" +Issues = "https://github.com/dmort27/epitran/issues" +Changelog = "https://github.com/dmort27/epitran/releases" + +[tool.setuptools_scm] +version_scheme = "guess-next-dev" +local_scheme = "no-local-version" +fallback_version = "0.0.0" + # Scripts will be handled via setuptools scripts configuration # since they don't follow the standard entry point pattern @@ -82,20 +87,15 @@ epitran = [ "data/bib/*.bib", ] -[tool.setuptools.dynamic] -# If you want to make version dynamic in the future, uncomment: -# version = {attr = "epitran.__version__"} - # Development dependencies (optional) [project.optional-dependencies] dev = [ - "pytest>=8.4.2", - "pytest-cov", - "black", - "flake8", - "mypy", + "ruff", ] -test = [ - "pytest>=8.4.2", - "pytest-cov", -] \ No newline at end of file + +# Automated semantic versioning and release management +[tool.semantic_release] +version_source = "tag" +tag_format = "v{version}" +commit_parser = "conventional" +upload_to_pypi = false