Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: Migrate to hatchling #1070

Merged
merged 4 commits into from Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions .circleci/config.yml
Expand Up @@ -647,8 +647,7 @@ jobs:
command: |
python -m venv /tmp/venv
source /tmp/venv/bin/activate
python -m pip install -U build "setuptools >= 45" wheel "setuptools_scm >= 6.2" \
setuptools_scm_git_archive pip twine docutils
python -m pip install -U build hatch hatchling pip twine docutils
- run:
name: Build and check
command: |
Expand All @@ -659,7 +658,7 @@ jobs:
name: Validate version
command: |
source /tmp/venv/bin/activate
THISVERSION=$( python3 -m setuptools_scm )
THISVERSION=$( python3 -m hatch version | tail -n1 | xargs )
python -m pip install dist/*.tar.gz
mkdir empty
cd empty
Expand All @@ -677,15 +676,14 @@ jobs:
command: |
python -m venv /tmp/venv
source /tmp/venv/bin/activate
python -m pip install -U build "setuptools >= 45" wheel "setuptools_scm >= 6.2" \
setuptools_scm_git_archive pip twine docutils
python -m pip -U hatch hatchling pip twine docutils
- run:
name: Deploy to PyPi
command: |
source /tmp/venv/bin/activate

# Set version on stone before editing the bundle
export SETUPTOOLS_SCM_PRETEND_VERSION=$( python -m setuptools_scm )
export SETUPTOOLS_SCM_PRETEND_VERSION=$( python3 -m hatch version | tail -n1 | xargs )

# Inject MRIQC-WebAPI secret
if [ "${MRIQC_API_SECRET_TOKEN}" != "" ]; then
Expand Down
19 changes: 9 additions & 10 deletions .github/workflows/pythonpackage.yml
Expand Up @@ -16,8 +16,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
pip: ["pip==21.2", "pip~=22.0"]
python-version: ['3.8', '3.9', '3.11']
pip: ["pip==21.2", "pip~=23.0"]

steps:
- uses: actions/checkout@v2
Expand All @@ -38,8 +38,7 @@ 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
python -m pip install -U build hatch hatchling pip twine docutils

python -m build -s -w
python -m twine check dist/mriqc-*
Expand All @@ -49,15 +48,15 @@ jobs:
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
- name: Install in confined environment [pip]
run: |
python -m venv /tmp/pip
source /tmp/pip/bin/activate
python -m pip install -U "setuptools >= 45" "setuptools_scm >= 6.2" "${{ matrix.pip }}"
python -m pip install -U hatch hatchling "${{ matrix.pip }}"
python -m pip install .
INSTALLED_VERSION=$(python -c 'import mriqc as qc; print(qc.__version__, end="")')
echo "VERSION: \"${THISVERSION}\""
Expand All @@ -67,7 +66,7 @@ jobs:
run: |
python -m venv /tmp/install_sdist
source /tmp/install_sdist/bin/activate
python -m pip install -U "setuptools >= 45" "${{ matrix.pip }}"
python -m pip install -U hatch hatchling "${{ matrix.pip }}"
python -m pip install /tmp/package/mriqc*.tar.gz
INSTALLED_VERSION=$(python -c 'import mriqc as qc; print(qc.__version__, end="")')
echo "VERSION: \"${THISVERSION}\""
Expand All @@ -87,9 +86,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.7
- run: pip install flake8
python-version: 3.9
- run: pip install flake8-pyproject
- run: flake8 mriqc/
219 changes: 205 additions & 14 deletions pyproject.toml
@@ -1,15 +1,206 @@
[build-system]
requires = [
"setuptools >= 45",
"setuptools_scm[toml] >= 6.2",
"wheel"
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "mriqc/_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"
description = "Automated Quality Control and visual reports for Quality Assessment of structural (T1w, T2w) and functional MRI of the brain."
readme = "README.rst"
authors = [{name = "The NiPreps Developers", email = "nipreps@gmail.com"}]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Image Recognition",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10"
]
license = "Apache-2.0"
requires-python = ">=3.8"
dependencies = [
'importlib_resources; python_version < "3.9"',
# jinja2 imports deprecated function removed in 2.1
"markupsafe ~= 2.0.1",
"matplotlib",
"migas",
"mriqc-learn",
"nibabel >= 3.0.1,<4.0",
"nilearn >= 0.5.1",
"nipype ~= 1.4",
"nitransforms >= 21.0.1",
"niworkflows ~= 1.7.1",
"nitransforms ~= 21.0.1",
"numpy ~=1.20",
"pandas ~=1.0",
"pybids >= 0.15.6",
"PyYAML",
"scipy ~=1.8",
"statsmodels",
"toml",
"torch >= 1.10.2",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://github.com/nipreps/mriqc"
NiPreps = "https://www.nipreps.org/"
Documentation = "https://mriqc.readthedocs.io/"
Manuscript = "https://doi.org/10.1371/journal.pone.0184661"
"Sci Dat Paper" = "https://doi.org/10.1038/s41597-019-0035-4"
"Web API" = "https://mriqc.nimh.nih.gov/"
"Docker Images" = "https://hub.docker.com/r/nipreps/mriqc/tags/"

[project.optional-dependencies]
doc = [
"nipype",
"packaging",
"pydot>=1.2.3",
"pydotplus",
"sphinx-argparse",
"sphinx_rtd_theme",
"sphinx~=4.0",
]

full = [
"dipy<=1.4.0", # see nipreps/mriqc#969; can be removed if nipype>1.7.0
"nitime",
"nirodents >= 0.2.8",
"scikit-learn ~= 1.0",
"seaborn",
"templateflow",
"xvfbwrapper",
]

notebook = [
"ipython",
"jupyter",
"nipy",
]

dev = [
"black ~= 22.3.0",
"pre-commit",
"isort ~= 5.10.1",
"flake8-pyproject",
]

test = [
"coverage",
"mock",
"pytest",
"pytest-cov",
"pytest-xdist",
]

other = [
"scikit-image",
]

# Aliases
docs = ["mriqc[doc]"]
tests = ["mriqc[test]"]
others = ["mriqc[other]"]
all = ["mriqc[doc,full,test,notebook,other]"]

[project.scripts]
mriqc = "mriqc.cli.run:main"
synthstrip = "mriqc.synthstrip.cli:main"
mriqc_plot = "mriqc.bin.mriqc_plot:main"
abide2bids = "mriqc.bin.abide2bids:main"
fs2gif = "mriqc.bin.fs2gif:main"
dfcheck = "mriqc.bin.dfcheck:main"
nib-hash = "mriqc.bin.nib_hash:main"
participants = "mriqc.bin.subject_wrangler:main"
mriqc_labeler = "mriqc.bin.labeler:main"
mriqcwebapi_test = "mriqc.bin.mriqcwebapi_test:main"

#
# 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"]
# exclude = [
# "mriqc/tests/data", # Large test data directory
# ]

## The following two sections configure setuptools_scm in the hatch way

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

[tool.hatch.build.hooks.vcs]
version-file = "mriqc/_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/"
ignore = ["W503", "E203"]
per-file-ignores = [
"**/__init__.py : F401",
"docs/conf.py : E265",
]

[tool.pytest.ini_options]
norecursedirs = [".git"]
addopts = "-svx --doctest-modules"
doctest_optionflags = "ALLOW_UNICODE NORMALIZE_WHITESPACE ELLIPSIS"
env = "PYTHONHASHSEED=0"
filterwarnings = ["ignore::DeprecationWarning"]
junit_family = "xunit2"


[tool.coverage.run]
branch = true
omit = [
'*/tests/*',
'*/__init__.py',
'*/conftest.py',
'mriqc/_version.py'
]

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