Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Update packaging (#46)
Browse files Browse the repository at this point in the history
* update pre-commit config

* update args for new brainreg version

* lint

* update manifest

* Bump version: 0.0.5-rc0 → 0.0.5-rc1

* update testing

* update packaging

* update requirements

* update manifest

* move entry point to pyproject.toml

* update hub preview version

* update release for use with setuptools_scm

* migrate from BG to neuroinformatics actions

* add setuptools_scm to dev requirements

* reduce number of tested version

* update python versions tested

* update release
  • Loading branch information
adamltyson authored Dec 6, 2022
1 parent de4e607 commit f1ba83c
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 175 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
ignore = E203, E231, W503, E722
max-line-length = 79
exclude = __init__.py,build,.eggs
2 changes: 1 addition & 1 deletion .github/workflows/plugin_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
uses: actions/checkout@v2

- name: napari hub Preview Page Builder
uses: chanzuckerberg/napari-hub-preview-action@v0.1.5
uses: chanzuckerberg/napari-hub-preview-action@v0.1
with:
hub-ref: main
101 changes: 70 additions & 31 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,98 @@
name: tests

on: [push, pull_request]
on:
push:
branches:
- '*'
tags:
- '*'
pull_request:

jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: brainglobe/actions/lint@v1
- uses: neuroinformatics-unit/actions/lint@v1.2.0

manifest:
name: Check Manifest
runs-on: ubuntu-latest
steps:
- uses: brainglobe/actions/check_manifest@v1
- uses: neuroinformatics-unit/actions/check_manifest@v1.2.0

test:
needs: [linting, manifest]
needs: [ linting, manifest ]
name: ${{ matrix.os }} py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# Run all supported Python versions on linux and windows
# Run all supported Python versions on linux
python-version: ["3.8", "3.9", "3.10"]
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest]
# Test on Windows and macOS on only one OS to save time (and CI minutes)
include:
- os: macos-latest
python-version: "3.10"
- os: windows-latest
python-version: "3.10"

steps:
# Setup pyqt libraries
- uses: tlambert03/setup-qt-libs@v1
# Run tests
- uses: brainglobe/actions/test@v1
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

deploy:
# this will run when you have tagged a commit, starting with "v*"
# and requires that you have put your twine API key in your
# github secrets (see readme for details)
needs: [test]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
# these libraries enable testing on Qt on linux
- uses: tlambert03/setup-qt-libs@v1

# strategy borrowed from vispy for installing opengl libs on windows
- name: Install Windows OpenGL
if: runner.os == 'Windows'
run: |
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1
# note: if you need dependencies from conda, considering using
# setup-miniconda: https://github.com/conda-incubator/setup-miniconda
# and
# tox-conda: https://github.com/tox-dev/tox-conda
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools setuptools_scm wheel twine
- name: Build and publish
python -m pip install setuptools tox tox-gh-actions
# this runs the platform-specific tests declared in tox.ini
- name: Test with tox
uses: GabrielBB/xvfb-action@v1
with:
run: python -m tox
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
run: |
git tag
python setup.py sdist bdist_wheel
twine upload dist/*
PLATFORM: ${{ matrix.platform }}

- name: Coverage
uses: codecov/codecov-action@v2

build_sdist_wheels:
name: Build source distribution
needs: [test]
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-latest
steps:
- uses: neuroinformatics-unit/actions/build_sdist_wheels@main


upload_all:
name: Publish build distributions
needs: [build_sdist_wheels]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@v1.5.0
with:
user: __token__
password: ${{ secrets.TWINE_API_KEY }}
13 changes: 8 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: check-docstring-first
- id: check-executables-have-shebangs
Expand All @@ -15,16 +15,19 @@ repos:
args: [--fix=lf]
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
# bump2version produces whitespace in setup.cfg, so exclude to
# not inferfere with versioning
exclude: setup.cfg
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
rev: v0.990
hooks:
- id: mypy
additional_dependencies:
Expand Down
42 changes: 21 additions & 21 deletions CITATION.CFF
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ authors:
given-names: "M."
- family-names: "Rousseau"
given-names: "C."
- family-names: "Cossell"
- family-names: "Cossell"
given-names: "L."
- family-names: "Tsitoura"
- family-names: "Tsitoura"
given-names: " C."
- family-names: "Lenzi"
- family-names: "Lenzi"
given-names: " S."
- family-names: "Obenhaus"
- family-names: "Obenhaus"
given-names: "H."
- family-names: "Claudi"
- family-names: "Claudi"
given-names: "F."
- family-names: "Branco"
- family-names: "Branco"
given-names: "T."
- family-names: "Margrie"
- family-names: "Margrie"
given-names: "T."
url: https://github.com/brainglobe/brainreg-napari
preferred-citation:
Expand All @@ -40,19 +40,19 @@ preferred-citation:
given-names: "M."
- family-names: "Rousseau"
given-names: "C."
- family-names: "Cossell"
- family-names: "Cossell"
given-names: "L."
- family-names: "Tsitoura"
- family-names: "Tsitoura"
given-names: " C."
- family-names: "Lenzi"
- family-names: "Lenzi"
given-names: "S."
- family-names: "Obenhaus"
- family-names: "Obenhaus"
given-names: "H."
- family-names: "Claudi"
- family-names: "Claudi"
given-names: "F."
- family-names: "Branco"
- family-names: "Branco"
given-names: "T."
- family-names: "Margrie"
- family-names: "Margrie"
given-names: "T."
references:
- type: article
Expand All @@ -70,13 +70,13 @@ references:
given-names: "A."
- family-names: "Jorge"
given-names: "M."
- family-names: "Osten"
- family-names: "Osten"
given-names: "P."
- family-names: "Ourselin"
- family-names: "Ourselin"
given-names: "S."
- family-names: "Modat"
- family-names: "Modat"
given-names: "M."
- family-names: "Margrie"
- family-names: "Margrie"
given-names: "T."
references:
- type: article
Expand All @@ -94,9 +94,9 @@ references:
given-names: "L."
- family-names: "Tyson"
given-names: "A."
- family-names: "Branco"
- family-names: "Branco"
given-names: "T."
- family-names: "Margrie"
- family-names: "Margrie"
given-names: "T."
- family-names: "Portugues"
- family-names: "Portugues"
given-names: "R."
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ include README.md
include tox.ini
include brainreg_napari/napari.yaml
include .napari/config.yml
include CITATION.CFF

recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-exclude .napari *
exclude .pre-commit-config.yaml
exclude .flake8
recursive-exclude examples *
1 change: 0 additions & 1 deletion brainreg_napari/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
__version__ = "0.0.5-rc0"
3 changes: 3 additions & 0 deletions brainreg_napari/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
initialise_brainreg,
)

PRE_PROCESSING_ARGS = None


def add_registered_image_layers(
viewer: napari.Viewer, *, registration_directory: pathlib.Path
Expand Down Expand Up @@ -440,6 +442,7 @@ def run():
data_orientation,
atlas.metadata["orientation"],
niftyreg_args,
PRE_PROCESSING_ARGS,
scaling,
load_parallel,
sort_input_file,
Expand Down
76 changes: 73 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,77 @@
[project]
name = "brainreg-napari"
authors = [{name = "Adam Tyson, Stephen Lenzi", email= "code@adamltyson.com"}]
description = "Multi-atlas whole-brain microscopy registration"
readme = "README.md"
requires-python = ">=3.8.0"
dynamic = ["version"]
classifiers = [
"Development Status :: 4 - Beta",
"Framework :: napari",
"Topic :: Scientific/Engineering :: Image Recognition",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Operating System :: OS Independent",
]

license = {text = "BSD-3-Clause"}
dependencies = [
"napari",
"napari-plugin-engine >= 0.1.4",
"magicgui",
"qtpy",
"brainglobe-napari-io",
"brainreg",
"brainreg-segment",
"pooch>1", # For sample data
]

[project.optional-dependencies]
dev = [
"black",
"pytest-cov",
"pytest",
"pytest-qt",
"napari",
"pyqt5",
"tox",
"gitpython",
"coverage>=5.0.3",
"bump2version",
"pre-commit",
"flake8",
"check-manifest",
"setuptools_scm",
]

[project.urls]
homepage = "https://brainglobe.info"
bug_tracker = "https://github.com/brainglobe/brainreg-napari/issues"
documentation = "https://docs.brainglobe.info/brainreg-napari"
source_code = "https://github.com/brainglobe/brainreg-napari"
user_support = "https://forum.image.sc/tag/brainglobe"
twitter = "https://twitter.com/brain_globe"

[project.entry-points."napari.manifest"]
brainreg-napari = "brainreg_napari:napari.yaml"

[build-system]
requires = [
"setuptools>=45",
"wheel",
"setuptools_scm[toml]>=6.2",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]

[tool.black]
target-version = ['py38', 'py39', 'py310']
skip-string-normalization = false
line-length = 79
exclude = '''
Expand All @@ -8,10 +81,7 @@ exclude = '''
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
Expand Down
Loading

0 comments on commit f1ba83c

Please sign in to comment.