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 PEP517/518 packaging #128

Merged
merged 18 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
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
14 changes: 6 additions & 8 deletions .github/workflows/contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v2
- name: Set up Python 3
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install flake8
run: python -m pip install flake8
- name: Check EddyMotion
run: python -m flake8 src
python-version: 3
- name: Lint EddyMotion
run: pipx run flake8-pyproject
9 changes: 5 additions & 4 deletions .github/workflows/docs-build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:

jobs:
build:
if: "(github.repository_owner != 'nipreps') && !contains(github.event.head_commit.message, '[skip ci]')"
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -39,10 +39,11 @@ jobs:

- name: Install dependencies
run: |
pip install --no-cache-dir "setuptools >= 45.0" "setuptools_scm[toml] >= 6.2"
pip install -U build hatch pip
pip install -r docs/requirements.txt
python -m hatch version | tail -n1

- name: Build docs
run: |
python -m setuptools_scm # Generate _version.py file
python -m hatch build --hooks-only
make -C docs/ SPHINXOPTS="-W" BUILDDIR="$HOME/docs" OUTDIR="${CURBRANCH:-html}" html
5 changes: 3 additions & 2 deletions .github/workflows/docs-build-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ jobs:

- name: Install dependencies
run: |
pip install --no-cache-dir "setuptools >= 45.0" "setuptools_scm[toml] >= 6.2"
pip install -U build hatch pip
pip install -r docs/requirements.txt
python -m hatch version | tail -n1

- name: Build docs
run: |
python -m setuptools_scm # Generate _version.py file
python -m hatch build --hooks-only
make -C docs/ SPHINXOPTS="-W" BUILDDIR="$HOME/docs" OUTDIR="${CURBRANCH:-html}" html

- name: Push created tag to gh-pages
Expand Down
27 changes: 12 additions & 15 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,18 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
pip: ["pip==21.2", "pip~=22.0"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v2
- name: Fetch all tags (for setuptools_scm to work)
run: |
/usr/bin/git -c protocol.version=2 fetch --tags --prune --unshallow origin
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v1
- uses: actions/cache@v4
with:
path: $HOME/.cache/pip
key: pip-cache-v1
Expand All @@ -39,20 +38,18 @@ 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 pip twine

python -m build -s -w
python -m twine check dist/eddymotion-*

mv dist /tmp/package
rm -rf eddymotion.egg-info/

# Interpolate version
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 +58,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 }}"
pip install -U pip
python -m pip install .
INSTALLED_VERSION=$(python -c 'import eddymotion as em; print(em.__version__, end="")')
echo "VERSION: \"${THISVERSION}\""
Expand All @@ -72,7 +69,7 @@ jobs:
run: |
python -m venv /tmp/install_sdist
source /tmp/install_sdist/bin/activate
python -m pip install -U "setuptools >= 45" "${{ matrix.pip }}"
pip install -U pip
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 +80,7 @@ jobs:
run: |
python -m venv /tmp/install_wheel
source /tmp/install_wheel/bin/activate
python -m pip install -U "setuptools >= 45" "${{ matrix.pip }}"
pip install -U pip
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
48 changes: 48 additions & 0 deletions .maint/update_requirements.py
oesteban marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/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
Loading
Loading