From 311ed1473a9763b1dfd6180881bc407908412d74 Mon Sep 17 00:00:00 2001 From: Alexander Beedie Date: Tue, 23 Jan 2024 14:26:05 +0000 Subject: [PATCH 1/4] feat: extend support to python 3.8+ --- .github/workflows/CI.yml | 6 +++--- .gitignore | 2 ++ README.md | 4 ++-- pyproject.toml | 6 +++--- python/fastexcel/__init__.py | 2 ++ python/fastexcel/_fastexcel.pyi | 2 ++ python/tests/benchmarks/memory.py | 18 ++++++++++-------- python/tests/test_durations.py | 3 ++- python/tests/test_empty.py | 1 - python/tests/test_fastexcel.py | 1 - 10 files changed, 26 insertions(+), 19 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9cc7b21..843ce3e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -12,10 +12,10 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - - name: Set up Python python3.10 + - name: Set up Python uses: actions/setup-python@v5 with: python-version: "${{ matrix.python-version }}" @@ -49,7 +49,7 @@ jobs: runs-on: macos-latest strategy: matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - name: build (fast) diff --git a/.gitignore b/.gitignore index 3eba138..9ed43c0 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,9 @@ __pycache__ *.pyc *.so *.dat + .python-version .venv docs +.idea .benchmarks diff --git a/README.md b/README.md index de1d519..7521149 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Docs available [here](https://fastexcel.toucantoco.dev/). ### Prerequisites -Python>=3.10 and a recent Rust toolchain must be installed on your machine. `cargo` must be available in your `PATH`. +Python>=3.8 and a recent Rust toolchain must be installed on your machine. `cargo` must be available in your `PATH`. ### First setup @@ -31,7 +31,7 @@ This will compile the wheel (in debug mode) and install it. It will then be avai ### Installing the project in prod mode -This is required for profiling, as dev mdoe wheels are much slower. `make prod-install` will compile the project +This is required for profiling, as dev mode wheels are much slower. `make prod-install` will compile the project in release mode and install it in your local venv, overriding previous dev installs. ### Linting and formatting diff --git a/pyproject.toml b/pyproject.toml index 7cb65ce..0296c8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "fastexcel" -requires-python = ">=3.10" +requires-python = ">=3.8" classifiers = [ "Programming Language :: Rust", "Programming Language :: Python :: Implementation :: CPython", @@ -27,7 +27,7 @@ python-source = "python" module-name = "fastexcel._fastexcel" [tool.mypy] -python_version = "3.10" +python_version = "3.8" follow_imports = "silent" ignore_missing_imports = true # A few custom options @@ -45,4 +45,4 @@ testpaths = [ line-length = 100 # Enable Pyflakes `E` and `F` codes by default. -select = ["E", "F", "Q"] +select = ["E", "F", "I", "Q", "FA102"] diff --git a/python/fastexcel/__init__.py b/python/fastexcel/__init__.py index f6fbcb2..fa42fb6 100644 --- a/python/fastexcel/__init__.py +++ b/python/fastexcel/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import TYPE_CHECKING if TYPE_CHECKING: diff --git a/python/fastexcel/_fastexcel.pyi b/python/fastexcel/_fastexcel.pyi index 1107d6c..b9fd5eb 100644 --- a/python/fastexcel/_fastexcel.pyi +++ b/python/fastexcel/_fastexcel.pyi @@ -1,3 +1,5 @@ +from __future__ import annotations + import pyarrow as pa class _ExcelSheet: diff --git a/python/tests/benchmarks/memory.py b/python/tests/benchmarks/memory.py index 0692de8..a01e806 100644 --- a/python/tests/benchmarks/memory.py +++ b/python/tests/benchmarks/memory.py @@ -1,5 +1,6 @@ -from enum import Enum import argparse +from enum import Enum + from readers import fastexcel_read, pyxl_read, xlrd_read @@ -18,13 +19,14 @@ def get_args() -> argparse.Namespace: def main(): args = get_args() - match args.engine: - case Engine.FASTEXCEL: - fastexcel_read(args.file) - case Engine.XLRD: - xlrd_read(args.file) - case Engine.OPENPYXL: - pyxl_read(args.file) + engine = args.engine + + if engine == Engine.FASTEXCEL: + fastexcel_read(args.file) + elif engine == Engine.XLRD: + xlrd_read(args.file) + elif engine == Engine.OPENPYXL: + pyxl_read(args.file) if __name__ == "__main__": diff --git a/python/tests/test_durations.py b/python/tests/test_durations.py index e3b3ef3..1b18c0f 100644 --- a/python/tests/test_durations.py +++ b/python/tests/test_durations.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from datetime import date, datetime, timedelta import fastexcel @@ -11,7 +13,6 @@ from polars.datatypes import PolarsDataType from polars.datatypes import Utf8 as PlUtf8 from polars.testing import assert_frame_equal as pl_assert_frame_equal - from utils import path_for_fixture diff --git a/python/tests/test_empty.py b/python/tests/test_empty.py index 26c80fa..1e2f4fb 100644 --- a/python/tests/test_empty.py +++ b/python/tests/test_empty.py @@ -1,6 +1,5 @@ import fastexcel import pytest - from utils import path_for_fixture diff --git a/python/tests/test_fastexcel.py b/python/tests/test_fastexcel.py index c63ccdb..a97e5e8 100644 --- a/python/tests/test_fastexcel.py +++ b/python/tests/test_fastexcel.py @@ -4,7 +4,6 @@ import pytest from pandas.testing import assert_frame_equal as pd_assert_frame_equal from polars.testing import assert_frame_equal as pl_assert_frame_equal - from utils import path_for_fixture From 98c45922ef72a4d86f374dc45dbe68911e65152a Mon Sep 17 00:00:00 2001 From: Alexander Beedie Date: Wed, 24 Jan 2024 14:34:07 +0000 Subject: [PATCH 2/4] update release workflow --- .github/workflows/release.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d654431..d4e51ca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - name: build (release) @@ -30,7 +30,7 @@ jobs: runs-on: macos-latest strategy: matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - name: build (release) @@ -51,6 +51,16 @@ jobs: runs-on: ubuntu-latest needs: [linux, macos] steps: + - name: Download Linux 3.8 wheels + uses: actions/download-artifact@v4 + with: + name: "wheels-linux-python-3.8" + path: wheels-linux + - name: Download Linux 3.9 wheels + uses: actions/download-artifact@v4 + with: + name: "wheels-linux-python-3.9" + path: wheels-linux - name: Download Linux 3.10 wheels uses: actions/download-artifact@v4 with: @@ -67,6 +77,16 @@ jobs: name: "wheels-linux-python-3.12" path: wheels-linux + - name: Download MacOS 3.8 wheels + uses: actions/download-artifact@v4 + with: + name: "wheels-macos-python-3.8" + path: wheels-macos + - name: Download MacOS 3.9 wheels + uses: actions/download-artifact@v4 + with: + name: "wheels-macos-python-3.9" + path: wheels-macos - name: Download MacOS 3.10 wheels uses: actions/download-artifact@v4 with: @@ -98,3 +118,4 @@ jobs: files: | wheels-linux/*.whl wheels-macos/*.whl +8 From 9458ab5cfa7a2ea369349090a7b4d235582259d4 Mon Sep 17 00:00:00 2001 From: Alexander Beedie Date: Wed, 24 Jan 2024 14:34:45 +0000 Subject: [PATCH 3/4] don't forget 3.8 for macos --- .github/workflows/CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 843ce3e..0acd019 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -49,7 +49,7 @@ jobs: runs-on: macos-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - name: build (fast) From 9c7e93e0b0e93232072abbda19ee6aa361384a4c Mon Sep 17 00:00:00 2001 From: Luka Peschke Date: Wed, 24 Jan 2024 15:48:27 +0100 Subject: [PATCH 4/4] Update .github/workflows/release.yml --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d4e51ca..81f6492 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -118,4 +118,3 @@ jobs: files: | wheels-linux/*.whl wheels-macos/*.whl -8