Skip to content

Add tests/test*.py to sdist default inclusion list - #2494

Closed
tomchen wants to merge 2 commits into
pypa:mainfrom
tomchen:main
Closed

tomchen wants to merge 2 commits into
pypa:mainfrom
tomchen:main

Conversation

@tomchen

@tomchen tomchen commented Dec 20, 2020 •

Copy link
Copy Markdown

Summary of changes

By default, all files matching the pattern test/test*.py (not tests/test*.py) are included in the source distribution (sdist). This is documented in Python Packaging User Guide's "Including files in source distributions with MANIFEST.in" page.

But, both pypa/sampleproject and Python Packaging User Guide's "Packaging Python Projects" page suggest the unit test folder be named tests.

I opened the issue pypa/sampleproject#133, it looks clear that tests is a more common name than test, and it may avoid conflicting with the test standard library module according to some.

Therefore, I request to add "tests/test*.py" to sdist default inclusion list. And "test/test*.py" should be kept for compatibility with old repos.

Pull Request Checklist

self.warn("standard file '%s' not found" % fn)

def _add_defaults_optional(self):
optional = ['test/test*.py', 'setup.cfg']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unfortunately, it's not allowed to make changes to distutils here. If you wish to make changes to distutils, they need to happen in the pypa/distutils project.

"""Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's a docstring in this code saying not to change this code.

@jaraco

jaraco commented Dec 20, 2020

Copy link
Copy Markdown
Member

Probably this issue requires more discussion. It's intertwined with the effort to adopt distutils and the copy of distutils functionality in the compat module. Making this change will add more divergence between distutils implementations. I'm inclined to say it would be best to wait for this change until setuptools owns distutils, at which time fine-tuning such a list would be more straightforward.

I do agree with you, the default of 'test' versus 'tests' violates my expectations, but this shift in expectations happened in spite of 'test' being included as a default for a very long time. Perhaps the better approach here would be to just remove all special files and simply require the user to use setuptools_scm or maintain a manifest of all the sources. After all, fixing this change still doesn't help users who have a pyproject.toml or those who choose a different convention for their tests.

The recommended usage here is for the packager to use setuptools_scm or provide a MANIFEST.in with the relevant rules.

Since neither of these code bases are meant to be changed here, I'm going to decline the PR.

Thanks anyhow for the effort.

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