Commits

Sylvain Thénault  committed 241f04d

create a console_scripts entry point to be used by easy_install, buildout and pip. Closes #103949

uniformize run interface and update licensing on the way

  • Participants
  • Parent commits 6eda98d

Comments (0)

Files changed (12)

     * #103656: fix W0231 false positive for missing call to object.__init__
       (patch by lothiraldan@gmail.com)
 
+    * #103949: create a console_scripts entry point to be used by
+      easy_install, buildout and pip
+
     * fix cross-interpreter issue (non compatible access to __builtins__)
 
     * stop including tests files in distribution, they causes crash when
+# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
+# http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
 # This program is free software; you can redistribute it and/or modify it under
 # the terms of the GNU General Public License as published by the Free Software
 # Foundation; either version 2 of the License, or (at your option) any later
 # You should have received a copy of the GNU General Public License along with
 # this program; if not, write to the Free Software Foundation, Inc.,
 # 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-""" Copyright (c) 2002-2008 LOGILAB S.A. (Paris, FRANCE).
-http://www.logilab.fr/ -- mailto:contact@logilab.fr  
-"""
+import sys
 
+def run_pylint():
+    """run pylint"""
+    from pylint.lint import Run
+    Run(sys.argv[1:])
+
+def run_pylint_gui():
+    """run pylint-gui"""
+    try:
+        from pylint.gui import Run
+        Run(sys.argv[1:])
+    except ImportError:
+        sys.exit('tkinter is not available')
+
+def run_epylint():
+    """run pylint"""
+    from pylint.epylint import Run
+    Run()
+
+def run_pyreverse():
+    """run pyreverse"""
+    from pylint.pyreverse.main import Run
+    Run(sys.argv[1:])
+
+def run_symilar():
+    """run symilar"""
+    from pylint.checkers.similar import Run
+    Run(sys.argv[1:])
 #!/usr/bin/env python
-import sys
-from pylint import lint
-lint.Run(sys.argv[1:])
+from pylint import run_pylint
+run_pylint()

File bin/pylint-gui

 #!/usr/bin/env python
-import sys
-try:
-    from pylint import gui 
-    gui.Run(sys.argv[1:])
-except ImportError:
-    sys.exit('tkinter is not available')
+from pylint import run_pylint_gui
+run_pylint_gui()

File bin/pyreverse

 #!/usr/bin/python
-import sys
-from pylint.pyreverse import main
-main.Run(sys.argv[1:])
+from pylint import run_pyreverse
+run_pyreverse()
 #!/usr/bin/env python
-from pylint.checkers import similar
-similar.run()
+from pylint import run_symilar
+run_symilar()

File checkers/similar.py

 # pylint: disable=W0622
-# Copyright (c) 2004-2006 LOGILAB S.A. (Paris, FRANCE).
+# Copyright (c) 2004-2012 LOGILAB S.A. (Paris, FRANCE).
 # http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This program is free software; you can redistribute it and/or modify it under
 # 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 """a similarities / code duplication command line tool and pylint checker
 """
-from __future__ import generators
-
 import sys
 from itertools import izip
 
 [-i|--ignore-comments] file1...'
     sys.exit(status)
 
-def run(argv=None):
+def Run(argv=None):
     """standalone command line access point"""
     if argv is None:
         argv = sys.argv[1:]
     for filename in args:
         sim.append_stream(filename, open(filename))
     sim.run()
+    sys.exit(0)
 
 if __name__ == '__main__':
-    run()
+    Run()
-#!/usr/bin/env python
 # -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=python:et:sw=4:ts=4:sts=4
+# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
+# http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 """Emacs and Flymake compatible Pylint.
 
 This script is for integration with emacs and is compatible with flymake mode.
     process.wait()
     return process.returncode
 
-def Run():
-    sys.exit(lint(sys.argv[1]))
-
 
 def py_run(command_options='', return_std=False, stdout=None, stderr=None,
            script='epylint'):
         return (p.stdout, p.stderr)
 
 
+def Run():
+    sys.exit(lint(sys.argv[1]))
+
 if __name__ == '__main__':
-    lint(sys.argv[1])
+    Run()
 
+# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
+# http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 """Tkinker gui for pylint"""
 
 import os
     """launch pylint gui from args"""
     if args:
         print 'USAGE: pylint-gui\n launch a simple pylint gui using Tk'
-        return
+        sys.exit(1)
     gui = LintGui()
     gui.mainloop()
+    sys.exit(0)
 
 if __name__ == '__main__':
     Run(sys.argv[1:])

File pyreverse/main.py

-# # Copyright (c) 2000-2010 LOGILAB S.A. (Paris, FRANCE).
+# # Copyright (c) 2000-2012 LOGILAB S.A. (Paris, FRANCE).
 # http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This program is free software; you can redistribute it and/or modify it under
 """
   %prog [options] <packages>
 
-  create UML diagrams for classes and modules in <packages> 
+  create UML diagrams for classes and modules in <packages>
 """
 
 import sys, os
 OPTIONS = (
 ("filter-mode",
     dict(short='f', default='PUB_ONLY', dest='mode', type='string',
-    action='store', metavar='<mode>', 
+    action='store', metavar='<mode>',
     help="""filter attributes and functions according to
     <mode>. Correct modes are :
                             'PUB_ONLY' filter all non public attributes
                 help="create a *.<format> output file if format available.")),
 )
 # FIXME : quiet mode
-#( ('quiet', 
+#( ('quiet',
                 #dict(help='run quietly', action='store_true', short='q')), )
 
-class PyreverseCommand(ConfigurationMixIn):
+class Run(ConfigurationMixIn):
     """base class providing common behaviour for pyreverse commands"""
 
     options = OPTIONS
         self.manager = ASTNGManager()
         self.register_options_provider(self.manager)
         args = self.load_command_line_configuration()
-        self.run(args)
+        sys.exit(self.run(args))
 
     def run(self, args):
         """checking arguments and run project"""
         if not args:
             print self.help()
-            return
+            return 1
         # insert current working directory to the python path to recognize
         # dependencies to local modules even if cwd is not in the PYTHONPATH
         sys.path.insert(0, os.getcwd())
             writer.VCGWriter(self.config).write(diadefs)
         else:
             writer.DotWriter(self.config).write(diadefs)
+        return 0
 
 
-class Run:
-    """pyreverse main class"""
-    def __init__(self, args):
-        """run pyreverse"""
-        PyreverseCommand(args)
-
 if __name__ == '__main__':
     Run(sys.argv[1:])
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 # pylint: disable=W0404,W0622,W0704,W0613
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
 #
 # This file is part of pylint.
                 shutil.rmtree(dest, ignore_errors=True)
                 shutil.copytree(directory, dest)
 
+
 def install(**kwargs):
     """setup entry point"""
     if USE_SETUPTOOLS:
     else:
         kwargs['package_dir'] = {modname : '.'}
         packages = [modname] + get_packages(os.getcwd(), modname)
-    if USE_SETUPTOOLS and install_requires:
-        kwargs['install_requires'] = install_requires
-        kwargs['dependency_links'] = dependency_links
+    if USE_SETUPTOOLS:
+        if install_requires:
+            kwargs['install_requires'] = install_requires
+            kwargs['dependency_links'] = dependency_links
+        kwargs['entry_points'] = {'console_scripts': [
+                'pylint = pylint:run_pylint',
+                'pylint-gui = pylint:run_pylint_gui',
+                'epylint = pylint:run_epylint',
+                'pyreverse = pylint:run_pyreverse',
+                'symilar = pylint:run_symilar',
+                ]}
     kwargs['packages'] = packages
     return setup(name = distname,
                  version = version,

File test/test_similar.py

     def test_ignore_comments(self):
         sys.stdout = StringIO()
         try:
-            similar.run(['--ignore-comments', SIMILAR1, SIMILAR2])
+            similar.Run(['--ignore-comments', SIMILAR1, SIMILAR2])
+        except SystemExit, ex:
+            self.assertEqual(ex.code, 0)
             output = sys.stdout.getvalue()
+        else:
+            self.fail('not system exit')
         finally:
             sys.stdout = sys.__stdout__
         self.assertMultiLineEqual(output.strip(), ("""
     def test_dont_ignore_comments(self):
         sys.stdout = StringIO()
         try:
-            similar.run([SIMILAR1, SIMILAR2])
+            similar.Run([SIMILAR1, SIMILAR2])
+        except SystemExit, ex:
+            self.assertEqual(ex.code, 0)
             output = sys.stdout.getvalue()
+        else:
+            self.fail('not system exit')
         finally:
             sys.stdout = sys.__stdout__
         self.assertMultiLineEqual(output.strip(), """
     def test_help(self):
         sys.stdout = StringIO()
         try:
-            try:
-                similar.run(['--help'])
-            except SystemExit, ex:
-                self.assertEqual(ex.code, 0)
-            else:
-                self.fail()
+            similar.Run(['--help'])
+        except SystemExit, ex:
+            self.assertEqual(ex.code, 0)
+        else:
+            self.fail('not system exit')
         finally:
             sys.stdout = sys.__stdout__
 
     def test_no_args(self):
         sys.stdout = StringIO()
         try:
-            try:
-                similar.run([])
-            except SystemExit, ex:
-                self.assertEqual(ex.code, 1)
-            else:
-                self.fail()
+            similar.Run([])
+        except SystemExit, ex:
+            self.assertEqual(ex.code, 1)
+        else:
+            self.fail('not system exit')
         finally:
             sys.stdout = sys.__stdout__