Skip to content

Commit

Permalink
Merge pull request #1627 from frostming/bugfix/1614
Browse files Browse the repository at this point in the history
Fix the bug of reloader with windows path
  • Loading branch information
davidism committed Aug 31, 2019
2 parents 8cfab30 + 87da8da commit ab1b556
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
.. currentmodule:: werkzeug

Version 0.15.6
--------------

Unreleased

- Work around a bug in pip that caused the reloader to fail on
Windows when the script was an entry point. This fixes the issue
with Flask's `flask run` command failing with "No module named
Scripts\flask". :issue:`1614`


Version 0.15.5
--------------

Expand Down
12 changes: 9 additions & 3 deletions src/werkzeug/_reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ def _get_args_for_reloading():
__main__ = sys.modules["__main__"]

# The value of __package__ indicates how Python was called. It may
# not exist if a setuptools script is installed as an egg.
if getattr(__main__, "__package__", None) is None:
# not exist if a setuptools script is installed as an egg. It may be
# set incorrectly for entry points created with pip on Windows.
if getattr(__main__, "__package__", None) is None or (
os.name == "nt"
and __main__.__package__ == ""
and not os.path.exists(py_script)
and os.path.exists(py_script + ".exe")
):
# Executed a file, like "python app.py".
py_script = os.path.abspath(py_script)

Expand All @@ -83,7 +89,7 @@ def _get_args_for_reloading():
py_script += ".exe"

if (
os.path.splitext(rv[0])[1] == ".exe"
os.path.splitext(sys.executable)[1] == ".exe"
and os.path.splitext(py_script)[1] == ".exe"
):
rv.pop(0)
Expand Down

0 comments on commit ab1b556

Please sign in to comment.