Skip to content

Commit

Permalink
Converted Image Titler to Poetry (#99)
Browse files Browse the repository at this point in the history
* Created poetry file

* Fixed bug with latest version of pillow

* Removing junk

* Added scripts to project file

* Removed junk files

* Fixed script lines in project

* Fixed up version code

* Added version to init

* Life is good

* Reworked to the workflows

* Restricting latest version to Python 3.11 and up

* Added python version table
  • Loading branch information
jrg94 authored Dec 28, 2023
1 parent c7488fc commit fe6447b
Show file tree
Hide file tree
Showing 30 changed files with 799 additions and 80 deletions.
36 changes: 20 additions & 16 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
name: Deploy
name: Poetry Deployment

on:
release:
types: [published]

jobs:
deploy:
all:

runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.8"]
poetry-version: ["1.7"]
os: ["ubuntu-latest"]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Run Poetry Image
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Configure PyPI
run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }}

- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
run: poetry publish --build --no-interaction
29 changes: 18 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
name: PyTest
name: Poetry Testing

on:
pull_request:
branches: [main]

jobs:
test:
all:

runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.11", "3.12"]
poetry-version: ["1.4"]
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run Poetry Image
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Install Dependencies
run: poetry install

- name: PyTest
run: python -m pytest
run: poetry run pytest
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,14 @@ Here's a description of all the option used in the samples above.
| --tier, -r | Choose between "free" (silver) or "premium" (gold) | Adds a border color to the title |
| --title, -t | Any string | Overrides the automatic title feature |
| --no_title, -n | | Do not add title |

## Python Version Compatibility

As this utility has grown and changed, it has also changed its
support for different versions of Python.

| Python | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 |
| ---------------------- | ---- | ---- | ---- | --- | --- |
| image-titler >= 2.5 | yes | yes | | | |
| image-titler 1.8 - 2.5 | | | yes | yes | yes |
| image-titler <= 1.8 | | | | | |
7 changes: 6 additions & 1 deletion imagetitler/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
__version__ = "2.4.0"
import tomllib

with open("pyproject.toml", "rb") as f:
_META = tomllib.load(f)

__version__ = _META["tool"]["poetry"]["version"]
2 changes: 1 addition & 1 deletion imagetitler/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def _get_appropriate_font_size(**kwargs) -> ImageFont:
font = font if font else DEFAULT_FONT
title = kwargs.get(KEY_TITLE)
font_size = 12
while ImageFont.truetype(font, font_size).getsize(title)[1] < bar_height - 10:
while ImageFont.truetype(font, font_size).getbbox(title)[3] < bar_height - 10:
font_size += 1
return ImageFont.truetype(font, font_size)

Expand Down
713 changes: 713 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.poetry]
name = "image-titler"
version = "2.5.0"
description = "An image processing utility which provides options for generating thumbnails for various social media platforms."
authors = ["Jeremy Grifski <[email protected]>"]
license = "GPL-3.0-or-later"
readme = "README.md"
repository = "https://github.com/TheRenegadeCoder/image-titler"
packages = [{include = "imagetitler"}]

[tool.poetry.dependencies]
python = "^3.11"
titlecase = "^2.0"
pillow = "^10.0.0"
pathvalidate = "^2.0"
piexif = "^1.0"
matplotlib = "^3.0"

[tool.poetry.group.test.dependencies]
pytest = "*"
pytest-cov = "*"

[tool.poetry.scripts]
image-titler = "scripts.cli:main"
image_titler = "scripts.cli:main"
image-titler-gui = "scripts.gui:main"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

Binary file modified samples/v2.4.0/23-tech-topics-to-tackle-v2-4-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/v2.4.0/columbus-drivers-are-among-the-worst-v2-4-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/v2.4.0/hello-world-in-matlab-v2-4-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/v2.4.0/the-art-of-simplification-v2-4-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified samples/v2.4.0/the-guide-to-causing-mass-panic-v2-4-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/v2.5.0/hello-world-in-c-v2-5-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/v2.5.0/hello-world-in-matlab-v2-5-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added samples/v2.5.0/minimalism-v2-5-0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 0 additions & 43 deletions setup.py

This file was deleted.

Empty file added tests/__init__.py
Empty file.

0 comments on commit fe6447b

Please sign in to comment.