Skip to content

Commit

Permalink
Merge pull request #128 from esavary/maint/migrate-to-pep517-8
Browse files Browse the repository at this point in the history
MAINT: Migrate to PEP517/518 packaging
  • Loading branch information
esavary authored Mar 21, 2024
2 parents b5b940e + b1ac626 commit 62a213a
Show file tree
Hide file tree
Showing 20 changed files with 253 additions and 262 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ jobs:
- run:
name: Initiate versioning
command: |
python -m pip install -U build "setuptools >= 45" wheel "setuptools_scm >= 6.2" \
setuptools_scm_git_archive pip twine docutils
python3 -m pip install -U build hatch hatchling pip twine docutils
pip install /tmp/src/eddymotion[all]
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v2
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install flake8
run: python -m pip install flake8
- name: Check EddyMotion
run: python -m flake8 src
python-version: 3
- name: Lint EddyMotion
run: pipx run flake8-pyproject
9 changes: 5 additions & 4 deletions .github/workflows/docs-build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:

jobs:
build:
if: "(github.repository_owner != 'nipreps') && !contains(github.event.head_commit.message, '[skip ci]')"
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -39,10 +39,11 @@ jobs:
- name: Install dependencies
run: |
pip install --no-cache-dir "setuptools >= 45.0" "setuptools_scm[toml] >= 6.2"
pip install -U build hatch pip
pip install -r docs/requirements.txt
python -m hatch version | tail -n1
- name: Build docs
run: |
python -m setuptools_scm # Generate _version.py file
python -m hatch build --hooks-only
make -C docs/ SPHINXOPTS="-W" BUILDDIR="$HOME/docs" OUTDIR="${CURBRANCH:-html}" html
5 changes: 3 additions & 2 deletions .github/workflows/docs-build-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ jobs:
- name: Install dependencies
run: |
pip install --no-cache-dir "setuptools >= 45.0" "setuptools_scm[toml] >= 6.2"
pip install -U build hatch pip
pip install -r docs/requirements.txt
python -m hatch version | tail -n1
- name: Build docs
run: |
python -m setuptools_scm # Generate _version.py file
python -m hatch build --hooks-only
make -C docs/ SPHINXOPTS="-W" BUILDDIR="$HOME/docs" OUTDIR="${CURBRANCH:-html}" html
- name: Push created tag to gh-pages
Expand Down
27 changes: 12 additions & 15 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
pip: ["pip==21.2", "pip~=22.0"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- name: Fetch all tags (for setuptools_scm to work)
run: |
/usr/bin/git -c protocol.version=2 fetch --tags --prune --unshallow origin
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: $HOME/.cache/pip
key: pip-cache-v1
Expand All @@ -39,20 +38,18 @@ jobs:
run: |
python -m venv /tmp/buildenv
source /tmp/buildenv/bin/activate
python -m pip install -U build "setuptools >= 45" wheel "setuptools_scm >= 6.2" \
setuptools_scm_git_archive pip twine docutils
pip install -U build hatch pip twine
python -m build -s -w
python -m twine check dist/eddymotion-*
mv dist /tmp/package
rm -rf eddymotion.egg-info/
# Interpolate version
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
TAG=${GITHUB_REF##*/}
fi
THISVERSION=$( python -m setuptools_scm )
THISVERSION=$( python -m hatch version | tail -n1 | xargs )
THISVERSION=${TAG:-$THISVERSION}
echo "Expected VERSION: \"${THISVERSION}\""
echo "THISVERSION=${THISVERSION}" >> $GITHUB_ENV
Expand All @@ -61,7 +58,7 @@ jobs:
run: |
python -m venv /tmp/pip
source /tmp/pip/bin/activate
python -m pip install -U "setuptools >= 45" "setuptools_scm >= 6.2" "${{ matrix.pip }}"
pip install -U pip
python -m pip install .
INSTALLED_VERSION=$(python -c 'import eddymotion as em; print(em.__version__, end="")')
echo "VERSION: \"${THISVERSION}\""
Expand All @@ -72,7 +69,7 @@ jobs:
run: |
python -m venv /tmp/install_sdist
source /tmp/install_sdist/bin/activate
python -m pip install -U "setuptools >= 45" "${{ matrix.pip }}"
pip install -U pip
python -m pip install /tmp/package/eddymotion*.tar.gz
INSTALLED_VERSION=$(python -c 'import eddymotion as em; print(em.__version__, end="")')
echo "VERSION: \"${THISVERSION}\""
Expand All @@ -83,7 +80,7 @@ jobs:
run: |
python -m venv /tmp/install_wheel
source /tmp/install_wheel/bin/activate
python -m pip install -U "setuptools >= 45" "${{ matrix.pip }}"
pip install -U pip
python -m pip install /tmp/package/eddymotion*.whl
INSTALLED_VERSION=$(python -c 'import eddymotion as em; print(em.__version__, end="")')
echo "INSTALLED: \"${INSTALLED_VERSION}\""
Expand Down
12 changes: 0 additions & 12 deletions MANIFEST.in

This file was deleted.

2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.. include:: links.rst
.. include:: ../README.rst
:end-line: 29
.. include:: ../README.rst
:start-line: 34


.. image:: _static/eddymotion-flowchart.svg
Expand Down
5 changes: 3 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
attrs >= 20.1.0
furo ~= 2021.10.09
furo >= 2024.01.29
matplotlib >= 2.2.0
packaging
sphinx ~= 4.2
sphinx >= 4.5
sphinxcontrib-apidoc
nireports
196 changes: 182 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,183 @@
[build-system]
requires = [
"setuptools >= 45",
"setuptools_scm[toml] >= 6.2",
"wheel"
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "src/eddymotion/_version.py"
write_to_template = """\
\"\"\"Version file, automatically generated by setuptools_scm.\"\"\"
__version__ = "{version}"
"""
fallback_version = "0.0"
requires = ["hatchling", "hatch-vcs", "nipreps-versions"]
build-backend = "hatchling.build"


[project]
name = "eddymotion"
description = "Pure python eddy-current and head-motion correction for dMRI, an extension of QSIprep's SHOREline algorithm (Cieslak, 2020) to multiple diffusion models."
readme = "README.rst"
authors = [{name = "The NiPreps Developers", email = "[email protected]"}]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Image Recognition",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
license = "Apache-2.0"
requires-python = ">=3.8"
dependencies = [
"dipy>=1.3.0",
"joblib",
"nipype>= 1.5.1, < 2.0",
"nitransforms>=21.0.0",
"nireports",
"numpy>=1.17.3",
"nest-asyncio>=1.5.1",
"scikit-image>=0.14.2",
"scipy>=1.8.0",
]
dynamic = ["version"]

[project.urls]
Documentation = "https://www.nipreps.org/eddymotion"
Home = "https://github.com/nipreps/eddymotion"
NiPreps = "https://www.nipreps.org/"

[project.optional-dependencies]
doc = [
"attrs >= 20.1.0",
"furo >= 2024.01.29",
"matplotlib >= 2.2.0",
"nbsphinx",
"packaging",
"pydot >= 1.2.3",
"pydotplus",
"sphinx >= 4.5",
"sphinx-argparse",
"sphinx_rtd_theme",
"sphinxcontrib-apidoc ~= 0.3.0",
"sphinxcontrib-napoleon",
"sphinxcontrib-versioning"
]

dev = [
"black",
"flake8",
"flake8-pyproject",
"isort",
"pre-commit",
"pre-commit-hooks",
]

plotting = ["nilearn"]

resmon = ["psutil >=5.4"]

popylar = ["popylar >= 0.2"]

test = [
"coverage",
"pytest >= 4.4",
"pytest-cov",
"pytest-env",
"pytest-xdist >= 1.28"
]

# Aliases
docs = ["eddymotion[doc]"]
tests = ["eddymotion[test]"]
all = ["eddymotion[doc,test,dev,plotting,resmon,popylar]"]

#
# Hatch configurations
#

[tool.hatch.metadata]
allow-direct-references = true

[tool.hatch.build.targets.sdist]
exclude = [".git_archival.txt"] # No longer needed in sdist

[tool.hatch.build.targets.wheel]
packages = ["src/eddymotion"]
# exclude = [
# "eddymotion/tests/data", # Large test data directory
# ]


[tool.hatch.version]
validate-bump = true
source = "vcs"
raw-options = { version_scheme = "nipreps-calver" }

[tool.hatch.build.hooks.vcs]
version-file = "src/eddymotion/_version.py"

#
# Developer tool configurations
#

[tool.black]
line-length = 99
target-version = ['py39']
skip-string-normalization = true
exclude = '''
# Directories
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| venv
| _build
| build
| dist
)/
'''

[tool.isort]
profile = 'black'
skip_gitignore = true

[tool.flake8]
max-line-length = 99
doctests = false
exclude = ["*build/", "docs/"]
select = "C,E,F,W,B,B950"
ignore = "N802,N806,W503,E203"
per-file-ignores = [
"*/__init__.py: F401",
"docs/conf.py: E265",
"/^\\s*\\.\\. _.*?: http/: E501"
]

[tool.pytest.ini_options]
pythonpath = "src/ test/"
norecursedirs = [".*", "_*"]
addopts = "-v --doctest-modules"
doctest_optionflags = "ALLOW_UNICODE NORMALIZE_WHITESPACE"
env = "PYTHONHASHSEED=0"
filterwarnings = ["ignore::DeprecationWarning"]


[tool.coverage.run]
branch = true
concurrency = 'multiprocessing'
omit = [
'*/tests/*',
'*/__init__.py',
'*/conftest.py',
'src/eddymotion/_version.py'
]

[tool.coverage.report]
# Regexes for lines to exclude from consideration
exclude_lines = [
'raise NotImplementedError',
'warnings\.warn',
]

[tool.codespell]
# nd - import scipy.ndimage as nd
# mapp, reson -- Mapp. and Reson. abbreviations in citation
ignore-words-list = 'nd,mapp,reson'
skip = """
./.git,*.pdf,*.svg,*.min.js,*.ipynb,ORIGINAL_LICENSE,\
./docs/source/_static/example_anatreport.html"""
Loading

0 comments on commit 62a213a

Please sign in to comment.