Warn user in case of "installed package" shadowed by "source package" #1449
Labels
feature:new
something does not exist yet, but should
help:wanted
Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Hello,
I've crossed numerous times the dangerous "installed package shadowed by source package" bug as described in #514
In some rare cases (eg. if the code needed to be transformed with 2to3 in setup.py), this raised an error and I could fix my pythonpath accordingly.
But most of the time, the error was silent, so I ended up testing the source package, not the installed one, with a risk of pushing to Pypi an incomplete/broken package.
I know the pythonpath problem can't be solved by Tox alone (despite nice protections like blocking PYTHONPATH transfer by default), since many factors are at work here: python adding (or not) cwd() to sys.path, pytest/nose and its plugins adding directories as they are discovered (eg. those with a conftest.py in it), presence of sources at the root of repository or in a "src/" subfolder... so the Tox configuration has to make sure that the final test launches occur in an environment without unwanted sys.path folders. But I guess that users could be warned when their conf is broken.
Would it be possible to automatically issue a check after virtualenv/install steps, to force an import on the "installed package" (no idea what's the best way to determine its name), and raise an exception if the imported package is not located in the "site-packages/" directory of the Tox virtualenv?
Maybe this check could be silenced by users on demand (though I can't think of a case when installing outsie the virtualenv is expected...), but having this safety by default would be invaluable (for now I add my own pytest test to check that).
The text was updated successfully, but these errors were encountered: