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

Reloader using wrong python executable #1580

Closed
amcgavin opened this issue Jun 5, 2019 · 3 comments

Comments

@amcgavin
Copy link

commented Jun 5, 2019

Python version: 3.6.5
Werkzeug version: 0.15.4

The change made as a result of this PR, #1242, causes inconsistent behaviour when specifying how a script should be run.

sys.executable might not (validly) equal the file's shebang.
For example, a developer might want to test their program with a different version of python, or run under a different environment to where the program would be deployed.

The biggest use case is running a script with a debugger, as seen with this issue: #1493

The developer shouldn't be forced to change shebangs or to change the execute permissions of the file to make it work.

In summary, if an executable is specified, then that executable should be used; regardless of the file's shebang.

Since the intention was for this to work with NixOS, I propose that if the functionality is to remain then it should be exclusive to NixOS (where it was pointed out on the PR that it seems to be a problem with the OS), similarly to Windows.

@davidism

This comment has been minimized.

Copy link
Member

commented Jun 5, 2019

Remove the interpreter line and only use the desired python commands. Or use tox to configure venvs for tests, where python will always refer to the correct interpreter.

@amcgavin

This comment has been minimized.

Copy link
Author

commented Jun 6, 2019

I agree that there are ways to set this up so that it works correctly.

As mentioned in this issue, #1482 , the solution to make it work on NixOS doesn't feel right over all.

The file being executed shouldn't have the final say on how it should be executed.

I'm happy to open a PR, but at this stage I don't know how to satisfy all users without adding in an additional option.

@TomiBelan

This comment has been minimized.

Copy link

commented Jun 11, 2019

I also encountered this issue while trying to upgrade. In my case, I have a main script that starts with #!/usr/bin/env python. Until werkzeug 0.15, I could run it with either of these:

source venv/bin/activate
./run.py ...
venv/bin/python run.py ...

Both were equivalent. After #1242, this is no longer possible.

About the suggested fixes, tox doesn't fit because I don't have multiple venvs, and chmod -x run.py would fix the second way but break the first way. Also, the app doesn't have a setup.py (just requirements.txt) so I can't use entry_points.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.