Skip to content

Commit

Permalink
FIX for OS=Windows: Rename __main__.py => main.py, causes problems w/…
Browse files Browse the repository at this point in the history
… script on windows.
  • Loading branch information
jenisys committed Feb 21, 2012
1 parent eb5011b commit c8575a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ _build
.ropeproject
tools/virtualenvs
build.log
.idea/*
File renamed without changes.
5 changes: 3 additions & 2 deletions bin/behave
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from behave.__main__ import main
from behave.main import main

main()
if __name__ == "__main__":
main()

2 comments on commit c8575a5

@jeamland
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you be more specific about what this fixes?

The __main__.py idiom is a documented thing for Python (see http://docs.python.org/release/2.7.3/using/cmdline.html) and if it's not working on Windows I'd like to see if there's another way to fix it.

@jenisys
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several issues using behave on Windows.
After installation, the "behave" script does not work, because it is only made for UNIX-like system
and not converted during installation.
Because Windows does not honor Shebang, the script cannot be executed.
When I manually fixed it by providing a behave.py and behave.cmd script,
I ran into a problem with using "main" to import the main() function.
After I renamed it to "main.py", it did not longer run into this problem again.
I didn't investigate it further.

ADDITIONAL PROBLEMS on Windows:

  • setup.py install related: script="behave" has no "*.py" extension, better use "console_scripts" (setup tools/distribute).
    This results in better platform-independence.
  • Strange behaviour when no steps directory is present / path specified behave/behave#37: Root directory discovery is not working due to POSIX, causing an endless loop (detectable via a runner test)
  • Missing os.path.normpath() conversions in the test suite, as far as I recall it.

Please sign in to comment.