From eaee07ca2d32031fd6ee1ef9286c91f08f6f0a20 Mon Sep 17 00:00:00 2001 From: Yurij Mikhalevich Date: Sat, 30 Nov 2024 14:49:32 +0400 Subject: [PATCH] BREAKING CHANGE: drop Python 3.9 support because some libraries, like the latest numpy don't support it anymore (#151) --- .github/workflows/release.yaml | 8 +++---- .github/workflows/validate.yaml | 8 ++----- poetry.lock | 21 ++++++++++--------- pyproject.toml | 2 +- rclip/utils/helpers.py | 10 +-------- release-utils/appimage/appimage-builder.yml | 16 +++++++------- .../appimage/appimage_after_bundle.sh | 14 ++++++------- 7 files changed, 34 insertions(+), 45 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5d1c7802..194c463b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.10 - name: Install dependencies run: | python -m pip install --upgrade pip @@ -52,7 +52,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.10 - name: Install dependencies run: | python -m pip install --upgrade pip @@ -81,7 +81,7 @@ jobs: echo "${{ secrets.LAUNCHPAD_CREDENTIALS }}" > ~/.local/share/snapcraft/provider/launchpad/credentials - uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.10 - name: Install dependencies run: | python -m pip install --upgrade pip @@ -152,7 +152,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.10 - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/.github/workflows/validate.yaml b/.github/workflows/validate.yaml index 79a6aae0..77e0e91d 100644 --- a/.github/workflows/validate.yaml +++ b/.github/workflows/validate.yaml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: '3.10' - name: Set up Node.js for pyright uses: actions/setup-node@v4 with: @@ -31,15 +31,11 @@ jobs: test: strategy: matrix: - python: ['3.9', '3.10', '3.11', '3.12'] + python: ['3.10', '3.11', '3.12'] # macos-13 is amd64, macos-14 is arm64 # skipping macos-13 here because newer versions of torch aren't being built for amd64 macOS anymore # the brew builds for amd64 macOS are being validated during brew release os: [ubuntu-22.04, macos-14, windows-2022] - exclude: - # github's setup-python action can't install Python 3.9 on macos-14 - - python: '3.9' - os: macos-14 runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 diff --git a/poetry.lock b/poetry.lock index beb86d43..6bf589f7 100644 --- a/poetry.lock +++ b/poetry.lock @@ -399,20 +399,21 @@ tests = ["pytest (>=4.6)"] [[package]] name = "networkx" -version = "3.2.1" +version = "3.4.2" description = "Python package for creating and manipulating graphs and networks" optional = false -python-versions = ">=3.9" +python-versions = ">=3.10" files = [ - {file = "networkx-3.2.1-py3-none-any.whl", hash = "sha256:f18c69adc97877c42332c170849c96cefa91881c99a7cb3e95b7c659ebdc1ec2"}, - {file = "networkx-3.2.1.tar.gz", hash = "sha256:9f1bb5cf3409bf324e0a722c20bdb4c20ee39bf1c30ce8ae499c8502b0b5e0c6"}, + {file = "networkx-3.4.2-py3-none-any.whl", hash = "sha256:df5d4365b724cf81b8c6a7312509d0c22386097011ad1abe274afd5e9d3bbc5f"}, + {file = "networkx-3.4.2.tar.gz", hash = "sha256:307c3669428c5362aab27c8a1260aa8f47c4e91d3891f48be0141738d8d053e1"}, ] [package.extras] -default = ["matplotlib (>=3.5)", "numpy (>=1.22)", "pandas (>=1.4)", "scipy (>=1.9,!=1.11.0,!=1.11.1)"] -developer = ["changelist (==0.4)", "mypy (>=1.1)", "pre-commit (>=3.2)", "rtoml"] -doc = ["nb2plots (>=0.7)", "nbconvert (<7.9)", "numpydoc (>=1.6)", "pillow (>=9.4)", "pydata-sphinx-theme (>=0.14)", "sphinx (>=7)", "sphinx-gallery (>=0.14)", "texext (>=0.6.7)"] -extra = ["lxml (>=4.6)", "pydot (>=1.4.2)", "pygraphviz (>=1.11)", "sympy (>=1.10)"] +default = ["matplotlib (>=3.7)", "numpy (>=1.24)", "pandas (>=2.0)", "scipy (>=1.10,!=1.11.0,!=1.11.1)"] +developer = ["changelist (==0.5)", "mypy (>=1.1)", "pre-commit (>=3.2)", "rtoml"] +doc = ["intersphinx-registry", "myst-nb (>=1.1)", "numpydoc (>=1.8.0)", "pillow (>=9.4)", "pydata-sphinx-theme (>=0.15)", "sphinx (>=7.3)", "sphinx-gallery (>=0.16)", "texext (>=0.6.7)"] +example = ["cairocffi (>=1.7)", "contextily (>=1.6)", "igraph (>=0.11)", "momepy (>=0.7.2)", "osmnx (>=1.9)", "scikit-learn (>=1.5)", "seaborn (>=0.13)"] +extra = ["lxml (>=4.6)", "pydot (>=3.0.1)", "pygraphviz (>=1.14)", "sympy (>=1.10)"] test = ["pytest (>=7.2)", "pytest-cov (>=4.0)"] [[package]] @@ -1478,5 +1479,5 @@ files = [ [metadata] lock-version = "2.0" -python-versions = ">=3.9 <3.13" -content-hash = "2e17295ff878ac84420c34d40b8bf111e304084d05ba7aadede9c4c6bf983a16" +python-versions = ">=3.10 <3.13" +content-hash = "011c39a732b2bd81d1a9600045ecd25e41b226454b684a3571519bb1059333d4" diff --git a/pyproject.toml b/pyproject.toml index c967aaec..59e1f77e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ classifiers = [ ] [tool.poetry.dependencies] -python = ">=3.9 <3.13" +python = ">=3.10 <3.13" numpy = "^1.26.4" open_clip_torch = "^2.24.0" pillow = "^10.3.0" diff --git a/rclip/utils/helpers.py b/rclip/utils/helpers.py index 70cdd51a..debfd952 100644 --- a/rclip/utils/helpers.py +++ b/rclip/utils/helpers.py @@ -175,14 +175,6 @@ def is_mps_available() -> bool: return False -def remove_prefix(string: str, prefix: str) -> str: - ''' - Removes prefix from a string (if present) and returns a new string without a prefix - TODO(yurij): replace with str.removeprefix once updated to Python 3.9+ - ''' - return string[len(prefix):] if string.startswith(prefix) else string - - # See: https://meta.wikimedia.org/wiki/User-Agent_policy def download_image(url: str) -> Image.Image: headers = {'User-agent': 'rclip - (https://github.com/yurijmikhalevich/rclip)'} @@ -205,7 +197,7 @@ def read_raw_image_file(path: str): def read_image(query: str) -> Image.Image: - path = remove_prefix(query, 'file://') + path = str.removeprefix(query, 'file://') try: file_ext = get_file_extension(path) if file_ext in IMAGE_RAW_EXT: diff --git a/release-utils/appimage/appimage-builder.yml b/release-utils/appimage/appimage-builder.yml index 2f634315..839c5af4 100644 --- a/release-utils/appimage/appimage-builder.yml +++ b/release-utils/appimage/appimage-builder.yml @@ -20,7 +20,7 @@ AppDir: icon: rclip version: !ENV ${APP_VERSION} # Set the python executable as entry point - exec: usr/bin/python3.9 + exec: usr/bin/python3.10 # Set the application main script path as argument. Use '$@' to forward CLI parameters exec_args: "${APPDIR}/usr/bin/rclip $@" @@ -36,11 +36,11 @@ AppDir: include: - libffi7 - - libpython3.9-minimal - - libpython3.9-stdlib - - python3.9 - - python3.9-distutils - - python3.9-minimal + - libpython3.10-minimal + - libpython3.10-stdlib + - python3.10 + - python3.10-distutils + - python3.10-minimal - python3-pip exclude: [] @@ -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.9/site-packages' + PYTHONPATH: '${APPDIR}/usr/src:${APPDIR}/usr/lib/python3.10/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.9/site-packages/certifi/cacert.pem' + SSL_CERT_FILE: '${APPDIR}/usr/lib/python3.10/site-packages/certifi/cacert.pem' test: fedora: diff --git a/release-utils/appimage/appimage_after_bundle.sh b/release-utils/appimage/appimage_after_bundle.sh index 32daff06..fd57dbe7 100755 --- a/release-utils/appimage/appimage_after_bundle.sh +++ b/release-utils/appimage/appimage_after_bundle.sh @@ -3,11 +3,11 @@ set -e PYTHONHOME=$APPDIR/usr \ -PYTHONPATH=$APPDIR/usr/lib/python3.9/site-packages:$APPDIR/usr/lib/python3.9 \ +PYTHONPATH=$APPDIR/usr/lib/python3.10/site-packages:$APPDIR/usr/lib/python3.10 \ LD_LIBRARY_PATH=$APPDIR/usr/lib/x86_64-linux-gnu \ -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 +python3.10 -m pip install poetry==1.8.4 && +python3.10 -m pip install --upgrade --isolated --no-input --ignore-installed --prefix="$APPDIR/usr" certifi setuptools wheel && +python3.10 -m poetry build && +python3.10 -m poetry export --output requirements.txt && +python3.10 -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.10 -m pip install --no-dependencies --isolated --no-input --prefix="$APPDIR/usr" dist/*.whl