Skip to content

Commit

Permalink
maint: migrate to PEP517/518 packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
oesteban committed Nov 30, 2023
1 parent aa86b0b commit e06e636
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 169 deletions.
16 changes: 8 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,10 @@ jobs:
command: |
export PY3=$( pyenv versions | awk '/^\* 3/ { print $2 }' )
pyenv local $PY3
python3 -m pip install --upgrade setuptools setuptools_scm pip
python3 -m pip install -U build hatch hatchling pip twine docutils
# Get version, update files.
THISVERSION=$( python3 -m setuptools_scm )
THISVERSION=$( python3 -m hatch version | tail -n1 | xargs )
if [[ ${THISVERSION:0:1} == "0" ]] ; then
echo "WARNING: latest git tag could not be found"
echo "Please, make sure you fetch all tags from upstream with"
Expand All @@ -255,7 +255,7 @@ jobs:
export PY3=$( pyenv versions | awk '/^\* 3/ { print $2 }' )
pyenv local $PY3
# Get version, update files.
THISVERSION=$( python3 -m setuptools_scm )
THISVERSION=$( python3 -m hatch version | tail -n1 | xargs )
BUILT_VERSION=$( docker run --rm --entrypoint=python nipreps/sdcflows:latest -c "import sdcflows; print(sdcflows.__version__)" )
BUILT_VERSION=${BUILT_VERSION%$'\r'}
echo "VERSION: \"$THISVERSION\""
Expand Down Expand Up @@ -376,13 +376,13 @@ jobs:
command: |
python -m venv /tmp/venv
source /tmp/venv/bin/activate
python -m pip install -U pip setuptools setuptools_scm
pip install --no-cache-dir -r docs/requirements.txt
python -m pip install -U build hatch hatchling pip twine docutils
python -m pip install --no-cache-dir -r docs/requirements.txt
- run:
name: Build only this commit
command: |
source /tmp/venv/bin/activate
python -m setuptools_scm
python -m hatch version | tail -n1 | xargs
BRANCH=$( echo $CIRCLE_BRANCH | sed 's+/+_+g' )
make -C docs SPHINXOPTS="-W" BUILDDIR="$HOME/docs" OUTDIR=${CIRCLE_TAG:-$BRANCH} html
- store_artifacts:
Expand Down Expand Up @@ -422,7 +422,7 @@ jobs:
command: |
python -m venv /tmp/buildenv
source /tmp/buildenv/bin/activate
python -m pip install -U build twine setuptools_scm
python3 -m pip install -U build hatch hatchling pip twine docutils
python3 -m build
twine check dist/sdcflows*
- store_artifacts:
Expand All @@ -435,7 +435,7 @@ jobs:
name: Validate version
command: |
source /tmp/buildenv/bin/activate
THISVERSION=$( python -m setuptools_scm )
THISVERSION=$( python -m hatch version | tail -n1 | xargs )
python -m pip install dist/*.whl
mkdir empty
cd empty
Expand Down
5 changes: 4 additions & 1 deletion .git_archival.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
ref-names: $Format:%D$
node: $Format:%H$
node-date: $Format:%cI$
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
ref-names: $Format:%D$
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
sdcflows/_version.py export-subst
.git_archival.txt export-subst
6 changes: 3 additions & 3 deletions .github/workflows/docs-build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ jobs:
- name: Install dependencies
run: |
pip install -r docs/requirements.txt
pip install --no-cache-dir "setuptools ~= 45.0" "setuptools_scm[toml] >= 3.4"
python setup.py --version
python -m pip install -U build hatch hatchling pip docutils
python -m pip install -r docs/requirements.txt
python -m hatch version | tail -n1 | xargs
- name: Build docs
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docs-build-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ jobs:
- name: Install dependencies
run: |
pip install -r docs/requirements.txt
pip install --no-cache-dir "setuptools ~= 45.0" "setuptools_scm[toml] >= 3.4"
python setup.py --version
python -m pip install -U build hatch hatchling pip docutils
python -m pip install -r docs/requirements.txt
python -m hatch version | tail -n1 | xargs
- name: Build docs
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION=${GITHUB_REF##*/}
else
pip install setuptools_scm
VERSION=$( python -m setuptools_scm )
pip install -U build hatch hatchling pip twine docutils
VERSION=$( python -m hatch version | tail -n1 | xargs )
fi
echo version=$VERSION | tee -a $GITHUB_OUTPUT
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.12"]
python-version: ["3.10", "3.12"]
install: [repo, sdist, wheel, editable]

env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ jobs:
strategy:
max-parallel: 5
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12"]
deps: ["requirements"]
include:
- python-version: "3.8"
- python-version: "3.10"
deps: "min-requirements"

steps:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# setuptools-scm
sdcflows/_version.py
_version.py

# Byte-compiled / optimized / DLL files
pip-wheel-metadata
Expand Down
7 changes: 0 additions & 7 deletions MANIFEST.in

This file was deleted.

192 changes: 183 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,184 @@
[build-system]
requires = ["setuptools >= 42.0", "wheel", "setuptools_scm[toml] >= 3.4"]

[tool.setuptools_scm]
write_to = "sdcflows/_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 = "sdcflows"
description = "Susceptibility Distortion Correction (SDC) workflows for EPI MR schemes."
readme = "README.rst"
authors = [{name = "The NiPreps Developers", email = "[email protected]"}]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Image Recognition",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
license = "Apache-2.0"
requires-python = ">=3.10"
dependencies = [
"attrs >= 20.1.0",
"nibabel >=3.1.0",
"nipype >=1.8.5,<2.0",
"traits <6.4",
"niworkflows >= 1.7.0",
"nitransforms >= 23.0.1",
"numpy >= 1.21.0",
"pybids >= 0.15.1",
"scikit-image >= 0.18",
"scipy >= 1.8.1",
"templateflow",
]
dynamic = ["version"]

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

[project.optional-dependencies]
doc = [
"attrs >= 20.1.0",
"furo",
"importlib_resources",
"matplotlib >= 2.2.0",
"nibabel",
"nipype >= 1.5.1",
"traits < 6.4",
"niworkflows ~= 1.6.3",
"numpy",
"packaging",
"pydot >= 1.2.3",
"pydotplus",
"sphinx >= 7.2.2",
"sphinxcontrib-apidoc",
"templateflow"
]

mem = [
"psutil"
]

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

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

# Aliases
docs = ["sdcflows[doc]"]
tests = ["sdcflows[test]"]
all = ["sdcflows[doc,test,mem,dev,test]"]

[project.scripts]
sdcflows-find-estimators = "sdcflows.cli.find_estimators: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 = ["sdcflows"]
# exclude = [
# "sdcflows/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 = "sdcflows/_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
concurrency = 'multiprocessing'
omit = [
'*/tests/*',
'*/__init__.py',
'*/conftest.py',
'sdcflows/_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 e06e636

Please sign in to comment.