Skip to content

Excluded from MANIFEST.in and setup.py tests folder and subfolders.#8807

Open
ffvogmv wants to merge 1 commit intoProject-MONAI:devfrom
ffvogmv:dev
Open

Excluded from MANIFEST.in and setup.py tests folder and subfolders.#8807
ffvogmv wants to merge 1 commit intoProject-MONAI:devfrom
ffvogmv:dev

Conversation

@ffvogmv
Copy link
Copy Markdown

@ffvogmv ffvogmv commented Apr 6, 2026

Fixes Tests are installed as a package

Description

This pull request resolves an issue introduced in commit af9e8f96d704a1b4bbce5b5ca52e0e2b7ea076dc, where the tests directory was inadvertently included as an installable package starting from MONAI 1.5.0, due to the refactor on tests that created multiple subfolders with __init__.py files on them.

This caused import conflicts in downstream projects with their own local tests folder, as Python could mistakenly resolve imports to MONAI’s packaged tests module.

To correct this behavior, the following adjustments are made:

  • MANIFEST.in updated to exclude the tests directory:
    exclude tests/*
  • setup.py updated to prevent inclusion of tests and its subpackages:
    packages = find_packages(exclude=("docs", "examples", "tests", "tests.*"))

These changes ensure that the MONAI test suite is not installed as part of the distributed package, restoring expected import resolution for downstream users.

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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

The pull request modifies packaging configuration to exclude test files and packages from source distributions. MANIFEST.in now explicitly excludes tests/* to prevent test files from being included. setup.py extends the find_packages() exclusion tuple from ("docs", "examples", "tests") to ("docs", "examples", "tests", "tests.*"), ensuring test subpackages are also excluded from discovery.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Title accurately describes the main change: excluding tests from packaging configurations in both MANIFEST.in and setup.py.
Description check ✅ Passed Description fully addresses the template with detailed context, clear problem statement, specific code changes, and types of changes checklist completed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@MANIFEST.in`:
- Line 3: Replace the problematic MANIFEST.in pattern "exclude tests/*" with the
correct directive "prune tests" so the entire tests directory (including nested
files and subdirectories) is excluded from source distributions; update the
MANIFEST.in entry that currently contains exclude tests/* to use prune tests
instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 905678a6-a4bf-4a65-a9f7-f84cffc752e8

📥 Commits

Reviewing files that changed from the base of the PR and between 8d39519 and d08daa2.

📒 Files selected for processing (2)
  • MANIFEST.in
  • setup.py

include versioneer.py
include monai/_version.py

exclude tests/*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In setuptools MANIFEST.in, does exclude tests/*match files in nested subdirectories, and isprune tests the correct way to exclude the full tests tree from sdist?

💡 Result:

  • exclude tests/* will not match files in nested subdirectories like tests/unit/test_x.py; in MANIFEST.in glob patterns, * does not match path separators (so it only matches the immediate children of tests/). [1]
  • To exclude the entire top-level tests/ tree from the sdist, prune tests is the appropriate directive (it removes all files under directories matching tests, relative to the project root). [1]
  • Alternative equivalent: recursive-exclude tests * (remove everything under tests/). [1]

Source: Setuptools MANIFEST.in command and glob semantics documentation. [1]


Use prune tests instead of exclude tests/* to exclude the entire tests directory from sdist.

The * pattern in MANIFEST.in does not match path separators, so exclude tests/* only excludes immediate children and will miss nested files like tests/unit/test_x.py.

Proposed fix
-exclude tests/*
+prune tests
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@MANIFEST.in` at line 3, Replace the problematic MANIFEST.in pattern "exclude
tests/*" with the correct directive "prune tests" so the entire tests directory
(including nested files and subdirectories) is excluded from source
distributions; update the MANIFEST.in entry that currently contains exclude
tests/* to use prune tests instead.

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.

1 participant