Fix tests
package being incorrectly included in builds
#3440
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When installing the latest version of flair through PyPI, I noticed that a
tests/
package could be found in my site-packages directory, and traced it back to flair.In
setup.py
, the exclusion list expects a list of exclusions, not a single excluded pathstr
. The end result is that before this PR, the exclusion list seems to be interpreted as an exclusion of"t", "e", "s"
instead of"tests"
...Now, for a reason that is beyond my understanding of Python packaging, with that fixed it would still listtests
under the site package'stop_level.txt
, andfrom tests import embedding_test_utils
would locally fail with an "unknown location" error rather than a "module not found" error.Not sure if this was some caching issue, but it was annoying nonetheless, thus:
I figured just listing the
flair
package underpackages=
would be just as good and might avoid some issues. It seems to work from my editable install testing, but I have not tested further.(The above was not valid: Submodules need to be specified too in regular (non-editable) installs, so
find_packages
is the way to go.)"tests.*"
has to be excluded too or the subpackages (apparently determined by the presence of a__init__.py
) still appear in the returned list. If only excluding["tests"]
, thenfrom tests import embedding_test_utils
would fail with an "unknown location" error rather than a proper "no module named 'tests'" error.To reproduce before this PR, try
from tests import embedding_test_utils
inside an environment with flair installed, with the working directory being outside of your install. It will find something to import, but that shouldn't have been the case.Note -- flair is honestly probably not the only package that encountered this issue, considering I accidentally found this diagnosing an issue with the same package name in SpeechBrain... So while testing, make sure yet another package in your environment is not also pulling a
tests
package. :)