Skip to content

Commit

Permalink
Merge pull request #89 from JSchmie/pyproject.toml
Browse files Browse the repository at this point in the history
Pyproject.toml
  • Loading branch information
JSchmie authored May 21, 2024
2 parents 815fe92 + ea216a2 commit 58df1bf
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 275 deletions.
135 changes: 48 additions & 87 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -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 📦
runs-on: ubuntu-latest
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
with:
name: python-package-distributions
path: dist/
test:
description: "Push to TestPyPI not PyPI"
default: true
type: boolean

publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs: build
jobs:
Build-and-publish-to-Test-PyPI:
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
steps:
- uses: actions/checkout@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
fetch-depth: '0'
- name: Set up Poetry 📦
uses: JRubics/[email protected]
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:
fetch-depth: '0'
branch: 'main'
- name: Checkout Repository (Develop)
uses: actions/checkout@v4
if: github.ref == "refs/heads/develop"
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: 'develop'
- name: Set up Poetry 📦
uses: JRubics/poetry-publish@v1.16
with:
repository-url: ${{ github.ref == 'refs/heads/main' && 'env.PyPI_URL' || ' env.PyPI_DEV_URL' }}
password: ${{ secrets.PYPI_API_TOKEN}}
pypi_token: ${{ secrets.PYPI_API_TOKEN }}
plugins: "poetry-dynamic-versioning"
repository_name: "scraibe"
9 changes: 3 additions & 6 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Run Tests

on:
#push:

pull_request:
branches: ['main', 'develop']
workflow_dispatch:
Expand All @@ -14,6 +12,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v3
Expand All @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
48 changes: 48 additions & 0 deletions .github/workflows/semver.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions .ruff.toml

This file was deleted.

6 changes: 0 additions & 6 deletions MANIFEST.in

This file was deleted.

72 changes: 72 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
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"]
3 changes: 1 addition & 2 deletions scraibe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
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__
1 change: 1 addition & 0 deletions scraibe/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.0"
Loading

0 comments on commit 58df1bf

Please sign in to comment.