From 8f31be9888e8e82a0c0ebbfdd1ac5911f4d4e073 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Mon, 7 Dec 2015 13:45:13 +0200 Subject: [PATCH] Use entry_points instead of scripts for cross-platform compatibility This makes `tx` work right out of the box when you `pip install transifex-client` on Windows. --- contrib/tx.spec | 2 +- setup.py | 2 +- tx => txclib/cmdline.py | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) rename tx => txclib/cmdline.py (97%) diff --git a/contrib/tx.spec b/contrib/tx.spec index 3febf6d2..b743f1ba 100644 --- a/contrib/tx.spec +++ b/contrib/tx.spec @@ -5,7 +5,7 @@ added_files = [ ('../txclib/cacert.pem', 'txclib'), ] -a = Analysis(['../tx'], +a = Analysis(['../txclib/cmdline.py'], binaries=None, datas=added_files, hiddenimports=[], diff --git a/setup.py b/setup.py index 6ccf510f..5bb14526 100755 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def get_file_content(filename): setup( name="transifex-client", version=txclib.__version__, - scripts=['tx'], + entry_points={'console_scripts': ['tx=txclib.cmdline:main']}, description="A command line interface for Transifex", long_description=get_file_content('README.rst'), author="Transifex", diff --git a/tx b/txclib/cmdline.py similarity index 97% rename from tx rename to txclib/cmdline.py index 096bdca2..d59b953a 100755 --- a/tx +++ b/txclib/cmdline.py @@ -36,10 +36,12 @@ def exithandler(signum,frame): sys.setdefaultencoding('utf-8') -def main(argv): +def main(argv=None): """ Here we parse the flags (short, long) and we instantiate the classes. """ + if argv is None: + argv = sys.argv[1:] usage = "usage: %prog [options] command [cmd_options]" description = "This is the Transifex command line client which"\ " allows you to manage your translations locally and sync"\ @@ -110,4 +112,4 @@ def main(argv): # Run baby :) ... run if __name__ == "__main__": # sys.argv[0] is the name of the script that we’re running. - main(sys.argv[1:]) + main()