Skip to content

Commit

Permalink
Merge pull request #410 from nipreps/maint/migrate-to-pep517-8
Browse files Browse the repository at this point in the history
MAINT: Migrate to PEP517/518 packaging
  • Loading branch information
oesteban authored Nov 30, 2023
2 parents aa86b0b + b75f288 commit f3b376d
Show file tree
Hide file tree
Showing 17 changed files with 252 additions and 243 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
18 changes: 11 additions & 7 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 Expand Up @@ -125,8 +125,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3
- run: pipx run flake8 sdcflows/
- run: pipx run flake8-pyproject sdcflows/

# codespell:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: codespell-project/actions-codespell@v2
10 changes: 2 additions & 8 deletions .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deps & CI
name: CI

on:
push:
Expand Down Expand Up @@ -31,15 +31,10 @@ jobs:
AFNI_TTATLAS_DATASET: /opt/afni/atlases
AFNI_PLUGINPATH: /opt/afni/plugins
ANTSPATH: /opt/ants
DEPS: ${{ matrix.deps }}.txt
strategy:
max-parallel: 5
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
deps: ["requirements"]
include:
- python-version: "3.8"
deps: "min-requirements"
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/cache@v3
Expand Down Expand Up @@ -117,7 +112,6 @@ jobs:
- name: Install dependencies
timeout-minutes: 5
run: |
pip install -r $DEPS
pip install .[tests]
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
12 changes: 7 additions & 5 deletions .maint/update_requirements.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
#!/usr/bin/env python3
from copy import copy
from configparser import ConfigParser
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
setup_cfg = repo_root / "setup.cfg"
pyproject = repo_root / "pyproject.toml"
reqs = repo_root / "requirements.txt"
min_reqs = repo_root / "min-requirements.txt"

config = ConfigParser()
config.read(setup_cfg)
requirements = [
Requirement(req)
for req in config.get("options", "install_requires").strip().splitlines()
for req in loads(pyproject.read_text())["project"]["dependencies"]
]

script_name = Path(__file__).relative_to(repo_root)
Expand Down
7 changes: 0 additions & 7 deletions MANIFEST.in

This file was deleted.

1 change: 0 additions & 1 deletion min-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Auto-generated by .maint/update_requirements.py
attrs==20.1.0
importlib_resources==5.7; python_version < "3.11"
nibabel==3.1.0
nipype==1.8.5
traits<6.4
Expand Down
Loading

0 comments on commit f3b376d

Please sign in to comment.