Skip to content

fix(packaging): prevent unwanted files and tests from being installed#3911

Merged
DimitriPapadopoulos merged 1 commit intocodespell-project:mainfrom
mikelolasagasti:avoid-tools
Apr 14, 2026
Merged

fix(packaging): prevent unwanted files and tests from being installed#3911
DimitriPapadopoulos merged 1 commit intocodespell-project:mainfrom
mikelolasagasti:avoid-tools

Conversation

@mikelolasagasti
Copy link
Copy Markdown
Contributor

Disable implicit namespace discovery and exclude those dirs so dev-only paths like tools/gen_OX.sh are not installed as top-level packages.

@DimitriPapadopoulos
Copy link
Copy Markdown
Collaborator

What do you mean exactly by "installed as top-level packages"? I'm afraid I fail to understand which exact issue this PR solves.

Copy link
Copy Markdown
Collaborator

@DimitriPapadopoulos DimitriPapadopoulos left a comment

Choose a reason for hiding this comment

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

Also, codespell_lib/tests should be removed from the wheel.

"dist",
"snap",
"tools",
"example",
Copy link
Copy Markdown
Collaborator

@DimitriPapadopoulos DimitriPapadopoulos Apr 12, 2026

Choose a reason for hiding this comment

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

But then example is not currently included in the sdist or wheel. Why is that?

@mikelolasagasti mikelolasagasti changed the title fix(packaging): stop setuptools from shipping tools/ and example/ in wheels fix(packaging): prevent unwanted files and tests from being installed Apr 13, 2026
@mikelolasagasti
Copy link
Copy Markdown
Contributor Author

I changed the approach:

  • This ensures that non-Python files (like shell scripts in tools/) are not automatically pulled into the wheel just because they are tracked in Git. Only files explicitly listed in [tool.setuptools.package-data] will be included.
  • codespell_lib.tests is excluded based on your suggestion
  • explicitly defined the included packages and added tools and example to the exclusion list.

@DimitriPapadopoulos
Copy link
Copy Markdown
Collaborator

Changes in wheels look good to me: codespell_lib/tests and tools are gone.

As for sdists, would it be possible to get rid of the following items?

  • .devcontainer (?)
  • .github
  • .gitignore
  • .mailmap

@mikelolasagasti
Copy link
Copy Markdown
Contributor Author

I've amended the commit to include the sdist cleanup.

@DimitriPapadopoulos
Copy link
Copy Markdown
Collaborator

The contents of the sdist look rather good to me after the latest change to MANIFEST.in:

COPYING
MANIFEST.in
PKG-INFO
README.rst
codespell.egg-info/
codespell.egg-info/PKG-INFO
codespell.egg-info/SOURCES.txt
codespell.egg-info/dependency_links.txt
codespell.egg-info/entry_points.txt
codespell.egg-info/requires.txt
codespell.egg-info/top_level.txt
codespell_lib/
codespell_lib/__init__.py
codespell_lib/__main__.py
codespell_lib/_codespell.py
codespell_lib/_spellchecker.py
codespell_lib/_text_util.py
codespell_lib/_version.py
codespell_lib/data/
codespell_lib/data/__init__.py
codespell_lib/data/dictionary.txt
codespell_lib/data/dictionary_code.txt
codespell_lib/data/dictionary_en-GB_to_en-US.txt
codespell_lib/data/dictionary_en_to_en-OX_AUTOGENERATED.txt
codespell_lib/data/dictionary_informal.txt
codespell_lib/data/dictionary_names.txt
codespell_lib/data/dictionary_rare.txt
codespell_lib/data/dictionary_usage.txt
codespell_lib/data/linux-kernel.exclude
codespell_lib/py.typed
codespell_lib/tests/
codespell_lib/tests/__init__.py
codespell_lib/tests/data/
codespell_lib/tests/data/en_GB-additional.wordlist
codespell_lib/tests/data/en_US-additional.wordlist
codespell_lib/tests/test_basic.py
codespell_lib/tests/test_dictionary.py
pyproject.toml
setup.cfg
tools/
tools/gen_OX.sh
tox.ini

Perhaps add Makefile and .pre-commit-config.yaml to the list, as they are interest to developers? Wat do you think?

I believe the following files/directories are correctly ignored:

codecov.yml
codespell.1.include
.coveragerc
.devcontainer
.git-blame-ignore-revs
.github
.gitignore
.mailmap
example
snap

@DimitriPapadopoulos
Copy link
Copy Markdown
Collaborator

As for the wheel, it looks perfect:

codespell-2.4.2.dev.....dist-info/licenses/COPYING
codespell_lib/__init__.py
codespell_lib/__main__.py
codespell_lib/_codespell.py
codespell_lib/_spellchecker.py
codespell_lib/_text_util.py
codespell_lib/_version.py
codespell_lib/py.typed
codespell_lib/data/__init__.py
codespell_lib/data/dictionary.txt
codespell_lib/data/dictionary_code.txt
codespell_lib/data/dictionary_en-GB_to_en-US.txt
codespell_lib/data/dictionary_en_to_en-OX_AUTOGENERATED.txt
codespell_lib/data/dictionary_informal.txt
codespell_lib/data/dictionary_names.txt
codespell_lib/data/dictionary_rare.txt
codespell_lib/data/dictionary_usage.txt
codespell_lib/data/linux-kernel.exclude
codespell-2.4.2.dev.....dist-info/METADATA
codespell-2.4.2.dev.....dist-info/WHEEL
codespell-2.4.2.dev.....dist-info/entry_points.txt
codespell-2.4.2.dev.....dist-info/top_level.txt
codespell-2.4.2.dev.....dist-info/RECORD

@mikelolasagasti
Copy link
Copy Markdown
Contributor Author

Added .pre-commit-config.yaml, but Makefile was already excluded.

@DimitriPapadopoulos
Copy link
Copy Markdown
Collaborator

I'm sorry, I wasn't clear at all. I meant including Makefile and .pre-commit-config.yaml in the sdist (removing them from the exclude list in MANIFEST.in). Indeed, the sdist should be directly usable by developers.

@mikelolasagasti
Copy link
Copy Markdown
Contributor Author

Yeah, now I understand what you meant.

Copy link
Copy Markdown
Collaborator

@DimitriPapadopoulos DimitriPapadopoulos left a comment

Choose a reason for hiding this comment

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

Perhaps one last change for .pre-commit-config.yaml.

Refine package discovery and manifest exclusions to clean up both
wheels and source distributions (sdists):

- Dev-only paths like `tools/` and `example/` are not installed in
wheels.
- The `codespell_lib.tests` subpackage is excluded from the wheel.
- Only files explicitly listed in `package-data` are bundled in wheels.
- Dev metadata (.github, .devcontainer, .gitignore, .mailmap) is pruned
from sdists.

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
@DimitriPapadopoulos DimitriPapadopoulos merged commit aca223e into codespell-project:main Apr 14, 2026
17 checks passed
@DimitriPapadopoulos
Copy link
Copy Markdown
Collaborator

Thank you @mikelolasagasti.

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.

2 participants