pypa / pypa/setuptools

[FR] Warn about top-level "tests" package in find_packages() by default

Open
#3,243 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement Needs Triage
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

What's the problem this feature will solve?

I often end up reporting bugs about packages using find_packages() without appropriate exclusion lists, that end up installing top-level test or tests directories. These directories are especially problematic since they're bound to cause file collisions between packages, and given their special use I don't think any specific package should be allowed to "own" them.

Describe the solution you'd like

I think it would be best if setuptools could at least warn if find_packages() ends up including test or tests directories, and suggest the package maintainers to exclude them. Perhaps they could also be skipped by default in some future version.

Alternative Solutions

It could be possible to implicitly skip them immediately. While I honestly don't think it would realistically break anything, I'm not sure if someone isn't actually having some workflow relying on this.

Additional context

No response

Code of Conduct
  • I agree to follow the PSF Code of Conduct

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the find_packages() entry point and how it handles package discovery and exclusions. Review the issue's two proposed behaviors—warning about top-level test or tests packages versus skipping them—and identify the existing tests around that behavior. Done means the chosen behavior is implemented and covered without unexpectedly breaking current package-discovery workflows.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.