Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

[Windows] Use console_scripts to generate portable wstool. #128

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 0 additions & 64 deletions scripts/wstool

This file was deleted.

4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def run(self):
},
# tests_require automatically installed when running python setup.py test
tests_require=test_required,
scripts=["scripts/wstool"],
entry_points = {
'console_scripts': ['wstool=wstool.wstool_cli:main']
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow, is this a new feature? 💃

Copy link
Author

Choose a reason for hiding this comment

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

This console_scripts seems to be a feature for a while (https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html), but since wstool mostly was used in the system supporting shebang so it probably doesn't matter to generate the console program stub.

However on Windows, it doesn't magically recognize it is a python script so people usually need to do "python wstool" to run it. With this console_scripts help, now on Windows you can also do "wstool". :)

Copy link
Contributor

Choose a reason for hiding this comment

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

🙌

},
author="Tully Foote",
author_email="tfoote@osrfoundation.org",
url="http://wiki.ros.org/wstool",
Expand Down
12 changes: 12 additions & 0 deletions src/wstool/wstool_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,15 @@ def wstool_main(argv=None, usage=None):

except KeyboardInterrupt:
return 1


def main():
try:
from .common import MultiProjectException
sys.exit(wstool_main(sys.argv))
except ImportError as exc:
sys.exit("ERROR: Cannot find required rosinstall library version, "
"check your installation (also of vcstools) is up-to-date. One frequent cause "
"is that rosinstall 0.5 is still installed in /usr/local/lib.\n%s" % exc)
except MultiProjectException as mpe:
sys.exit("ERROR in config: %s" % str(mpe))