Skip to content

Commit

Permalink
Merge pull request #29 from hitblast/migrate-poetry
Browse files Browse the repository at this point in the history
🔨 [tuning] Migrate to Poetry and Masonry API for deployment
  • Loading branch information
hitblast authored May 1, 2024
2 parents e8d67e7 + e156319 commit 9ca60b2
Show file tree
Hide file tree
Showing 19 changed files with 1,285 additions and 1,019 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python 3
uses: actions/setup-python@v5
- name: Install Poetry
uses: snok/install-poetry@v1
with:
python-version: '3.x'
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies & build
run: |
pip install -U pip
pip install build
python -m build
poetry install --sync --no-interaction --no-root
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }}
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
Expand All @@ -40,4 +40,4 @@ jobs:
file_glob: true

- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
run: poetry publish --build
17 changes: 9 additions & 8 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3
uses: actions/setup-python@v5

- name: Install Poetry
uses: snok/install-poetry@v1
with:
python-version: '3.x'

- name: Set up dependencies
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install dependencies & setup project
run: |
pip install -U pip && pip install pytest
poetry install --sync --no-interaction --no-root --with test
- name: Run the tests
run: pytest -v
run: poetry run pytest .
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ ipython_config.py
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,20 @@ $ avro parse --from-clip --copy # (clipboard input -> output)

**Additional Developer Notes**

In short, avro.py doesn't depend on any third-party libraries. However, if you'd like to contribute to the project, you'll need a handful of such useful tools. <br>
In short, avro.py doesn't depend on any third-party libraries. However, if you'd like to contribute to the project, you'll need a handful of such useful tools.

- [ruff](https://github.com/astral-sh/ruff) - linter
- [pytest](https://pypi.python.org/pypi/pytest) - testing framework
**Poetry** has been used to manage the project's dependencies and virtual environment. You can install it by following [the instructions here](https://python-poetry.org/docs/). The dependencies have been configured using the `pyproject.toml` file and doesn't require manual installation. Simply set up your developer environment using the following commands: <br>

```sh
# Installing the required developer toolchain.
$ python3 -m pip install -r requirements.txt
# Set up virtual environment and activate it.
$ python3 -m venv venv && source venv/bin/activate

# (Optional) Setting up the package itself for testing purposes.
$ python3 setup.py develop
# Install required first-party dependencies and Poetry for dependency management.
# (Note: Skip this step if Poetry is globally installed and added to PATH.)
$ pip install -U pip setuptools && pip install poetry

# Running the predetermined tests inside the project.
$ python3 -m pytest --verbose
# Setup project using Poetry.
$ poetry install --all-extras
```

### 🐛 We're looking for bug hunters, by the way!
Expand Down
6 changes: 0 additions & 6 deletions avro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,3 @@

# Import local modules.
from .main import *

# Set package information.
__description__ = 'A modern Pythonic implementation of Avro Phonetic.'

__version_info__ = ('2024', '4', '27') # YYYY / MM / DD
__version__ = '.'.join(__version_info__)
40 changes: 20 additions & 20 deletions avro/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
from rich.console import Console

except ImportError:
print('In order to enable CLI, please install avro.py using: pip install avro.py[cli]')
print("In order to enable CLI, please install avro.py using: pip install avro.py[cli]")
exit()


# Create a new group for putting the CLI commands.
@click.group(help=avro.__description__)
@click.group(help="A modern Pythonic implementation of Avro Phonetic.")
@click.version_option(
package_name='avro.py',
message='Package: %(prog)s, version %(version)s\nCore: version {0}'.format(avro.__version__),
package_name="avro.py",
message="Package: %(prog)s, version %(version)s\n",
)
def cli() -> None:
pass
Expand All @@ -33,7 +33,7 @@ def cli() -> None:

# Helper functions for CLI commands.
def _print_err(text: str) -> None:
console.print(text, style='red')
console.print(text, style="red")
return click.echo(err=True)


Expand All @@ -48,33 +48,33 @@ def _cli_action(
) -> Optional[str]:
if not text:
if not from_clipboard:
return _print_err('No text provided.')
return _print_err("No text provided.")
else:
if not (text := pyclip.paste(text=True).strip()):
return _print_err('No text found in the clipboard.')
return _print_err("No text found in the clipboard.")

if reverse:
output = avro.reverse(text)
else:
output = avro.parse(text) if not bijoy else avro.parse(text, bijoy=True)

if output == text:
return _print_err('No changes in output.')
return _print_err("No changes in output.")

console.print(f'\n[bold green]Output[/bold green]\n {text}\n')
console.print(f"\n[bold green]Output[/bold green]\n {text}\n")

if copy_on_success:
pyclip.copy(text)
console.print('[bold yellow](copied to clipboard)[/bold yellow]\n')
console.print("[bold yellow](copied to clipboard)[/bold yellow]\n")


# usage: avro parse <text> [--bijoy] [--from-clip] [--copy]
@cli.command('parse', help='Parse a given text to Bangla / Bengali.')
@click.argument('text', required=False)
@click.option('--bijoy', is_flag=True, help='Use Bijoy Keyboard format for parsing.')
@click.option('--from-clip', is_flag=True, help='Parse text from clipboard.')
@click.option('--copy', is_flag=True, help='Copy the parsed text to clipboard.')
def _parse(text: str = '', bijoy: bool = False, from_clip: bool = False, copy: bool = False) -> None:
@cli.command("parse", help="Parse a given text to Bangla / Bengali.")
@click.argument("text", required=False)
@click.option("--bijoy", is_flag=True, help="Use Bijoy Keyboard format for parsing.")
@click.option("--from-clip", is_flag=True, help="Parse text from clipboard.")
@click.option("--copy", is_flag=True, help="Copy the parsed text to clipboard.")
def _parse(text: str = "", bijoy: bool = False, from_clip: bool = False, copy: bool = False) -> None:
_cli_action(
text,
bijoy=bijoy,
Expand All @@ -84,10 +84,10 @@ def _parse(text: str = '', bijoy: bool = False, from_clip: bool = False, copy: b


# usage: avro reverse <text> [--from-clip] [--copy]
@cli.command('reverse', help='Reverse a given text to English.')
@click.argument('text')
@click.option('--from-clip', is_flag=True, help='Reverse text from clipboard.')
@click.option('--copy', is_flag=True, help='Copy the reversed text to clipboard.')
@cli.command("reverse", help="Reverse a given text to English.")
@click.argument("text")
@click.option("--from-clip", is_flag=True, help="Reverse text from clipboard.")
@click.option("--copy", is_flag=True, help="Copy the reversed text to clipboard.")
def _reverse(text: str, from_clip: bool = False, copy: bool = False) -> None:
_cli_action(
text,
Expand Down
24 changes: 12 additions & 12 deletions avro/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
from .resources import DICT

# Shortcuts to vowels, constants, case-sensitives and numbers.
AVRO_VOWELS = set(DICT['avro']['vowel'])
AVRO_CONSONANTS = set(DICT['avro']['consonant'])
AVRO_CASESENSITIVES = set(DICT['avro']['casesensitive'])
AVRO_NUMBERS = set(DICT['avro']['number'])
AVRO_VOWELS = set(DICT["avro"]["vowel"])
AVRO_CONSONANTS = set(DICT["avro"]["consonant"])
AVRO_CASESENSITIVES = set(DICT["avro"]["casesensitive"])
AVRO_NUMBERS = set(DICT["avro"]["number"])

# Shortcuts to Bengali Svaravarna, Kar(s)
AVRO_SHORBORNO = set(DICT['avro']['shorborno'])
AVRO_KAR = set(DICT['avro']['kar'])
AVRO_IGNORE = set(DICT['avro']['ignore'])
AVRO_EXCEPTIONS = DICT['avro']['exceptions']
AVRO_SHORBORNO = set(DICT["avro"]["shorborno"])
AVRO_KAR = set(DICT["avro"]["kar"])
AVRO_IGNORE = set(DICT["avro"]["ignore"])
AVRO_EXCEPTIONS = DICT["avro"]["exceptions"]

# Shortcuts for conversion (e.g. for Bijoy Keyboard support).
BIJOY_MAP = DICT['bijoy']['mappings']
BIJOY_PREKAR = set(DICT['bijoy']['prekar'])
BIJOY_BANJONBORNO = set(DICT['bijoy']['banjonborno'])
BIJOY_EXCEPTIONS = DICT['bijoy']['exceptions']
BIJOY_MAP = DICT["bijoy"]["mappings"]
BIJOY_PREKAR = set(DICT["bijoy"]["prekar"])
BIJOY_BANJONBORNO = set(DICT["bijoy"]["banjonborno"])
BIJOY_EXCEPTIONS = DICT["bijoy"]["exceptions"]
Loading

0 comments on commit 9ca60b2

Please sign in to comment.