[CI] Prevent tmp_src test fixture from copying the .git/.tox and other heavy folders#2922
[CI] Prevent tmp_src test fixture from copying the .git/.tox and other heavy folders#2922abravalheri wants to merge 2 commits intopypa:mainfrom
tmp_src test fixture from copying the .git/.tox and other heavy folders#2922Conversation
The `tmp_src` fixture copies the setuptools directory to prevent errors that appear when running tests concurrently. However it seems that is copying everything including the `.git` directory (and possibly others like `.tox`). These directories can be quite heavy and error prone to copy. The changes introduced here prevent copying these unnecessary folders/files. As a side effect, the tests should run slightly faster.
tmp_src test fixture from copying the .git/.tox and other heavy folders
|
There is value to copying the git metadata. If Setuptools were using setuptools_scm for file discovery or version attribution (both of which I'd like to adopt here if not for bootstrapping issues), the git directory would be necessary. If this PR is adopted, it will introduce an impediment to adopting setuptools_scm. I could also imagine other scenarios down the road where a I definitely see the value in excluding I do note that checking out a shallower version of the repo could save some (most?) of this cost. I wonder if it would be possible instead, in order to avoid copying the source tree, to simply implement a lock, so that only one test at a time can rely on the source tree, saving the copying altogether (but losing the benefit of parallelism for those tests). I wonder if pytest-xdist has a feature that you can take tests that should not be run together - that would be even more efficient, allowing xdist to chose tests that can be run in parallel while deferring those that would conflict. |
|
Thank you very much for the review and discussion @jaraco, I can clearly (and agree with) your points.
In some cases that might help, but the
It seems that the latest versions of Another approach that can be worthy exploring is setting (for each test) the following options in a I believe these are the directories that end up being populated during the build, right? The approach with the What would be your opinion on this? |
|
I think I found a better approach, so I will close this PR in favour of #2968. |
The
tmp_srcfixture copies the setuptools directory to prevent errors that appear when running tests concurrently. However it seems that is copying everything including the.gitdirectory (and possibly others like.tox). These directories can be quite heavy and error prone to copy.The changes introduced here prevent copying these unnecessary folders/files. As a side effect, the tests should run slightly faster.
Summary of changes
tmp_srcfixture, instead of blindly usingshutil.copytree, glob the src directory and copy entry-by-entry, if they are not hidden or unnecessary file/folders.Closes #2921
Pull Request Checklist
changelog.d/.(See documentation for details)