From 44a010f9044eee0f3d6bbaf978cd9b84740ac10c Mon Sep 17 00:00:00 2001 From: laggykiller Date: Thu, 21 Mar 2024 20:47:32 +0800 Subject: [PATCH] Add optional dependencies --- .github/workflows/build.yml | 3 +-- .github/workflows/check_and_fix.yml | 12 ++++-------- README.md | 5 +++-- pyproject.toml | 20 ++++++++++++++++++-- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fcd7bc4..76f1054 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,8 +26,7 @@ jobs: - name: Test sdist run: | - python -m pip install dist/apngasm_python-*.tar.gz - pip install pytest Pillow numpy && + python -m pip install dist/apngasm_python-*.tar.gz[full,test] pytest - uses: actions/upload-artifact@v3 diff --git a/.github/workflows/check_and_fix.yml b/.github/workflows/check_and_fix.yml index 01c8fc5..555a2a4 100644 --- a/.github/workflows/check_and_fix.yml +++ b/.github/workflows/check_and_fix.yml @@ -22,18 +22,14 @@ jobs: - uses: actions/setup-python@v5 with: python-version: '3.9' - - name: Install dependency - run: | - pip install build ruff mypy isort Pillow numpy pytest types-Pillow - pip install git+https://github.com/wjakob/nanobind.git + - name: Install test + run: pip install .[full,test,lint] - name: Ruff check run: ruff check - - name: Install test - run: pip install . - - name: mypy - run: mypy - name: ruff format run: ruff format + - name: mypy + run: mypy - name: isort run: isort . - name: nanobind stubgen diff --git a/README.md b/README.md index a502bd9..932ee71 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,10 @@ Documentations: https://apngasm-python.readthedocs.io/en/latest/ pip install apngasm-python ``` -Optionally, you can also install `Pillow` and `numpy` +`Pillow` and `numpy` are optional dependencies. Without them, +some functions are not usable. To also install them: ``` -pip install Pillow numpy +pip install apngasm-python[full] ``` ## Example usage diff --git a/pyproject.toml b/pyproject.toml index 8cd7ab5..2c31bfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,12 +15,28 @@ Repository = "https://github.com/laggykiller/apngasm-python" Documentation = "https://apngasm-python.readthedocs.io/en/latest/" Tracker = "https://github.com/laggykiller/apngasm-python/issues" +[project.optional-dependencies] +full = [ + "Pillow", + "numpy", +] + +test = [ + "pytest", +] + +lint = [ + "ruff", + "mypy", + "isort", + "types-Pillow", +] + [build-system] # How pip and other frontends should build this project requires = [ "py-build-cmake==0.2.0a12", "nanobind @ git+https://github.com/wjakob/nanobind.git", - "conan>=2.0", - "wheel" + "conan>=2.0" ] build-backend = "py_build_cmake.build"