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

vendoring: remove dependency on setuptools from vendored pytest #15612

Merged
merged 1 commit into from
Mar 23, 2020

Conversation

tgamblin
Copy link
Member

Closes #15369.
Closes #9034.
Follow-up of #9261.

Previously, spack test would fail within a new spack environment, because it could not import pkg_resources (part of setuptools) Parts of pytest use setuptools, but we do not need them for Spack, so it's an unnecessary dependency.

Patching pytest is nasty but it's a lot simpler than vendoring yet another mess of packages. Also, recent versions of pytest do not depend on setuptools (see pytest-dev/pytest#5063). We're just stuck with an old version of pytest because we still support Python 2.6.

Astute readers may note that jinja2 also uses pkg_resources, but we don't use any parts of it that actually import pkg_resources. So we do not need to remove these imports from jinja2.

  • Remove the parts of pytest that need setuptools

@tgamblin
Copy link
Member Author

@adamjstewart: can you try this out and see if it allows you to test within your spack environment successfully?

@scheibelp scheibelp self-assigned this Mar 21, 2020
@tgamblin tgamblin marked this pull request as ready for review March 21, 2020 06:02
@tgamblin
Copy link
Member Author

I'm able to get tests working in a bare python (no setuptools) environment using this and #15618.

Copy link
Member

@scheibelp scheibelp left a comment

Choose a reason for hiding this comment

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

This looks like it will work but IMO should be edited for clarity. Right now I think it's not clear from reading the code why turning these functions into noops is "OK" (i.e. why they don't cause the rest of the code to break).

lib/spack/external/__init__.py Outdated Show resolved Hide resolved
lib/spack/external/_pytest/config.py Outdated Show resolved Hide resolved
lib/spack/external/_pytest/vendored_packages/pluggy.py Outdated Show resolved Hide resolved
@tgamblin
Copy link
Member Author

@scheibelp: ready for re-review.

@tgamblin
Copy link
Member Author

I made some changes based on @scheibelp's comments that simplify this quite a bit.

Previously, `spack test` would fail within a new spack environment,
because it could not import `pkg_resources` (part of `setuptools`) Parts
of `pytest` use `setuptools`, but we do not need them for Spack, so it's
an unnecessary dependency.

- [x] Remove calls to parts of `pytest` that need setuptools
@tgamblin
Copy link
Member Author

@scheibelp: I removed both functions -- I suppose that does make it much less likely someone will reintroduce this bug.

@scheibelp scheibelp merged commit cde4375 into develop Mar 23, 2020
@scheibelp
Copy link
Member

Thanks!

@adamjstewart adamjstewart deleted the remove-pkg-resources branch March 24, 2020 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setuptools needs to be vendored
2 participants