Skip to content

Conversation

@KumoLiu
Copy link
Contributor

@KumoLiu KumoLiu commented Oct 31, 2025

Fixes #8610.

Description

setuptools’ import chain requires more-itertools, but it isn’t installed when setup.py runs.
Edit pyproject.toml to include it under [build-system].

Types of changes

  • Non-breaking change (fix or new feature that would not break existing functionality).
  • Breaking change (fix or new feature that would cause existing functionality to change).
  • New tests added to cover the changes.
  • Integration tests passed locally by running ./runtests.sh -f -u --net --coverage.
  • Quick tests passed locally by running ./runtests.sh --quick --unittests --disttests.
  • In-line docstrings updated.
  • Documentation updated, tested make html command in the docs/ folder.

Signed-off-by: Yun Liu <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

Walkthrough

Added more-itertools>=8.0 to the [build-system] requires in pyproject.toml. Added a pip install step for more-itertools>=8.0 in .github/workflows/pythonapp-min.yml (min-dep-pytorch pipeline) during the Prepare pip wheel phase.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

  • Small, focused dependency addition and corresponding CI install step
  • Files to spot-check:
    • pyproject.toml (build-system requires entry)
    • .github/workflows/pythonapp-min.yml (new pip install step)

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Include more-itertools in build env" directly and specifically describes the main change in the pull request: adding the more-itertools package to the build environment via pyproject.toml's [build-system] section. It is concise, clear, and provides sufficient context for understanding the primary objective without being overly broad or vague.
Linked Issues Check ✅ Passed The pull request directly addresses the objective from linked issue #8610: ensuring more-itertools is available in the build environment to prevent the ModuleNotFoundError during setup.py execution. The changes add more-itertools>=8.0 to pyproject.toml's [build-system] requires and update the CI workflow accordingly, which directly resolves the setuptools import chain failure described in the issue.
Out of Scope Changes Check ✅ Passed All changes are directly in-scope and aligned with fixing issue #8610. The pyproject.toml modification adds more-itertools to [build-system] requires, addressing the root cause, and the .github/workflows/pythonapp-min.yml change ensures the dependency is available during CI testing. No extraneous or unrelated changes are present.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between bf7df0a and 1a7c76f.

📒 Files selected for processing (1)
  • .github/workflows/pythonapp-min.yml (1 hunks)
🔇 Additional comments (1)
.github/workflows/pythonapp-min.yml (1)

139-139: Review comment is incorrect.

The proper fix already exists in pyproject.toml under [build-system] requires, which includes "more-itertools>=8.0". When setup.py develop runs, setuptools automatically uses these build-system requirements. The explicit pip install in the min-dep-pytorch workflow step appears to be a job-specific workaround, not evidence of a missing systemic fix that all jobs need.

Likely an incorrect or invalid review comment.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 42a9947 and bf7df0a.

📒 Files selected for processing (1)
  • pyproject.toml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: min-dep-os (ubuntu-latest)
  • GitHub Check: min-dep-pytorch (2.8.0)
  • GitHub Check: min-dep-py3 (3.9)
  • GitHub Check: min-dep-os (macOS-latest)
  • GitHub Check: min-dep-py3 (3.12)
  • GitHub Check: min-dep-os (windows-latest)
  • GitHub Check: min-dep-py3 (3.10)
  • GitHub Check: min-dep-py3 (3.11)
  • GitHub Check: quick-py3 (ubuntu-latest)
  • GitHub Check: flake8-py3 (pytype)
  • GitHub Check: flake8-py3 (codeformat)
  • GitHub Check: quick-py3 (macOS-latest)
  • GitHub Check: packaging
  • GitHub Check: build-docs
  • GitHub Check: flake8-py3 (mypy)
  • GitHub Check: quick-py3 (windows-latest)

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR adds more-itertools>=8.0 as a build-time dependency to fix a ModuleNotFoundError that occurs during package installation. The error happened because setuptools' internal import chain requires more-itertools, but it wasn't available in the build environment.

Changes:

  • Added more-itertools>=8.0 to [build-system].requires in pyproject.toml

Analysis:
The fix correctly addresses issue #8610 by ensuring more-itertools is installed before setup.py runs. The version constraint >=8.0 is reasonable and aligns with modern setuptools requirements. This is a minimal, targeted fix that resolves the build failure without introducing unnecessary dependencies.

Confidence Score: 5/5

  • This PR is safe to merge with no risk - it's a minimal build configuration fix
  • Score reflects that this is a single-line addition to resolve a well-documented build failure, with no code logic changes, no breaking changes, and the fix directly addresses the root cause identified in the error traceback
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
pyproject.toml 5/5 Added more-itertools>=8.0 to build-system requirements to fix setuptools import dependency

Sequence Diagram

sequenceDiagram
    participant Build as Build System (pip/build)
    participant PyProject as pyproject.toml
    participant Setup as setup.py
    participant Setuptools as setuptools
    participant Jaraco as jaraco.functools
    participant MoreIter as more-itertools

    Build->>PyProject: Read [build-system].requires
    PyProject-->>Build: wheel, setuptools, more-itertools>=8.0, torch, ninja, packaging
    Build->>MoreIter: Install more-itertools>=8.0
    Build->>Setuptools: Install setuptools
    Build->>Setup: Execute setup.py
    Setup->>Setuptools: Import setuptools (line 21)
    Setuptools->>Jaraco: Import jaraco.functools
    Jaraco->>MoreIter: Import more_itertools
    Note over Jaraco,MoreIter: Previously failed here with ModuleNotFoundError
    MoreIter-->>Jaraco: Module loaded successfully
    Jaraco-->>Setuptools: Import successful
    Setuptools-->>Setup: Import successful
    Setup->>Build: Package build completes
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

Signed-off-by: Yun Liu <[email protected]>
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

This PR addresses a build failure in the min-dep-pytorch CI job caused by newer versions of setuptools requiring more-itertools as an internal dependency. The fix adds more-itertools>=8.0 installation before running setup.py.

Key Changes:

  • Added more-itertools>=8.0 to the pip installation step in the min-dep-pytorch workflow job
  • Also updated pyproject.toml to include more-itertools>=8.0 in the build-system requirements (previous commit)

Potential Issues:

  • The other two jobs in this workflow (min-dep-os and min-dep-py3) also call setup.py and may encounter the same error
  • min-dep-py3 explicitly upgrades setuptools, making it especially vulnerable to this issue
  • Consider applying the same fix to all three jobs for consistency

Confidence Score: 3/5

  • This PR is safe to merge but may not fully resolve the issue across all CI jobs
  • The fix correctly addresses the immediate build failure in the min-dep-pytorch job by installing more-itertools before setuptools attempts to import it. However, the same issue could occur in the other two jobs (min-dep-os and min-dep-py3) that also run setup.py. The min-dep-py3 job is particularly at risk since it explicitly upgrades setuptools.
  • .github/workflows/pythonapp-min.yml - Consider applying the more-itertools fix to all three workflow jobs for consistency

Important Files Changed

File Analysis

Filename Score Overview
.github/workflows/pythonapp-min.yml 3/5 Added more-itertools>=8.0 installation to fix setuptools import error in min-dep-pytorch job. The other two jobs (min-dep-os and min-dep-py3) may need the same fix.

Sequence Diagram

sequenceDiagram
    participant GH as GitHub Actions
    participant Env as Python Environment
    participant Pip as pip
    participant Setup as setuptools
    participant Script as setup.py
    
    GH->>Env: Set up Python 3.9
    GH->>Pip: pip install --user --upgrade pip setuptools wheel
    Note over Pip,Setup: setuptools is upgraded
    GH->>Pip: pip install --user more-itertools>=8.0
    Note over Pip: Fix: Install more-itertools<br/>before setup.py runs
    GH->>Script: python setup.py develop
    Script->>Setup: from setuptools import find_packages, setup
    Setup->>Setup: Import internal modules
    Note over Setup: setuptools requires<br/>more_itertools internally
    Setup-->>Script: Import successful
    Script-->>GH: MONAI installed in dev mode
Loading

Additional Comments (2)

  1. .github/workflows/pythonapp-min.yml, line 90 (link)

    logic: min-dep-py3 job also installs setuptools and calls setup.py (line 109), so it may encounter the same more_itertools import error

  2. .github/workflows/pythonapp-min.yml, line 41 (link)

    style: min-dep-os job calls setup.py (line 60) which imports setuptools, potentially encountering the same more_itertools error. Consider adding more-itertools>=8.0 here as well

1 file reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@KumoLiu KumoLiu requested a review from ericspod October 31, 2025 13:35
@KumoLiu
Copy link
Contributor Author

KumoLiu commented Oct 31, 2025

/build

Copy link
Member

@ericspod ericspod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to add this dependency and we'll revisit how dependencies are specifed later, eg. setuptools.

@KumoLiu KumoLiu enabled auto-merge (squash) October 31, 2025 15:28
@KumoLiu KumoLiu merged commit 09ace63 into Project-MONAI:dev Oct 31, 2025
27 checks passed
@KumoLiu KumoLiu deleted the fix-setuptools branch November 20, 2025 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No module named 'more_itertools'

2 participants