diff --git a/.appveyor.yml b/.appveyor.yml deleted file mode 100644 index 8a571022ba..0000000000 --- a/.appveyor.yml +++ /dev/null @@ -1,59 +0,0 @@ -# vim ft=yaml -# CI on Windows via appveyor - -environment: - global: - EXTRA_FLAGS: "" - - matrix: - - PYTHON: C:\Python27 - - PYTHON: C:\Python27-x64 - # Doctest fail from the long Ls, as in (1L, 2L) != (1, 2) - EXTRA_FLAGS: "--without-doctest" - - PYTHON: C:\Python36 - - PYTHON: C:\Python36-x64 - - PYTHON: C:\Python37 - - PYTHON: C:\Python37-x64 - - PYTHON: C:\Python38 - # https://stackoverflow.com/a/58582651/1939576 - EXTRA_FLAGS: "--traverse-namespace" - - PYTHON: C:\Python38-x64 - EXTRA_FLAGS: "--traverse-namespace" - - PYTHON: C:\Python39 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - EXTRA_FLAGS: "--traverse-namespace" - - PYTHON: C:\Python39-x64 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - EXTRA_FLAGS: "--traverse-namespace" - -install: - # Prepend newly installed Python to the PATH of this build (this cannot be - # done from inside the powershell script as it would require to restart - # the parent CMD process). - - SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH% - - python -m pip install -U pip setuptools - - # Fix MSVC builds for 64-bit Python. See: - # http://stackoverflow.com/questions/32091593/cannot-install-windows-sdk-7-1-on-windows-10 - - echo "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 > "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64/vcvars64.bat" - - # Install the dependencies of the project. - - pip install numpy Cython nose nibabel "sympy<1.6" scipy - # Pin wheel to 0.26 to avoid Windows ABI tag for built wheel - - pip install wheel==0.26 - # install - - pip install . - -build: false # Not a C# project, build stuff at the test step instead. - -test_script: - # Change into an innocuous directory and find tests from installation - - mkdir for_testing - - cd for_testing - - python --version - - python ..\tools\nipnost %EXTRA_FLAGS% nipy - - cd .. - -cache: - # Use the appveyor cache to avoid re-downloading large archives. - - '%APPDATA%\pip\Cache' diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 0000000000..2553dc9dce --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,3 @@ +00f00c5929f1f93389c12c786522eccb301c896b +0adde5085031aed3c2807061bd4e88b901910f76 +b53c35c7eb3ac78b22c584bec7b56e414690791f diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000000..492bbd562a --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,48 @@ +name: coverage + +on: + push: + branches: [main] + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + report: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + allow-prereleases: true + - name: Install + run: | + pip install -r dev-requirements.txt + pip install . + - name: Show environment + run: env + - name: Library tests + run: | + mkdir tmp + cd tmp + pytest --doctest-plus --ignore-glob="__config__.py" \ + --cov=nipy --cov-report xml --cov-config=../.coveragerc \ + --pyargs nipy + - name: See what's where + run: | + pwd + ls -lR .. + - name: Upload to codecov + uses: codecov/codecov-action@v4 + with: + files: tmp/coverage.xml + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml new file mode 100644 index 0000000000..cf97653ff9 --- /dev/null +++ b/.github/workflows/doc-build.yml @@ -0,0 +1,45 @@ +name: doc-build + +on: + push: + branches: [main] + pull_request: + branches: [main] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + report: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3"] + steps: + - name: Apt update + run: sudo apt update + - name: Install graphviz + run: | + sudo apt install -y graphviz + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + allow-prereleases: true + - name: Install + run: | + pip install -r doc-requirements.txt + pip install . + - name: Show environment + run: env + - name: Build documentation + run: | + cd doc + make html + - name: Run documentation doctests + run: | + cd doc + make clean + make doctest diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000000..ed79b18705 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +name: style + +on: [push, pull_request] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + format: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.12"] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install packages + run: | + pip install --upgrade pip + pip install pre-commit + pip list + + - name: Lint + run: pre-commit run --all-files --show-diff-on-failure --color always diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..e00b38e0cd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,63 @@ +name: Test + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read # to fetch code (actions/checkout) + +defaults: + run: + shell: bash + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + strategy: + matrix: + python_version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] + os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python_version }} + allow-prereleases: true + - name: Install + run: | + pip install -r dev-requirements.txt + pip install . + - name: Show environment + run: env + - name: Library tests + run: | + mkdir tmp + cd tmp + pytest --doctest-plus --ignore-glob="__config__.py" --pyargs nipy + bench: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install + run: | + pip install -r dev-requirements.txt + pip install . + - name: Show environment + run: env + - name: Library tests + run: | + mkdir tmp + cd tmp + pytest -s -c ../bench.ini --pyargs nipy diff --git a/.gitignore b/.gitignore index 88a4ea014d..60fe2a23b6 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ *.py[oc] *.so *.pyd +__pycache__/ # Packages # ############ @@ -52,6 +53,7 @@ ################ MANIFEST build/ +build-install/ _build dist/ *.egg-info diff --git a/.mailmap b/.mailmap index 8bbb7fe58a..d219f757e8 100644 --- a/.mailmap +++ b/.mailmap @@ -12,6 +12,7 @@ Cindee Madison Cindee Madison Cindee Madison cindee.madison <> Cindee Madison cindeem <> Cindee Madison cindeem +Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Eleftherios Garyfallidis Erik Ziegler erikz Fabian Pedregosa @@ -34,9 +35,12 @@ Matthew Brett mb312 Matthieu Brucher Merlin Keller Merlin KELLER Merlin Keller keller +Nicholas Tolley <> Nicholas Tolley <55253912+ntolley@users.noreply.github.com> Tom Waite twaite Virgile Fritsch VirgileFritsch Virgile Fritsch Fritsch +Matteo Visconti di Oleggio Castello Matteo Visconti dOC +Ben Beasley Benjamin A. Beasley # and below the ones to fill out Paris Sprint Account diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..11b0b51b6e --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +# pre-commit install + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # v5.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: debug-statements + - id: check-ast + - id: mixed-line-ending + - id: check-yaml + args: [--allow-multiple-documents] + - id: check-added-large-files + + - repo: https://github.com/rbubley/mirrors-prettier + rev: 1463d990e0801964764a375260dca598513f3be5 # frozen: v3.3.3 + hooks: + - id: prettier + files: \.(md|rst|toml|yml|yaml) + args: [--prose-wrap=preserve] + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: 8b76f04e7e5a9cd259e9d1db7799599355f97cdf # frozen: v0.8.2 + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fefdac465e..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,146 +0,0 @@ -# vim ft=yaml -# Multiple lines can be made a single "virtual line" because of the way that -# Travis munges each line before executing it to print out the exit status. -# It's okay for it to be on multiple physical lines, so long as you remember: -# - There can't be any leading "-"s - All newlines will be removed, so use -# ";"s -sudo: false # To use travis container infrastructure - -language: python - -cache: - directories: - - $HOME/.cache/pip - -env: - global: - - DEPENDS="numpy scipy sympy matplotlib nibabel" - - PRE_PIP_FLAGS="--pre --extra-index-url https://pypi.anaconda.org/multibuild-wheels-staging/simple" --extra-index-url https://anaconda.org/scipy-wheels-nightly" - - INSTALL_TYPE="pip" - -python: - - 3.6 - - 3.7 - - 3.8 - - 3.9 - -matrix: - include: - - python: 2.7 - env: - - COVERAGE=1 - # Absolute minimum dependencies - - python: 2.7 - env: - # Definitive source for these in nipy/info.py - - PRE_DEPENDS="numpy==1.14" - - DEPENDS="scipy==1.0.0 sympy==1.0.0 nibabel==2.0.0" - # Test compiling against external lapack - - python: 3.6 - env: - - NIPY_EXTERNAL_LAPACK=1 - addons: - apt: - packages: - - libblas-dev - - liblapack-dev - - python: 3.8 - env: - - INSTALL_TYPE=sdist - - python: 3.8 - env: - - INSTALL_TYPE=wheel - - python: 3.8 - env: - - INSTALL_TYPE=requirements - - DEPENDS= - # test 3.9 against pre-release builds of everything - - python: 3.9 - env: - - EXTRA_PIP_FLAGS="$PRE_PIP_FLAGS" - # test python setup.py install - - python: 3.8 - env: - - INSTALL_TYPE=setup - - python: 3.8 - env: - - INSTALL_TYPE="pip_e" - - python: 3.8 - env: - - DOC_BUILD=1 - addons: - apt: - packages: - - graphviz - - texlive-latex-base - - texlive-latex-extra - - texlive-fonts-recommended - - texlive-latex-recommended - - latexmk - -before_install: - - source tools/travis_tools.sh - - python -m pip install --upgrade pip - - pip install --upgrade virtualenv - - virtualenv --python=python venv - - source venv/bin/activate - - python --version # just to check - - pip install -U pip - - pip install nose mock # always - - if [ -n "$PRE_DEPENDS" ]; then - pip install $EXTRA_PIP_FLAGS $PRE_DEPENDS; - fi - - if [ -n "$DEPENDS" ]; then - pip install $EXTRA_PIP_FLAGS $DEPENDS; - fi - - if [ "${COVERAGE}" == "1" ]; then - pip install coverage; - pip install coveralls codecov; - fi - -# command to install dependencies -# e.g. pip install -r requirements.txt # --use-mirrors -install: - - | - if [ "$INSTALL_TYPE" == "pip" ]; then - pip install . - elif [ "$INSTALL_TYPE" == "pip_e" ]; then - pip install -e . - elif [ "$INSTALL_TYPE" == "setup" ]; then - python setup.py install - elif [ "$INSTALL_TYPE" == "sdist" ]; then - python setup.py egg_info # check egg_info while we're here - python setup.py sdist - pip install $EXTRA_PIP_FLAGS dist/*.tar.gz - elif [ "$INSTALL_TYPE" == "wheel" ]; then - pip install wheel - python setup.py bdist_wheel - pip install $EXTRA_PIP_FLAGS dist/*.whl - elif [ "$INSTALL_TYPE" == "requirements" ]; then - pip install $EXTRA_PIP_FLAGS -r requirements.txt - pip install -r requirements.txt - python setup.py install - fi - -# command to run tests -script: - - | - if [ "$DOC_BUILD" ]; then # doc build - pip install -r doc-requirements.txt - # Work round bug in Sympy atoms docstring as of 1.1.0 - # https://github.com/sympy/sympy/pull/12900 - pip install git+https://github.com/sympy/sympy.git - make html-stamp pdf-stamp - else - # Change into an innocuous directory and find tests from installation - mkdir for_testing - cd for_testing - if [ "${COVERAGE}" == "1" ]; then - cp ../.coveragerc . - COVER_ARGS="--with-coverage --cover-package nipy" - fi - python ../tools/nipnost --verbosity=3 $COVER_ARGS nipy - fi - -after_success: - - if [ "${COVERAGE}" == "1" ]; then coveralls; codecov; fi diff --git a/AUTHOR b/AUTHOR index 8eb393a16e..cddaf05184 100644 --- a/AUTHOR +++ b/AUTHOR @@ -1,10 +1,12 @@ Alexis Roche Ariel Rokem +Ben Beasley Bertrand Thirion Benjamin Thyreau Brian Hawthrorne Ben Cipollini Chris Burns +Chris Markiewicz Cindee Madison Elvis Dohmatob Endolith @@ -19,6 +21,7 @@ Matteo Visconti dOC Merlin Keller Michael Waskom Mike Trumpis +Stefan van der Walt Tim Leslie Tom Waite Virgile Fritsch diff --git a/Changelog b/Changelog index a1136ff0f4..9e99405e9c 100644 --- a/Changelog +++ b/Changelog @@ -17,7 +17,7 @@ about their releases. The full VCS changelog is available here: - http://github.com/nipy/nipy/commits/master + http://github.com/nipy/nipy/commits/main Releases ~~~~~~~~ @@ -31,6 +31,43 @@ Abbreviated authors are: * YH - Yarik Halchenko * JBP - Jean-Baptiste Poline * JT - Jonathan Taylor +* BB - Ben Beasley +* CM - Chris Markiewicz +* JM - Jarrod Millman +* SvdW - Stéfan van der Walt + +* 0.6.1 (Saturday 5 October 2024) + + Compatibility release for Numpy 2.0 + + * Port code for Numpy 2.0 compatibility (MB) + * Update for test precision on Sympy 1.13 (MB) + * Clean up consts and casts in C code (BB) + * Refactoring to functools.cached_property, style and CI updates (CM) + * CI and automated style check updates (Dimitri Papadopoulos Orfanos) + * Fix for Viz example (Nicholas Tolley) + * Add spin tooling for working with repository checkout (SvdW) + * Fix shebangs for some development scripts (Étienne Mollier) + +* 0.6.0 (Thursday 21 December 2023) + + Bugfix, refactoring and compatibility release. + + Much thankless maintenance duty particularly by CM. Oh wait - not thankless + - thank you! + + * Huge cleanup of old dependencies for installation and build (BB). + * Allow for Nibabel deprecations and removals, particularly ``get_data`` + (BB). + * Build refactor to ``pyproject.toml`` (CM) + * Various cleanups in spelling and script mechanics (Dimitri Papadopoulos). + * Move to pytest / pytest-doctestplus for testing (JM, MB). + * Various improvements to development process and CI (JM, MB, SvdW). + * Port build process from Numpy distutils to Meson (SvdW). + * Drop Python 2 support. + * Various bugfixes for modern Numpy (BB, MB). + * Drop Cython C files and depend on Cython for build (MB). + * Fixes to temporary files in Mayavi calls (fazledyn-or, CM). * 0.5.0 (Saturday 27 March 2021) diff --git a/LICENSE b/LICENSE index 191baae250..0bee217a6a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2006-2021, NIPY Developers +Copyright (c) 2006-2024, NIPY Developers All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Makefile b/Makefile index c75f567461..65fa8bb3d8 100644 --- a/Makefile +++ b/Makefile @@ -37,49 +37,24 @@ distclean: clean -rm -r .tox -git clean -fxd -dev: cythonize - $(PYTHON) setup.py build_ext --inplace - -test: - cd .. && $(PYTHON) -c 'import nipy; nipy.test()' - install: - $(PYTHON) setup.py install - -cythonize: - $(PYTHON) tools/nicythize + $(PYTHON) -m pip install . -bdist_rpm: - $(PYTHON) setup.py bdist_rpm \ - --doc-files "doc" \ - --packager "nipy authors " - --vendor "nipy authors " - -# build MacOS installer -- depends on patched bdist_mpkg for Leopard -bdist_mpkg: - $(PYTHON) tools/mpkg_wrapper.py setup.py install +editable: + $(PYTHON) -m pip install --no-build-isolation --editable . # Print out info for possible install methods check-version-info: bash tools/show_version_info.sh source-release: distclean - $(PYTHON) setup.py sdist + $(PYTHON) -m build . --sdist tox-fresh: # tox tests with fresh-installed virtualenvs. Needs network. And # pytox, obviously. tox -c tox.ini -tox-stale: - # tox tests with MB's already-installed virtualenvs (numpy and nose - # installed) - tox -e python25,python26,python27,python32,np-1.2.1 - -recythonize: - # Recythonize all pyx files - find . -name "*.pyx" -exec cython -I libcstat/wrapper -I lib/fff_python_wrapper {} \; - # Website stuff $(WWW_DIR): if [ ! -d $(WWW_DIR) ]; then mkdir -p $(WWW_DIR); fi diff --git a/README.rst b/README.rst index 36a8e2aca8..d56acf9d59 100644 --- a/README.rst +++ b/README.rst @@ -1,11 +1,8 @@ .. -*- rest -*- .. vim:syntax=rst -.. image:: https://coveralls.io/repos/nipy/nipy/badge.png?branch=master - :target: https://coveralls.io/r/nipy/nipy?branch=master - -.. Following contents should be from LONG_DESCRIPTION in nipy/info.py - +.. image:: https://codecov.io/gh/nipy/nipy/branch/main/graph/badge.svg + :target: https://app.codecov.io/gh/nipy/nipy/branch/main ==== NIPY @@ -67,30 +64,28 @@ You can find our sources and single-click downloads: .. _main repository: https://github.com/nipy/nipy .. _Documentation: http://nipy.org/nipy -.. _current development version: https://github.com/nipy/nipy/archive/master.zip +.. _current development version: https://github.com/nipy/nipy/archive/main.zip .. _available releases: http://pypi.python.org/pypi/nipy Tests ===== -To run nipy's tests, you will need to install the nose_ Python testing -package. If you are using Python 2.7, you will also need to install the mock_ -testing package - e.g.:: +To run nipy's tests, you will need to install the pytest_ Python testing +package:: - pip install nose mock + pip install pytest Then:: - python -c "import nipy; nipy.test()" + pytest nipy -You can also run nipy's tests with the ``nipnost`` script in the ``tools`` -directory of the nipy distribution:: +You can run the doctests along with the other tests with:: - ./tools/nipnost nipy + pip install pytest-doctestplus + +Then:: -``nipnost`` is a thin wrapper around the standard ``nosetests`` program that -is part of the nose package. Try ``nipnost --help`` to see a large number of -command-line options. + pytest --doctest-plus nipy Installation ============ @@ -105,12 +100,11 @@ the nipy distribution. .. links: .. _python: http://python.org -.. _numpy: http://numpy.scipy.org -.. _scipy: http://www.scipy.org +.. _numpy: http://numpy.org +.. _scipy: http://scipy.org .. _sympy: http://sympy.org .. _nibabel: http://nipy.org/nibabel .. _ipython: http://ipython.org .. _matplotlib: http://matplotlib.org -.. _nose: http://nose.readthedocs.org/en/latest -.. _mock: https://pypi.python.org/pypi/mock +.. _pytest: http://pytest.org .. _installation instructions: http://nipy.org/nipy/users/installation.html diff --git a/bench.ini b/bench.ini new file mode 100644 index 0000000000..8d7f62c95f --- /dev/null +++ b/bench.ini @@ -0,0 +1,3 @@ +[pytest] +python_files = bench_*.py +python_functions = bench_* diff --git a/dev-requirements.txt b/dev-requirements.txt index aa8ad84f83..7d631b02c8 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,10 @@ # Requirements for running tests -r requirements.txt -nose3 -mock +pytest>=7.2 +pytest-doctestplus +pytest-cov>=4.0 +matplotlib +coverage +pre-commit +build +twine diff --git a/doc-requirements.txt b/doc-requirements.txt index 3b875dbc77..6a93a4452d 100644 --- a/doc-requirements.txt +++ b/doc-requirements.txt @@ -1,8 +1,8 @@ # Requirements for building docs # Check these dependencies against doc/conf.py -r dev-requirements.txt -sphinx>=1.0,<3.0 -numpydoc==0.8.0 +sphinx>=7.0 +numpydoc>=1.6.0 matplotlib texext ipython diff --git a/doc/Makefile b/doc/Makefile index 28bd71d498..1f9d71c5f0 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -110,10 +110,10 @@ linkcheck: @echo "Link check complete; look for any errors in the above output " \ "or in build/linkcheck/output.txt." -clean-doctest: clean doctest-only +clean-doctest: clean doctest # Clean avoids testing API docs -doctest-only: +doctest: mkdir -p build/doctest build/doctrees $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) build/doctest @echo diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html index be4ca53b41..98c6f64c00 100644 --- a/doc/_templates/layout.html +++ b/doc/_templates/layout.html @@ -21,7 +21,7 @@ {# This block gets put at the top of the sidebar #} {% block sidebarlogo %} - +

Site Navigation

  • Documentation
  • @@ -65,7 +65,7 @@

    Search mailing list archive

    - +