diff --git a/.circleci/config.yml b/.circleci/config.yml index 4ddc2d5..73c44e2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,7 +5,7 @@ orbs: jobs: test_package: docker: - - image: cimg/python:3.8.5 + - image: cimg/python:3.11 auth: username: $DOCKER_USER password: $DOCKER_PAT @@ -17,9 +17,11 @@ jobs: command: | python3 -m venv /tmp/buildenv source /tmp/buildenv/bin/activate - python -m pip install -U "setuptools~=58.0" "setuptools_scm>=6.2" pip wheel twine docutils - python setup.py sdist bdist_wheel - twine check dist/mriqc_learn* + python -m pip install -U build hatch pip twine + + # Build and test package + python -m build -s -w + python -m twine check dist/mriqc_learn-* - store_artifacts: path: /tmp/src/mriqc_learn/dist - persist_to_workspace: @@ -30,10 +32,11 @@ jobs: command: | python3 -m venv /tmp/install_sdist source /tmp/install_sdist/bin/activate - python -m pip install -U pip "setuptools~=58.0" "setuptools_scm>=6.2" - THISVERSION=$( python setup.py --version ) + + THISVERSION=$( python -m hatch version | tail -n1 | xargs ) THISVERSION=${CIRCLE_TAG:-$THISVERSION} - python -m pip install dist/mriqc-learn*.tar.gz + + python -m pip install /tmp/src/mriqc_learn/dist/mriqc_learn*.tar.gz INSTALLED_VERSION=$(python -c 'import mriqc_learn as ml; print(ml.__version__, end="")') echo "VERSION: \"${THISVERSION}\"" echo "INSTALLED: \"${INSTALLED_VERSION}\"" @@ -43,10 +46,11 @@ jobs: command: | python3 -m venv /tmp/install_wheel source /tmp/install_wheel/bin/activate - python -m pip install "setuptools~=58.0" "setuptools_scm>=6.2" wheel "pip>=10.0.1" - THISVERSION=$( python setup.py --version ) + + THISVERSION=$( python -m hatch version | tail -n1 | xargs ) THISVERSION=${CIRCLE_TAG:-$THISVERSION} - python -m pip install dist/mriqc_learn*.whl + + python -m pip install /tmp/src/mriqc_learn/dist/mriqc_learn*.whl INSTALLED_VERSION=$(python -c 'import mriqc_learn as ml; print(ml.__version__, end="")') echo "VERSION: \"${THISVERSION}\"" echo "INSTALLED: \"${INSTALLED_VERSION}\"" @@ -54,7 +58,7 @@ jobs: deploy_pypi: docker: - - image: cimg/python:3.8.5 + - image: cimg/python:3.11 working_directory: /tmp/src/mriqc_learn steps: - attach_workspace: diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index b244286..594a7dd 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -12,87 +12,69 @@ on: jobs: build: - if: "!contains(github.event.head_commit.message, '[skip ci]')" + if: "!startsWith(github.ref, 'refs/tags/') && !contains(github.event.head_commit.message, '[skip ci]')" runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] steps: - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: ssh-key: "${{ secrets.NIPREPS_DEPLOY }}" fetch-depth: 0 - - name: Build in confined, updated environment and interpolate version + - name: Build in confined environment and interpolate version run: | python -m venv /tmp/buildenv source /tmp/buildenv/bin/activate - python -m pip install -U "setuptools~=58.0" "setuptools_scm>=6.2" pip wheel twine docutils + python -m pip install -U build hatch pip twine + + python -m build -s -w + python -m twine check dist/mriqc_learn-* + + mv dist /tmp/package # Interpolate version if [[ "$GITHUB_REF" == refs/tags/* ]]; then TAG=${GITHUB_REF##*/} fi - THISVERSION=$( python setup.py --version ) + THISVERSION=$( python -m hatch version | tail -n1 | xargs ) THISVERSION=${TAG:-$THISVERSION} echo "Expected VERSION: \"${THISVERSION}\"" echo "THISVERSION=${THISVERSION}" >> ${GITHUB_ENV} - python setup.py sdist - python -m twine check dist/mriqc-learn-${THISVERSION}.tar.gz - - python setup.py bdist_wheel - python -m twine check dist/mriqc_learn-${THISVERSION}-py3-none-any.whl - + - name: Install in confined environment [pip] + run: | + python -m venv /tmp/pip + source /tmp/pip/bin/activate + pip install -U pip + python -m pip install . + INSTALLED_VERSION=$(python -c 'import mriqc_learn as em; print(em.__version__, end="")') + echo "VERSION: \"${THISVERSION}\"" + echo "INSTALLED: \"${INSTALLED_VERSION}\"" + test "${INSTALLED_VERSION}" = "${THISVERSION}" + - name: Install in confined environment [sdist] run: | python -m venv /tmp/install_sdist source /tmp/install_sdist/bin/activate - python -m pip install --upgrade pip wheel - python -m pip install dist/mriqc-learn-${THISVERSION}.tar.gz - INSTALLED_VERSION=$(python -c 'import mriqc_learn; print(mriqc_learn.__version__, end="")') + pip install -U pip + python -m pip install /tmp/package/mriqc_learn*.tar.gz + INSTALLED_VERSION=$(python -c 'import mriqc_learn as em; print(em.__version__, end="")') echo "VERSION: \"${THISVERSION}\"" echo "INSTALLED: \"${INSTALLED_VERSION}\"" test "${INSTALLED_VERSION}" = "${THISVERSION}" + - name: Install in confined environment [wheel] run: | python -m venv /tmp/install_wheel source /tmp/install_wheel/bin/activate - python -m pip install --upgrade pip wheel - python -m pip install dist/mriqc_learn-${THISVERSION}-py3-none-any.whl - INSTALLED_VERSION=$(python -c 'import mriqc_learn; print(mriqc_learn.__version__, end="")') + pip install -U pip + python -m pip install /tmp/package/mriqc_learn*.whl + INSTALLED_VERSION=$(python -c 'import mriqc_learn as em; print(em.__version__, end="")') echo "INSTALLED: \"${INSTALLED_VERSION}\"" test "${INSTALLED_VERSION}" = "${THISVERSION}" - - name: Install in confined environment [pip install .] - run: | - python -m venv /tmp/setup_install - source /tmp/setup_install/bin/activate - python -m pip install --upgrade pip wheel - python -m pip install . - INSTALLED_VERSION=$(python -c 'import mriqc_learn; print(mriqc_learn.__version__, end="")') - echo "INSTALLED: \"${INSTALLED_VERSION}\"" - test "${INSTALLED_VERSION}" = "${THISVERSION}" - - name: Install in confined environment [pip install -e .] - run: | - python -m venv /tmp/setup_develop - source /tmp/setup_develop/bin/activate - python -m pip install pip - python -m pip install --upgrade pip wheel - python -m pip install -e . - INSTALLED_VERSION=$(python -c 'import mriqc_learn; print(mriqc_learn.__version__, end="")') - echo "INSTALLED: \"${INSTALLED_VERSION}\"" - test "${INSTALLED_VERSION}" = "${THISVERSION}" - flake8: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - run: pip install flake8 - - run: flake8 mriqc_learn/ diff --git a/pyproject.toml b/pyproject.toml index 8f354ef..79b26a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,157 @@ [build-system] -requires = ["setuptools>=45, <58", "wheel", "setuptools_scm>=6.2"] - -[tool.setuptools_scm] -write_to = "mriqc_learn/_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 = "mriqc-learn" +description = "Learning on MRIQC-generated image quality metrics (IQMs)." +readme = "README.md" +authors = [{name = "The NiPreps Developers", email = "nipreps@gmail.com"}] +classifiers = [ + "Development Status :: 2 - Pre-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 = [ + "numpy", + "joblib", + "pandas", + "scikit-learn", +] +dynamic = ["version"] + +[project.urls] +Home = "https://github.com/nipreps/mriqc-learn" + +[project.optional-dependencies] +doc = [ + "furo >= 2024.01.29", + "pydot >= 1.2.3", + "pydotplus", + "sphinx >= 4.5", + "sphinxcontrib-apidoc", + "sphinxcontrib-napoleon", +] + +mem = [ + "psutil", +] + +test = [ + "codecov", + "coverage", + "pytest", + "pytest-cov", + "pytest-env", + "pytest-xdist", +] + +# Aliases +docs = ["mriqc-learn[doc]"] +tests = ["mriqc-learn[test]"] +all = ["mriqc-learn[doc,test,mem]"] + +# +# 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 = ["mriqc_learn"] +# exclude = [ +# "mriqc_learn/tests/largedata", # 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 = "mriqc_learn/_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] +norecursedirs = [".*", "_*"] +addopts = "-vsx --doctest-modules" +doctest_optionflags = "ALLOW_UNICODE NORMALIZE_WHITESPACE NUMBER" +env = "PYTHONHASHSEED=0" +filterwarnings = ["ignore::DeprecationWarning"] + + +[tool.coverage.run] +branch = true +concurrency = 'multiprocessing' +omit = [ + '*/tests/*', + '*/__init__.py', + '*/conftest.py', + 'mriqc_learn/_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""" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 8e42dd5..0000000 --- a/setup.cfg +++ /dev/null @@ -1,93 +0,0 @@ -[metadata] -author = The NiPreps developers -author_email = nipreps@gmail.com -classifiers = - Development Status :: 2 - Pre-Alpha - Intended Audience :: Science/Research - Topic :: Scientific/Engineering :: Image Recognition - License :: OSI Approved :: Apache Software License - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 -description = Learning on MRIQC-generated image quality metrics (IQMs). -license = Apache-2.0 -long_description = file:docs/about.rst -long_description_content_type = text/x-rst; charset=UTF-8 -name = mriqc-learn -url = https://github.com/nipreps/mriqc-learn - -[options] -python_requires = >=3.7 -install_requires = - numpy >=1.20, <1.22; python_version<'3.8' - numpy ~=1.20; python_version>='3.8' - joblib - pandas >=1.0, <1.4; python_version<'3.8' - pandas ~=1.0; python_version>='3.8' - scikit-learn ~= 1.0 -packages = find: -include_package_data = True -zip_safe = True - -[options.exclude_package_data] -* = tests - -[options.extras_require] -doc = - furo ~= 2021.10.09 - pydot - pydotplus - sphinx - sphinxcontrib-apidoc - sphinxcontrib-napoleon -docs = - %(doc)s -mem = - psutil - -test = - codecov - coverage - pytest - pytest-cov - pytest-env - pytest-xdist -tests = - %(test)s - -all = - %(doc)s - %(mem)s - %(test)s - -[options.package_data] -mriqc_learn = - datasets/*.tsv - -[flake8] -max-line-length = 99 -doctests = False -ignore = - W503 - E231 - E203 -exclude = - *build/ - docs/sphinxext/ - docs/tools/ -per-file-ignores = - **/__init__.py : F401 - docs/conf.py : E265 - -[tool:pytest] -norecursedirs = .git -addopts = -vsx --doctest-modules -doctest_optionflags = ALLOW_UNICODE NORMALIZE_WHITESPACE NUMBER -env = - PYTHONHASHSEED=0 -filterwarnings = - ignore::DeprecationWarning - ignore::PendingDeprecationWarning - ignore:cmp not installed:UserWarning - ignore:This has not been fully tested:UserWarning diff --git a/setup.py b/setup.py deleted file mode 100644 index 6076df6..0000000 --- a/setup.py +++ /dev/null @@ -1,28 +0,0 @@ -# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- -# vi: set ft=python sts=4 ts=4 sw=4 et: -# -# Copyright 2021 The NiPreps Developers -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# We support and encourage derived works from this project, please read -# about our expectations at -# -# https://www.nipreps.org/community/licensing/ -"""mriqc-learn setup script.""" - -if __name__ == "__main__": - """Install entry-point.""" - from setuptools import setup - - setup()