Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include tests in PyPI tarball #68

Closed
kwshi opened this issue Jul 22, 2021 · 3 comments · Fixed by #69
Closed

Include tests in PyPI tarball #68

kwshi opened this issue Jul 22, 2021 · 3 comments · Fixed by #69
Assignees
Labels
enhancement New feature or request

Comments

@kwshi
Copy link
Contributor

kwshi commented Jul 22, 2021

Currently, the PyPI source archive does not contain the tests for pytest-socket:

> curl -fsSL 'https://files.pythonhosted.org/packages/source/p/pytest-socket/pytest-socket-0.4.0.tar.gz' | tar -tz
pytest-socket-0.4.0/LICENSE
pytest-socket-0.4.0/README.md
pytest-socket-0.4.0/pyproject.toml
pytest-socket-0.4.0/pytest_socket.py
pytest-socket-0.4.0/setup.py
pytest-socket-0.4.0/PKG-INFO

OS/distribution package vendors rely on package tests to validate sanity/functionality of packages; as such, it would be a good idea to ship these tests together with the rest of the source. It can be done by adding the following line to pyproject.toml (documentation here):

include = [{ path = "tests", format = "sdist" }]
@miketheman
Copy link
Owner

@kwshi Thank you for raising this!

I appreciate the position package vendors have in this regard.

Reading more about this inclusion, I don't understand how the source distribution will know which test dependencies to install, as I do not see hat key in the generated setup.py file.

These dependencies are necessary for the project to run tests, how does the package vendor get notified of them?

@miketheman miketheman added the enhancement New feature or request label Jul 27, 2021
@kwshi
Copy link
Contributor Author

kwshi commented Jul 27, 2021

@miketheman Great question--there's two parts to this answer:

  • How to get poetry to add a tests_require key in the generated setup.py? I did some digging, and I could not figure out an answer--for some reason, nobody else has asked this question, and the current version of Poetry doesn't seem to have this feature documented anywhere, even if it has it. There was Support dependencies groups python-poetry/poetry#1644 raised on the Poetry repository, in response to which "dependency groups" were recently implemented in the (unstable) development branch of Poetry (see also Feature roadmap python-poetry/poetry#1856 (comment)) and documented here, but this feature is not released yet, and it's unclear as to whether Poetry itself will actually make use of this feature in its setup.py generation step. There are also some suggestions here and there to specify test dependencies in a test key under tool.poetry.extras, but then it gets treated not as a test dependency so much as just a regular optional dependency.
  • OS vendors specifically know about test dependencies because they are all manually specified upon being added to the package repository (as such, packages generally require manual attention from maintainers in the sense of manually checking upstream for updates, making sure dependencies are correct, etc.) As an example, you can see the line that specifies the test dependencies for python3-wheel in the void-packages repository here: https://github.com/void-linux/void-packages/blob/5f0ed9f35fbbf2313205b2fc942942c870739e04/srcpkgs/python3-wheel/template#L9. So from the vendor perspective it's not essential for setup.py to actually specify test dependencies (since they are manually recorded); only for the sdist bundle to include the test files so it can run them.

On a related note: the tests_require key in setup.py has been long since deprecated--not sure why--but also seems to have reappeared as an allowed key in the newer setup.cfg configuration format? Not sure what's going on there, but it seems from the first decision to deprecate tests_require in setup.py that those folks are not interested in specifying test dependencies within setup.py either.

@miketheman
Copy link
Owner

@kwshi Excellent response, thanks! I'll be happy to incorporate this change soon and release a patch version package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants