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
be more careful with PYTHONPATH when invoking flask #161
Conversation
I don't think it is a good idea to override PYTHONPATH. Basically this change prevents the caller to ever set a custom path. Sounds like you are patching this side because it is easier, when the problem is somewhere else. Why is the PYTHONPATH wrong in this specific case? |
I agree this is a hack. The problem is a total mess though. Here's what's happening in excruciating detail:
Basically everything is horrible (I realise now that my patch probably means that the flask-migrate code is not really tested under python 2.7 at all in these test cases now -- maybe running sys.executable -m flask instead of just 'flask' would work better... |
Why is the flask tool configured to run on Python3? When I install Flask on a Python 2.7 virtualenv I get the shebang line set to 2.7. |
On a given system, the flask binary on the global PATH is going to be one or the other. If it was 2.7 we'd just have the problem when running the Python 3 tests. |
I've pushed what looks like a better fix to me (insanely repetitive, but the idea is clear and it works). Out of time for this week now, sorry. |
The Ubuntu package of Flask-Migrate failed in a rather strange way because the PYTHONPATH that setuptools sets when running the python 2.7 tests via "python2.7 setup.py test" was causing the /usr/bin/flask to look in various 2.7-specific locations for modules and failing. This runs sys.executable -m flask and not the global flask, which means flask for the correct version of python is tested even when not operating in a virtualenv.
9805555
to
5d19519
Compare
I was just reminded of this PR and I've just pushed a new version. Any updates from your side? |
As I mentioned before, overriding the PYTHONPATH is guaranteed to affect users that need it set in a specific way. Packages are not supposed to rely on this variable, this is for end users to set. As I said, the problem is not in this package, if Ubuntu used virtual environments to run unit tests, or allowed you to set the PYTHONPATH before running the tests, then we wouldn't be talking about this. |
This issue will be automatically closed due to being inactive for more than six months. Please reopen if you need more assistance. |
The Ubuntu package of Flask-Migrate failed in a rather strange way because
the PYTHONPATH that setuptools sets when running the python 2.7 tests via
"python2.7 setup.py test" was causing the /usr/bin/flask to look in various
2.7-specific locations for modules and failing. This patch overrides the
PYTHONPATH setuptools sets to just '..'.