Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

test-pyinstaller-build:
name: Test pyinstaller
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install package and dev dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install pytest pyinstaller
- name: Unit tests
run: pytest -v --pyargs cmap.__pyinstaller

deploy:
name: Deploy
needs: test
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ dev = [
"pyqt6",
]

[project.entry-points."pyinstaller40"]
hook-dirs = "cmap.__pyinstaller:get_hook_dirs"
tests = "cmap.__pyinstaller:get_test_dirs"

[project.urls]
Homepage = "https://github.com/pyapp-kit/cmap"
Repository = "https://github.com/pyapp-kit/cmap"
Expand Down Expand Up @@ -139,6 +143,9 @@ filterwarnings = [
"ignore:datetime.datetime.utcfromtimestamp:DeprecationWarning",
"ignore::DeprecationWarning:docstring_parser",
"ignore:Pyarrow will become a required dependency of pandas",
"ignore::DeprecationWarning:Pyinstaller",
"ignore::DeprecationWarning:pkg_resources",
"ignore::DeprecationWarning:altgraph",
]

# https://mypy.readthedocs.io/en/stable/config_file.html
Expand Down
11 changes: 11 additions & 0 deletions src/cmap/__pyinstaller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from os.path import dirname

Check warning on line 1 in src/cmap/__pyinstaller/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/__init__.py#L1

Added line #L1 was not covered by tests

HERE = dirname(__file__)

Check warning on line 3 in src/cmap/__pyinstaller/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/__init__.py#L3

Added line #L3 was not covered by tests


def get_hook_dirs() -> list[str]:
return [HERE]

Check warning on line 7 in src/cmap/__pyinstaller/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/__init__.py#L6-L7

Added lines #L6 - L7 were not covered by tests


def get_test_dirs() -> list[str]:
return [HERE]

Check warning on line 11 in src/cmap/__pyinstaller/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/__init__.py#L10-L11

Added lines #L10 - L11 were not covered by tests
4 changes: 4 additions & 0 deletions src/cmap/__pyinstaller/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import os

Check warning on line 1 in src/cmap/__pyinstaller/conftest.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/conftest.py#L1

Added line #L1 was not covered by tests

os.environ["PYI_BUILDER_CLEANUP"] = "0"
from PyInstaller.utils.conftest import * # noqa

Check warning on line 4 in src/cmap/__pyinstaller/conftest.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/conftest.py#L3-L4

Added lines #L3 - L4 were not covered by tests
24 changes: 24 additions & 0 deletions src/cmap/__pyinstaller/hook-cmap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from PyInstaller.utils.hooks import collect_all

Check warning on line 1 in src/cmap/__pyinstaller/hook-cmap.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/hook-cmap.py#L1

Added line #L1 was not covered by tests

datas, binaries, hiddenimports = collect_all(

Check warning on line 3 in src/cmap/__pyinstaller/hook-cmap.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/hook-cmap.py#L3

Added line #L3 was not covered by tests
"cmap",
# include_datas=["data/"],
exclude_datas=["**/__pycache__/"],
# filter_submodules=lambda x: x.startswith("cmap.data"),
)
excludedimports = [

Check warning on line 9 in src/cmap/__pyinstaller/hook-cmap.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/hook-cmap.py#L9

Added line #L9 was not covered by tests
"bokeh",
"colorspacious",
"matplotlib",
"napari",
"numpy.typing",
"pydantic_core",
"pydantic",
"numba",
"pygfx",
"pyqtgraph",
"tkinter",
"typing_extensions",
"viscm",
"vispy",
]
9 changes: 9 additions & 0 deletions src/cmap/__pyinstaller/test_cmap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from typing import Any

Check warning on line 1 in src/cmap/__pyinstaller/test_cmap.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/test_cmap.py#L1

Added line #L1 was not covered by tests


def test_pyi_cmap_data(pyi_builder: Any) -> None:
pyi_builder.test_source("""

Check warning on line 5 in src/cmap/__pyinstaller/test_cmap.py

View check run for this annotation

Codecov / codecov/patch

src/cmap/__pyinstaller/test_cmap.py#L4-L5

Added lines #L4 - L5 were not covered by tests
import cmap
assert isinstance(cmap.Colormap('viridis'), cmap.Colormap)
assert isinstance(cmap.Colormap('crameri:acton'), cmap.Colormap)
""")
5 changes: 0 additions & 5 deletions src/cmap/_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@

import numpy as np

try:
from pydantic import model_serializer
except ImportError:
model_serializer = lambda x: x # noqa: E731

from . import _external

if TYPE_CHECKING:
Expand Down