Skip to content

Commit

Permalink
Fix/numpy2 (#37)
Browse files Browse the repository at this point in the history
* fix: install for numpy<2
* fix: code style issues with Black
* ci: update versions
* ci: add setuptools to tox
* style: flake8 compatibility
* ci: remove macos python3.7
* ci: updated action versions
* tests: use pip install
  • Loading branch information
glichtner authored Oct 2, 2024
1 parent b5d9c03 commit 79fc62c
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:

steps:
- name: Check out Git repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: 3.9

Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
exclude:
- os: macos-latest
python-version: "3.7"


steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox and dependencies
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/wheels-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/cibuildwheel@v2.10.2
uses: pypa/cibuildwheel@v2.21.1

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
path: dist/*.tar.gz

Expand All @@ -45,7 +45,7 @@ jobs:
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
Expand All @@ -57,7 +57,7 @@ jobs:
artifacts: "dist/*.whl,dist/*.tar.gz"
token: ${{ secrets.GITHUB_TOKEN }}

- uses: pypa/gh-action-pypi-publish@v1.5.0
- uses: pypa/gh-action-pypi-publish@v1.10.2
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
20 changes: 13 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
exclude: '^docs/'
repos:
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
exclude: '^.bumpversion.cfg$'
Expand All @@ -10,19 +16,19 @@ repos:
- id: pretty-format-json
args: ['--autofix', '--no-sort-keys']
- repo: https://github.com/ambv/black
rev: 22.6.0
rev: 24.8.0
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
- repo: https://github.com/PyCQA/flake8
rev: '7.1.1'
hooks:
- id: flake8
- id: flake8
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.961
rev: v1.11.2
hooks:
- id: mypy
- repo: https://github.com/codespell-project/codespell
rev: 'v2.1.0'
rev: 'v2.3.0'
hooks:
- id: codespell
name: codespell
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[build-system]
requires = ["setuptools", "wheel", "oldest-supported-numpy"]
requires = ["setuptools", "wheel", "numpy<2.0"]
build-backend = "setuptools.build_meta"


[tool.cibuildwheel]
test-requires = ["pytest", "tqdm", "tifffile"]
Expand Down
3 changes: 2 additions & 1 deletion pystackreg/util/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Collection of utility functions for pystackreg
"""

import numpy as np


Expand Down Expand Up @@ -44,7 +45,7 @@ def to_int_dtype(arr: np.ndarray, dtype: type):
:rtype: ndarray(Ni..., Nj..., Nk...)
:return: Input array clipped & rounded to integer dtype
"""
assert type(arr) == np.ndarray, "Input must be a numpy array"
assert isinstance(arr, np.ndarray), "Input must be a numpy array"

if not np.issubdtype(dtype, np.integer):
return arr
Expand Down
24 changes: 13 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import os
from setuptools import setup, Extension, find_packages

# cannot directly import because __init__.py imports pystackreg which imports the
# compiled plugin, which is not available before setup.py is run
__version__ = "" # placeholder for linters
exec(open("pystackreg/version.py").read())

Expand All @@ -26,13 +24,17 @@ def __str__(self):

setup(
name="pystackreg",
description="Image registration tool (python implementation of the ImageJ/FIJI "
"Plugin TurboReg/StackReg)",
description=(
"Image registration tool (python implementation of the ImageJ/FIJI "
"Plugin TurboReg/StackReg)"
),
long_description="\n\n".join([readme, change]),
version=__version__,
author="Gregor Lichtner (python/C++ port);"
"TurboReg Author: Philippe Thévenaz, Biomedical Imaging Group,"
"Swiss Federal Institute of Technology Lausanne",
author=(
"Gregor Lichtner (python/C++ port);"
"TurboReg Author: Philippe Thévenaz, Biomedical Imaging Group,"
"Swiss Federal Institute of Technology Lausanne"
),
url="https://github.com/glichtner/pystackreg",
packages=find_packages("."),
ext_modules=[
Expand All @@ -51,7 +53,7 @@ def __str__(self):
)
],
setup_requires=["numpy"],
install_requires=["numpy", "tqdm"],
install_requires=["numpy<2", "tqdm"],
classifiers=[
# complete list: http://pypi.python.org/pypi?%3Aaction=list_classifiers
"Development Status :: 5 - Production/Stable",
Expand All @@ -62,12 +64,12 @@ def __str__(self):
"Operating System :: POSIX",
"Programming Language :: C++",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Image Processing",
"Topic :: Utilities",
],
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ deps=
-rrequirements.txt
tifffile
pytest
setuptools
numpy<2

commands=
python setup.py build_ext --inplace
pip install -e .
python setup.py install
pytest {posargs:}

0 comments on commit 79fc62c

Please sign in to comment.