Skip to content

Commit

Permalink
chore(spm): drop support for python 3.7 (#106)
Browse files Browse the repository at this point in the history
Reached end-of-life over a year ago and  no longer supported by our upcoming dependencies
  • Loading branch information
nfrasser authored Dec 13, 2024
1 parent 12cfde7 commit 15a653d
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 44 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ jobs:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.7", "3.13"]
python-version: ["3.8", "3.13"]
exclude:
# Latest macos runner does not support older Python versions
# https://github.com/actions/setup-python/issues/852
- os: macos-latest
python-version: "3.7"
python-version: "3.8"
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -100,10 +100,10 @@ jobs:
python -m pip install --upgrade pip wheel
python -m pip install --editable .[dev]
- name: Downgrade numpy
if: ${{ matrix.python-version == '3.7' }}
if: ${{ matrix.python-version == '3.8' }}
run: |
# test with older numpy version to ensure compatibility
python -m pip install numpy==1.15
python -m pip install numpy~=1.17.5
- name: Test with pytest
run: |
pytest -v --benchmark-disable -n auto
Expand All @@ -129,7 +129,7 @@ jobs:
platforms: arm64
- uses: pypa/[email protected]
env:
CIBW_SKIP: cp36-* pp*-win* pp*-macosx* *_i686
CIBW_SKIP: cp36-* cp37-* pp*-win* pp*-macosx* *_i686
CIBW_TEST_SKIP: "*-win_arm64"
CIBW_ARCHS_LINUX: "x86_64 aarch64"
CIBW_ARCHS_MACOS: "x86_64 arm64 universal2"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for full details.
### Prerequisites

- Git and Git LFS
- Python >= 3.7
- Python >= 3.8
- Miniconda3
- C compiler such as GCC or Clang

Expand Down
3 changes: 2 additions & 1 deletion cryosparc/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,20 @@
Generator,
Generic,
List,
Literal,
Mapping,
MutableMapping,
Optional,
Sequence,
Set,
SupportsIndex,
Tuple,
Type,
Union,
overload,
)

import numpy as n
from typing_extensions import Literal, SupportsIndex

from .column import Column
from .core import Data, DsetType, Stream
Expand Down
3 changes: 1 addition & 2 deletions cryosparc/dtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
"""

import json
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Type, Union
from typing import TYPE_CHECKING, Dict, List, Literal, Optional, Sequence, Tuple, Type, TypedDict, Union

import numpy as n
from typing_extensions import Literal, Sequence, TypedDict

from .core import Data, DsetType

Expand Down
4 changes: 1 addition & 3 deletions cryosparc/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
Definitions for various error classes raised by cryosparc-tools functions
"""

from typing import Any, List

from typing_extensions import TypedDict
from typing import Any, List, TypedDict

from .spec import Datafield, Datatype, SlotSpec

Expand Down
3 changes: 1 addition & 2 deletions cryosparc/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
from io import BytesIO
from pathlib import PurePath, PurePosixPath
from time import sleep, time
from typing import IO, TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Pattern, Union, overload
from typing import IO, TYPE_CHECKING, Any, Dict, Iterable, List, Literal, Optional, Pattern, Union, overload

import numpy as n
from typing_extensions import Literal

from .command import CommandError, make_json_request, make_request
from .dataset import DEFAULT_FORMAT, Dataset
Expand Down
9 changes: 2 additions & 7 deletions cryosparc/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
"""

from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Dict, Generic, List, Optional, Tuple, TypeVar, Union

from typing_extensions import Literal, TypedDict

if TYPE_CHECKING:
from typing_extensions import Self # not present in typing-extensions=3.7
from typing import Any, Dict, Generic, List, Literal, Optional, Tuple, TypedDict, TypeVar, Union

# Database document
D = TypeVar("D")
Expand Down Expand Up @@ -964,6 +959,6 @@ def doc(self) -> D:
return self._doc

@abstractmethod
def refresh(self) -> "Self":
def refresh(self):
# Must be implemented in subclasses
return self
17 changes: 15 additions & 2 deletions cryosparc/star.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,23 @@
"""

from pathlib import PurePath
from typing import IO, TYPE_CHECKING, Any, Callable, Dict, List, Mapping, Optional, Tuple, Type, Union, overload
from typing import (
IO,
TYPE_CHECKING,
Any,
Callable,
Dict,
List,
Literal,
Mapping,
Optional,
Tuple,
Type,
Union,
overload,
)

import numpy as n
from typing_extensions import Literal

if TYPE_CHECKING:
from numpy.typing import NDArray # type: ignore
Expand Down
15 changes: 7 additions & 8 deletions cryosparc/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
from pathlib import PurePath
from typing import (
IO,
TYPE_CHECKING,
Any,
AsyncGenerator,
AsyncIterable,
AsyncIterator,
BinaryIO,
Generator,
Iterable,
Iterator,
Optional,
Protocol,
Union,
)

from typing_extensions import Protocol

if TYPE_CHECKING:
from typing_extensions import Self # not present in typing-extensions=3.7
from typing_extensions import Self


class AsyncBinaryIO(Protocol):
Expand Down Expand Up @@ -93,7 +92,7 @@ async def read(self, n: Optional[int] = None):
out = []
if n is None or n < 0:
while True:
m = self._read1()
m = await self._read1()
if not m:
break
out.append(m)
Expand Down Expand Up @@ -153,8 +152,8 @@ async def from_async_iterator(cls, iterator: Union[AsyncIterator[bytes], AsyncGe
return await cls.from_async_stream(AsyncBinaryIteratorIO(iterator))

@abstractmethod
def stream(self) -> Generator[bytes, None, None]: ...
def stream(self) -> Iterable[bytes]: ...

async def astream(self):
async def astream(self) -> AsyncIterable[bytes]:
for chunk in self.stream():
yield chunk
11 changes: 2 additions & 9 deletions cryosparc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,7 @@ def default_rng(seed=None) -> "n.random.Generator":
Returns:
numpy.random.Generator: Random number generator
"""
try:
return n.random.default_rng(seed)
except AttributeError:
return n.random.RandomState(seed) # type: ignore
return n.random.default_rng(seed)


def random_integers(
Expand All @@ -337,11 +334,7 @@ def random_integers(
Returns:
NDArray: Numpy array of randomly-generated integers.
"""
try:
f = rng.integers
except AttributeError:
f = rng.randint # type: ignore
return f(low=low, high=high, size=size, dtype=dtype) # type: ignore
return rng.integers(low=low, high=high, size=size, dtype=dtype) # type: ignore


def print_table(headings: List[str], rows: List[List[str]]):
Expand Down
2 changes: 1 addition & 1 deletion docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Source code is [available on GitHub](https://github.com/cryoem-uoft/cryosparc-to

## Pre-requisites

- [Python ≥ 3.7](https://www.python.org/downloads/)
- [Python ≥ 3.8](https://www.python.org/downloads/)
- [CryoSPARC ≥ v4.1](https://cryosparc.com/download)

CryoSPARC installation must be accessible via one of the following methods:
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "cryosparc-tools"
version = "4.6.1"
description = "Toolkit for interfacing with CryoSPARC"
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.8"
authors = [
{ name = "Structura Biotechnology Inc.", email = "[email protected]" },
]
Expand All @@ -20,7 +20,10 @@ classifiers = [
"Topic :: Software Development :: Libraries",
]
license = { file = "LICENSE" }
dependencies = ["numpy >= 1.15, < 3.0", "typing-extensions >= 3.7"]
dependencies = [
"numpy >= 1.17, < 3.0",
"typing-extensions >= 4.0",
]

[project.optional-dependencies]
dev = [
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def test_column_aggregation(t20s_dset):
assert not isinstance(n.mean(t20s_dset["uid"]), n.ndarray)


@pytest.mark.skipif(n.__version__.startswith("1.15."), reason="works with newer numpy versions, use case is limited")
@pytest.mark.skipif(n.__version__.startswith("1.17."), reason="works with newer numpy versions, use case is limited")
def test_row_array_type(t20s_dset):
rowarr = n.array(t20s_dset.rows())
assert isinstance(rowarr[0], Row)
Expand Down

0 comments on commit 15a653d

Please sign in to comment.