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: Initate porting to PEP517/8 #24

Merged
merged 2 commits into from
Aug 20, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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}\""
Expand All @@ -43,18 +46,19 @@ 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}\""
test "${INSTALLED_VERSION}" = "${THISVERSION}"

deploy_pypi:
docker:
- image: cimg/python:3.8.5
- image: cimg/python:3.11
working_directory: /tmp/src/mriqc_learn
steps:
- attach_workspace:
Expand Down
78 changes: 30 additions & 48 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
165 changes: 156 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"}]
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"""
Loading