diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 0e73d9a..451aba8 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -1,112 +1,73 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI -# on: -# workflow_dispatch: -# inputs: -# branch_name: -# description: 'Branch to build from (default is main)' -# required: false -# default: 'main' -# workflow_run: -# workflows: ["Run Tests"] -# types: -# - completed -# branches: [main, develop] # This ensures it only triggers for these branches - on: push: branches: - develop + tags: + - v* # Push tags to trigger the workflow workflow_dispatch: inputs: - branch_name: - description: 'Branch to build from (default is main)' - required: false - default: 'main' - -env: - TestPyPI_URL: https://test.pypi.org/p/scraibe - PyPI_URL: https://pypi.org/p/scraibe - PyPI_DEV_URL: https://pypi.org/p/scraibe-nightly - ISRELEASED: true -jobs: - - build: - name: Build distribution 📦 + test: + description: "Push to TestPyPI not PyPI" + default: true + type: boolean + +jobs: + Build-and-publish-to-Test-PyPI: runs-on: ubuntu-latest - steps: + steps: - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v4 with: - python-version: "3.x" - - name: Install dependencies - run: | - python3 -m pip install --upgrade pip - pip install setuptools wheel - - name: Build source distribution - run: | - python3 -c "import os; print('ISRELEASED' in os.environ)" - python3 setup.py sdist - - name: Store the distribution packages - uses: actions/upload-artifact@v3 + fetch-depth: '0' + - name: Set up Poetry 📦 + uses: JRubics/poetry-publish@v1.16 with: - name: python-package-distributions - path: dist/ - - publish-to-testpypi: - name: Publish Python 🐍 distribution 📦 to TestPyPI - needs: build - runs-on: ubuntu-latest - environment: - name: testpypi - url: env.TestPyPI_URL - permissions: - id-token: write - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 - with: - name: python-package-distributions - path: dist/ - - name: Publish distribution 📦 to TestPyPI - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - skip-existing: true - + pypi_token: ${{ secrets.TEST_PYPI_API_TOKEN }} + plugins: "poetry-dynamic-versioning" + repository_name: "scraibe" + repository_url: "https://test.pypi.org/legacy/" test-install: name: Test Installation from TestPyPI - needs: publish-to-testpypi + needs: Build-and-publish-to-Test-PyPI runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9, 3.11, 3.12] steps: - - name: Set up Python - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 with: - python-version: "3.x" + python-version: ${{ matrix.python-version }} - name: Install package run: | - python3 -m pip install setuptools - python3 -m pip install --index-url https://test.pypi.org/simple/ scraibe + pip install -U setuptools + pip install -r requirements.txt + python3 -m pip install --no-deps --pre --index-url https://test.pypi.org/simple/ scraibe>=0.1.3 + python3 -c "import scraibe; print(scraibe.__version__)" publish-to-pypi: - name: Conditional Publish to PyPI or Dev Repository - needs: [build, test-install] + name: Publish to PyPI + needs: test-install runs-on: ubuntu-latest - environment: - name: pypi - url: env.PyPI_URL - permissions: - id-token: write - steps: - - name: Download all the dists - uses: actions/download-artifact@v3 + steps: + - name: Checkout Repository Tags + uses: actions/checkout@v4 + if: github.ref == 'refs/tags/v*' with: - name: python-package-distributions - path: dist/ - - name: Publish distribution 📦 to PyPI or Dev Repository - uses: pypa/gh-action-pypi-publish@release/v1 + fetch-depth: '0' + branch: 'main' + - name: Checkout Repository (Develop) + uses: actions/checkout@v4 + if: github.ref == "refs/heads/develop" with: - repository-url: ${{ github.ref == 'refs/heads/main' && 'env.PyPI_URL' || ' env.PyPI_DEV_URL' }} - password: ${{ secrets.PYPI_API_TOKEN}} \ No newline at end of file + fetch-depth: '0' + branch: 'develop' + - name: Set up Poetry 📦 + uses: JRubics/poetry-publish@v1.16 + with: + pypi_token: ${{ secrets.PYPI_API_TOKEN }} + plugins: "poetry-dynamic-versioning" + repository_name: "scraibe" \ No newline at end of file diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 973571f..aac8afe 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -1,8 +1,6 @@ name: Run Tests on: - #push: - pull_request: branches: ['main', 'develop'] workflow_dispatch: @@ -14,6 +12,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Setup Python uses: actions/setup-python@v3 @@ -30,10 +30,7 @@ jobs: sudo apt-get install libsndfile1-dev sudo apt-get install ffmpeg pip install pytest - - - - + - name: Run pytest env: HF_TOKEN : ${{ secrets.HF_TOKEN }} diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml index c8a0958..271e0b4 100644 --- a/.github/workflows/ruff.yml +++ b/.github/workflows/ruff.yml @@ -3,6 +3,7 @@ on: [ push, pull_request ] jobs: ruff: runs-on: ubuntu-latest + if: ${{ github.event_name == 'pull_request' || (github.event_name == 'push') }} steps: - uses: actions/checkout@v4 - uses: chartboost/ruff-action@v1 \ No newline at end of file diff --git a/.github/workflows/semver.yml b/.github/workflows/semver.yml new file mode 100644 index 0000000..c6d5fb1 --- /dev/null +++ b/.github/workflows/semver.yml @@ -0,0 +1,48 @@ +name: Semantic Versioning for Tags + +on: + pull_request: + types: [closed] + branches: + - main + +jobs: + bump-version: + if: ${{ github.event.pull_request.merged == true $$ github.event.pull_request.base.ref == 'main' }} + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Bump Version and Tag + run: | + # Fetch the latest tags from the remote + git fetch --tags + + # Get the latest tag + latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) + + # Split the latest tag into parts + IFS='.' read -r -a parts <<< "${latest_tag#v}" + + # Increment the patch version + major=${parts[0]} + minor=${parts[1]} + patch=${parts[2]} + new_patch=$((patch + 1)) + + # Create a new tag + new_tag="v$major.$minor.$new_patch" + + echo "Bumping version from $latest_tag to $new_tag" + + # Tag the new version + git tag $new_tag + + # Configure GitHub token authentication + git remote set-url origin https://x-access-token:${{ secrets.GH_TOKEN }}@github.com/${{ github.repository }}.git + + # Push the new tag to the remote repository + git push origin $new_tag diff --git a/.ruff.toml b/.ruff.toml deleted file mode 100644 index f6be0be..0000000 --- a/.ruff.toml +++ /dev/null @@ -1,2 +0,0 @@ -[lint.extend-per-file-ignores] -"__init__.py" = ["E402","F403"] diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index e2cb9a8..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -recursive-include scraibe *.py -recursive-include scraibe *.yaml -recursive-exclude test/* -global-include requirements.txt -global-exclude *.pyc -global-exclude __pycache__ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b850f63 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,72 @@ +[build-system] +requires = ["poetry-core>=1.8.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"] +build-backend = "poetry_dynamic_versioning.backend" + +[tool.poetry] +name = "scraibe" +version = "0.0.0" +description = "Transcription tool for audio files based on Whisper and Pyannote" +authors = ["Schmieder, Jacob "] +license = "GPL-3.0-or-later" +readme = ["README.md", "LICENSE"] +repository = "https://github.com/JSchmie/ScAIbe" +documentation = "https://jschmie.github.io/ScrAIbe/" +keywords = ["transcription", "audio", "whisper", "pyannote", "speech-to-text", "speech-recognition"] +classifiers = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Environment :: GPU :: NVIDIA CUDA :: 12 :: 12.1', + 'Topic :: Scientific/Engineering :: Artificial Intelligence' + ] +packages = [{include = "scraibe"}] +exclude =[ + "__pycache__", + "*.pyc", + "test" + ] +[tool.poetry.dependencies] +python = "^3.9" +tqdm = "^4.66.4" +numpy = "^1.26.4" +openai-whisper = "^20231117" +"pyannote.audio" = "^3.2.0" +torch = "^2.3.0" + +[tool.poetry.group.dev.dependencies] +pytest = "^8.1.1" + +[tool.poetry-dynamic-versioning] +enable = true +vcs = "git" +strict = true +format-jinja = """ + {%- if distance == 0 -%} + {{ serialize_pep440(base) }} + {%- elif branch == 'pyproject.toml' -%} + {{ serialize_pep440(bump_version(base), dev = distance) }} + {%- else -%} + {{ serialize_pep440(bump_version(base), dev=distance, metadata=[commit]) }} + {%- endif -%} +""" + +[tool.poetry.group.docs.dependencies] +sphinx = "^7.3.7" +sphinx-rtd-theme = "^2.0.0" +markdown-it-py = {version = "~3.0.0", extras = ["plugins"]} +myst-parser = "^3.0.1" +mdit-py-plugins = "^0.4.1" + +[tool.poetry.scripts] +scraibe = "scraibe.cli:cli" + +[tool.poetry.extras] +app = ["scraibe-webui"] + +[tool.ruff.lint.extend-per-file-ignores] +"__init__.py" = ["E402","F403",'F401'] +"scraibe/misc.py" = ["E722"] diff --git a/scraibe/__init__.py b/scraibe/__init__.py index eb0cc68..399023a 100644 --- a/scraibe/__init__.py +++ b/scraibe/__init__.py @@ -4,9 +4,8 @@ from .audio import * from .transcript_exporter import * from .diarisation import * -from .version import get_version as _get_version from .misc import * from .cli import * -__version__ = _get_version() +from ._version import __version__ diff --git a/scraibe/_version.py b/scraibe/_version.py new file mode 100644 index 0000000..3aa0d7b --- /dev/null +++ b/scraibe/_version.py @@ -0,0 +1 @@ +__version__ = "0.0.0" \ No newline at end of file diff --git a/scraibe/version.py b/scraibe/version.py deleted file mode 100644 index 6bef146..0000000 --- a/scraibe/version.py +++ /dev/null @@ -1,71 +0,0 @@ -import os -import subprocess as sp - -MAJOR = 0 -MINOR = 1 -MICRO = 1 -NANO = 2 -ISRELEASED = False -VERSION = '%d.%d.%d.%d' % (MAJOR, MINOR, MICRO, NANO) - -# Return the git revision as a string -# taken from numpy/numpy - - -def git_version(): - def _minimal_ext_cmd(cmd): - # construct minimal environment - env = {} - for k in ['SYSTEMROOT', 'PATH', 'HOME']: - v = os.environ.get(k) - if v is not None: - env[k] = v - - # LANGUAGE is used on win32 - env['LANGUAGE'] = 'C' - env['LANG'] = 'C' - env['LC_ALL'] = 'C' - - out = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE, - env=env).communicate()[0] - return out - - try: - out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD']) - GIT_REVISION = out.strip().decode('ascii') - except OSError: - GIT_REVISION = "Unknown" - - return GIT_REVISION - - -def _get_git_version(): - cwd = os.getcwd() - - # go to the main directory - fdir = os.path.dirname(os.path.abspath(__file__)) - maindir = os.path.abspath(os.path.join(fdir, "..")) - # maindir = fdir # os.path.join(fdir, "..") - os.chdir(maindir) - - # get git version - res = git_version() - - # restore the cwd - os.chdir(cwd) - return res - - -def get_version(build_version=False): - if ISRELEASED: - return VERSION - - # unreleased version - GIT_REVISION = _get_git_version() - - if build_version: - import datetime as dt - date = dt.date.strftime(dt.datetime.now(), "%Y%m%d%H%M%S") - return VERSION + ".dev" + date - else: - return VERSION + ".dev0+" + GIT_REVISION[:7] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 7ecab8c..0000000 --- a/setup.cfg +++ /dev/null @@ -1,32 +0,0 @@ -[metadata] -name = scraibe -version = attr: scraibe.__version__ -author = Jacob Schmieder -author_email = Jacob.Schmieder@dbfz.de -description = My package description -long_description = file: README.md, file: LICENSE -long_description_content_type = text/markdown; charset=UTF-8; variant=GFM -platforms = Linux -keywords = transcription speech recognition whisper pyannote audio speech-to-text speech-to-text transcription speech-to-text recognition voice-to-speech -license = GPL-3.0 -classifiers = - Development Status :: 3 - Alpha - Environment :: GPU :: NVIDIA CUDA :: 11.2 - License :: OSI Approved :: Open Software License 3.0 (OSL-3.0) - Topic :: Scientific/Engineering :: Artificial Intelligence - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - -[options] -zip_safe = False -include_package_data = True -packages = find: -python_requires = >=3.7 -install_requires = - requests - importlib-metadata; python_version<"3.8" - -[options.entry_points] -console_scripts = - executable-name = scraibe.cli:cli \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 3dfc95e..0000000 --- a/setup.py +++ /dev/null @@ -1,69 +0,0 @@ -import os -from setuptools import setup, find_packages - -module_name = "scraibe" -github_url = "https://github.com/JSchmie/ScAIbe" - -file_dir = os.path.dirname(os.path.realpath(__file__)) -absdir = lambda p: os.path.join(file_dir, p) - -############### versioning ############### -verfile = os.path.abspath(os.path.join(module_name, "version.py")) -version = {"__file__": verfile} - -with open(verfile, "r") as fp: - exec(fp.read(), version) - - -############### setup ############### - -build_version = "SCRAIBE_BUILD" in os.environ - -version["ISRELEASED"] = True if "ISRELEASED" in os.environ else False - -############### load requirements ############### - -with open(os.path.join(os.path.dirname(__file__), "requirements.txt")) as f: - requirements = [line.strip() for line in f if line.strip() and not line.startswith('#')] - - -print(f"Launch Version: {version['get_version'](build_version)}") - -if __name__ == "__main__": - - setup( - name = module_name, - version = version["get_version"](build_version), - packages = find_packages(), - python_requires = ">=3.8", - readme = "README.md", - install_requires = requirements, - extras_require = { - "app" : ["scraibe-webui"], - }, - # dependency_links=[ - # 'https://download.pytorch.org/whl/cu113', - # ], - - url = github_url, - - license = 'GPL-3', - author = 'Jacob Schmieder', - author_email = 'Jacob.Schmieder@dbfz.de', - description = 'Transcription tool for audio files based on Whisper and Pyannote', - classifiers = [ - 'Development Status :: 3 - Alpha', - 'Environment :: GPU :: NVIDIA CUDA :: 11.2', - 'License :: OSI Approved :: Open Software License 3.0 (OSL-3.0)', - 'Topic :: Scientific/Engineering :: Artificial Intelligence', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10'], - keywords = ['transcription', 'speech recognition', 'whisper', 'pyannote', 'audio', 'ScrAIbe', 'scraibe', - 'speech-to-text', 'speech-to-text transcription', 'speech-to-text recognition', - 'voice-to-speech'], - include_package_data=True, - package_data = {'scraibe.app' : ["*.html", "*.svg","*.yml"]}, - entry_points = {'console_scripts': - ['scraibe = scraibe.cli:cli']} - )