Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
maint: migrate to PEP517/518 packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
esavary committed Mar 12, 2024
1 parent bfb8fcc commit f8ec76d
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 166 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
11 changes: 5 additions & 6 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,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
pip install -U build hatch hatchling pip twine docutils
python -m build -s -w
python -m twine check dist/eddymotion-*
Expand All @@ -52,7 +51,7 @@ 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
Expand All @@ -61,7 +60,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 }}"
python -m pip install -U build hatch hatchling pip twine docutils
python -m pip install .
INSTALLED_VERSION=$(python -c 'import eddymotion as em; print(em.__version__, end="")')
echo "VERSION: \"${THISVERSION}\""
Expand All @@ -72,7 +71,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 build hatch hatchling pip twine docutils
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 +82,7 @@ jobs:
run: |
python -m venv /tmp/install_wheel
source /tmp/install_wheel/bin/activate
python -m pip install -U "setuptools >= 45" "${{ matrix.pip }}"
python -m pip install -U build hatch hatchling pip twine docutils
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
44 changes: 44 additions & 0 deletions .maint/update_requirements.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
from copy import copy
from pathlib import Path
from packaging.requirements import Requirement, SpecifierSet

try:
from tomllib import loads # Python +3.11
except ImportError:
from pip._vendor.tomli import loads

repo_root = Path(__file__).parent.parent
pyproject = repo_root / "pyproject.toml"
reqs = repo_root / "requirements.txt"
min_reqs = repo_root / "min-requirements.txt"

requirements = [
Requirement(req)
for req in loads(pyproject.read_text())["project"]["dependencies"]
]

script_name = Path(__file__).relative_to(repo_root)


def to_min(req):
if req.specifier:
req = copy(req)
try:
min_spec = [spec for spec in req.specifier if spec.operator in (">=", "~=")][0]
except IndexError:
return req
min_spec._spec = ("==",) + min_spec._spec[1:]
req.specifier = SpecifierSet(str(min_spec))
return req


lines = [f"# Auto-generated by {script_name}", ""]

# Write requirements
lines[1:-1] = [str(req) for req in requirements]
reqs.write_text("\n".join(lines))

# Write minimum requirements
lines[1:-1] = [str(to_min(req)) for req in requirements]
min_reqs.write_text("\n".join(lines))
12 changes: 0 additions & 12 deletions MANIFEST.in

This file was deleted.

10 changes: 10 additions & 0 deletions min-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Auto-generated by .maint/update_requirements.py
dipy==1.3.0
joblib
nipype==1.5.1
nitransforms==21.0.0
nireports
numpy==1.17.3
nest-asyncio==1.5.1
scikit-image==0.14.2
scipy==1.8.0
194 changes: 180 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,181 @@
[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 = [
"nbsphinx",
"packaging",
"pydot >= 1.2.3",
"pydotplus",
"sphinx >= 2.1.2",
"sphinx-argparse",
"sphinx_rtd_theme",
"sphinxcontrib-apidoc ~= 0.3.0",
"sphinxcontrib-napoleon",
"sphinxcontrib-versioning"
]

dev = [
"black~=22.3",
"flake8~=4.0",
"isort~=5.10",
"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]"]

[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 = ["eddymotion"]
# exclude = [
# "sdcflows/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',
'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"""
10 changes: 10 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Auto-generated by .maint/update_requirements.py
dipy>=1.3.0
joblib
nipype<2.0,>=1.5.1
nitransforms>=21.0.0
nireports
numpy>=1.17.3
nest-asyncio>=1.5.1
scikit-image>=0.14.2
scipy>=1.8.0
Loading

0 comments on commit f8ec76d

Please sign in to comment.