Skip to content

Commit

Permalink
chore(build): enable Python 3.12, drop Python 3.8, update deps (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
yurijmikhalevich authored Apr 9, 2024
1 parent fb6c5d5 commit ced1e81
Show file tree
Hide file tree
Showing 11 changed files with 708 additions and 499 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -52,7 +52,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
echo "${{ secrets.LAUNCHPAD_CREDENTIALS }}" > ~/.local/share/snapcraft/provider/launchpad/credentials
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Set up Node.js for pyright
uses: actions/setup-node@v3
with:
Expand All @@ -31,7 +31,7 @@ jobs:
test:
strategy:
matrix:
python: ['3.8', '3.9', '3.10', '3.11']
python: ['3.9', '3.10', '3.11', '3.12']
os: [ubuntu-22.04, macos-13]
runs-on: ${{ matrix.os }}
steps:
Expand Down
22 changes: 0 additions & 22 deletions Dockerfile

This file was deleted.

1,105 changes: 670 additions & 435 deletions poetry.lock

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rclip"
version = "1.7.26"
version = "1.7.27a3"
description = "AI-Powered Command-Line Photo Search Tool"
authors = ["Yurij Mikhalevich <[email protected]>"]
license = "MIT"
Expand All @@ -18,17 +18,17 @@ classifiers = [
]

[tool.poetry.dependencies]
python = ">=3.8 <3.12"
open_clip_torch = "^2.20.0"
pillow = "^10.0.0"
python = ">=3.9 <3.13"
open_clip_torch = "^2.24.0"
pillow = "^10.3.0"
requests = "~=2.26"
torch = [
{ version = "==2.0.1", source = "pypi", markers = "sys_platform != 'linux' or platform_machine == 'aarch64'" },
{ version = "==2.0.1+cpu", source = "pytorch-cpu", markers = "sys_platform == 'linux' and platform_machine != 'aarch64'" }
{ version = "==2.2.2", source = "pypi", markers = "sys_platform != 'linux' or platform_machine == 'aarch64'" },
{ version = "==2.2.2+cpu", source = "pytorch-cpu", markers = "sys_platform == 'linux' and platform_machine != 'aarch64'" }
]
torchvision = [
{ version = "==0.15.2", source = "pypi", markers = "sys_platform != 'linux' or platform_machine == 'aarch64'" },
{ version = "==0.15.2+cpu", source = "pytorch-cpu", markers = "sys_platform == 'linux' and platform_machine != 'aarch64'" }
{ version = "==0.17.2", source = "pypi", markers = "sys_platform != 'linux' or platform_machine == 'aarch64'" },
{ version = "==0.17.2+cpu", source = "pytorch-cpu", markers = "sys_platform == 'linux' and platform_machine != 'aarch64'" }
]
tqdm = "^4.65.0"

Expand All @@ -47,7 +47,7 @@ build-backend = "poetry.core.masonry.api"

[[tool.poetry.source]]
name = "pypi"
priority = "default"
priority = "primary"

[[tool.poetry.source]]
name = "pytorch-cpu"
Expand Down
2 changes: 1 addition & 1 deletion rclip/utils/preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def preview(filepath: str, img_height_px: int):
width_px, height_px = img.width, img.height
else:
width_px, height_px = int(img_height_px * img.width / img.height), img_height_px
img = img.resize((width_px, height_px), Image.LANCZOS)
img = img.resize((width_px, height_px), Image.LANCZOS) # type: ignore
buffer = BytesIO()
img.convert('RGB').save(buffer, format='JPEG')
img_bytes = buffer.getvalue()
Expand Down
16 changes: 8 additions & 8 deletions release-utils/appimage/appimage-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ AppDir:
icon: rclip
version: !ENV ${APP_VERSION}
# Set the python executable as entry point
exec: usr/bin/python3.8
exec: usr/bin/python3.9
# Set the application main script path as argument. Use '$@' to forward CLI parameters
exec_args: "${APPDIR}/usr/bin/rclip $@"

Expand All @@ -36,11 +36,11 @@ AppDir:

include:
- libffi7
- libpython3.8-minimal
- libpython3.8-stdlib
- python3.8
- python3.8-distutils
- python3.8-minimal
- libpython3.9-minimal
- libpython3.9-stdlib
- python3.9
- python3.9-distutils
- python3.9-minimal
- python3-pip
exclude: []

Expand All @@ -54,9 +54,9 @@ AppDir:
PYTHONHOME: '${APPDIR}/usr'
# Path to the site-packages dir or other modules dirs
# See https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH
PYTHONPATH: '${APPDIR}/usr/src:${APPDIR}/usr/lib/python3.8/site-packages'
PYTHONPATH: '${APPDIR}/usr/src:${APPDIR}/usr/lib/python3.9/site-packages'
# SSL Certificates are placed in a different location for every system therefore we ship our own copy
SSL_CERT_FILE: '${APPDIR}/usr/lib/python3.8/site-packages/certifi/cacert.pem'
SSL_CERT_FILE: '${APPDIR}/usr/lib/python3.9/site-packages/certifi/cacert.pem'

test:
fedora:
Expand Down
14 changes: 7 additions & 7 deletions release-utils/appimage/appimage_after_bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
set -e

PYTHONHOME=$APPDIR/usr \
PYTHONPATH=$APPDIR/usr/lib/python3.8/site-packages:$APPDIR/usr/lib/python3.8 \
PYTHONPATH=$APPDIR/usr/lib/python3.9/site-packages:$APPDIR/usr/lib/python3.9 \
LD_LIBRARY_PATH=$APPDIR/usr/lib/x86_64-linux-gnu \
python3.8 -m pip install poetry==1.7.1 &&
python3.8 -m pip install --upgrade --isolated --no-input --ignore-installed --prefix="$APPDIR/usr" certifi setuptools wheel &&
python3.8 -m poetry build &&
python3.8 -m poetry export --output requirements.txt &&
python3.8 -m pip install --extra-index-url https://download.pytorch.org/whl/cpu --upgrade --isolated --no-input --ignore-installed --prefix="$APPDIR/usr" -r requirements.txt &&
python3.8 -m pip install --no-dependencies --isolated --no-input --prefix="$APPDIR/usr" dist/*.whl
python3.9 -m pip install poetry==1.8.2 &&
python3.9 -m pip install --upgrade --isolated --no-input --ignore-installed --prefix="$APPDIR/usr" certifi setuptools wheel &&
python3.9 -m poetry build &&
python3.9 -m poetry export --output requirements.txt &&
python3.9 -m pip install --extra-index-url https://download.pytorch.org/whl/cpu --upgrade --isolated --no-input --ignore-installed --prefix="$APPDIR/usr" -r requirements.txt &&
python3.9 -m pip install --no-dependencies --isolated --no-input --prefix="$APPDIR/usr" dist/*.whl
4 changes: 2 additions & 2 deletions release-utils/homebrew/generate_formula.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
depends_on "numpy"
depends_on "pillow"
depends_on "python-certifi"
depends_on "python@3.11"
depends_on "python@3.12"
depends_on "pytorch"
depends_on "sentencepiece"
depends_on "torchvision"
Expand All @@ -32,7 +32,7 @@ def install
virtualenv_install_with_resources
# link dependent virtualenvs to this one
site_packages = Language::Python.site_packages("python3.11")
site_packages = Language::Python.site_packages("python3.12")
paths = %w[pytorch torchvision].map do |package_name|
package = Formula[package_name].opt_libexec
package/site_packages
Expand Down
12 changes: 4 additions & 8 deletions snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,16 @@ description: |
For a detailed demonstration, watch the video: https://www.youtube.com/watch?v=tAJHXOkHidw.
You can use another image as a query by passing a file path or even an URL to the image file to **rclip** and combine multiple queries. Check out the project's README on GitHub for more usage examples: https://github.com/yurijmikhalevich/rclip#readme.
version: 1.7.26
version: 1.7.27a3
website: https://github.com/yurijmikhalevich/rclip
contact: [email protected]
passthrough:
license: MIT

grade: stable
confinement: strict
base: core20
architectures:
- build-on: amd64
run-on: amd64
- build-on: arm64
run-on: arm64
base: core22
architectures: [amd64, arm64]

apps:
rclip:
Expand All @@ -33,7 +29,7 @@ apps:
parts:
rclip:
plugin: python
source: ./snap/local/rclip-1.7.26.tar.gz
source: ./snap/local/rclip-1.7.27a3.tar.gz
build-packages:
- python3-pip
build-environment:
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
File "./non-existing-file.jpg" not found. Check if you have typos in the filename.
File "<test_images_dir>/non-existing-file.jpg" not found. Check if you have typos in the filename.

0 comments on commit ced1e81

Please sign in to comment.