From f5146e72b6a78fae04ffe40ae9556fcc7944d652 Mon Sep 17 00:00:00 2001 From: wuzewu Date: Thu, 28 Mar 2019 20:01:43 +0800 Subject: [PATCH] update commands --- paddle_hub/commands/hub.py | 5 +++++ paddle_hub/commands/install.py | 7 ++++--- paddle_hub/commands/list.py | 3 ++- paddle_hub/commands/run.py | 2 +- paddle_hub/commands/show.py | 9 +++++---- paddle_hub/commands/uninstall.py | 6 ++++-- paddle_hub/commands/version.py | 3 ++- setup.py | 12 +++++------- 8 files changed, 28 insertions(+), 19 deletions(-) diff --git a/paddle_hub/commands/hub.py b/paddle_hub/commands/hub.py index fb4b4c5e..a83945cf 100644 --- a/paddle_hub/commands/hub.py +++ b/paddle_hub/commands/hub.py @@ -50,5 +50,10 @@ class HubCommand(BaseCommand): command = HubCommand.instance() + +def main(): + command.exec(sys.argv[1:]) + + if __name__ == "__main__": command.exec(sys.argv[1:]) diff --git a/paddle_hub/commands/install.py b/paddle_hub/commands/install.py index 4c48817a..2d99a9c3 100644 --- a/paddle_hub/commands/install.py +++ b/paddle_hub/commands/install.py @@ -11,15 +11,16 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - from __future__ import absolute_import from __future__ import division from __future__ import print_function + +import argparse + from paddle_hub.tools.logger import logger from paddle_hub.commands.base_command import BaseCommand, ENTRY from paddle_hub.tools import utils from paddle_hub.module.manager import default_module_manager -import argparse class InstallCommand(BaseCommand): @@ -28,7 +29,7 @@ class InstallCommand(BaseCommand): def __init__(self, name): super(InstallCommand, self).__init__(name) self.show_in_help = True - self.description = "Install the specify module to current environment." + self.description = "Install the specific module to current environment." self.parser = self.parser = argparse.ArgumentParser( description=self.__class__.__doc__, prog='%s %s ' % (ENTRY, name), diff --git a/paddle_hub/commands/list.py b/paddle_hub/commands/list.py index 5c0dc415..1be30945 100644 --- a/paddle_hub/commands/list.py +++ b/paddle_hub/commands/list.py @@ -15,6 +15,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function + from paddle_hub.tools.logger import logger from paddle_hub.commands.base_command import BaseCommand from paddle_hub.tools import utils @@ -28,7 +29,7 @@ class ListCommand(BaseCommand): def __init__(self, name): super(ListCommand, self).__init__(name) self.show_in_help = True - self.description = "List all module install in current environment." + self.description = "List all modules install in current environment." def exec(self, argv): all_modules = default_module_manager.all_modules() diff --git a/paddle_hub/commands/run.py b/paddle_hub/commands/run.py index e1bb85ae..a16a17da 100644 --- a/paddle_hub/commands/run.py +++ b/paddle_hub/commands/run.py @@ -34,7 +34,7 @@ class RunCommand(BaseCommand): def __init__(self, name): super(RunCommand, self).__init__(name) self.show_in_help = True - self.description = "Run the specify module" + self.description = "Run the specific module." self.parser = self.parser = argparse.ArgumentParser( description=self.__class__.__doc__, prog='%s %s ' % (ENTRY, name), diff --git a/paddle_hub/commands/show.py b/paddle_hub/commands/show.py index eb7b178c..3a2638cc 100644 --- a/paddle_hub/commands/show.py +++ b/paddle_hub/commands/show.py @@ -15,12 +15,14 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function + +import os +import argparse + from paddle_hub.tools.logger import logger from paddle_hub.commands.base_command import BaseCommand, ENTRY from paddle_hub.module.manager import default_module_manager from paddle_hub.module.module import Module -import os -import argparse class ShowCommand(BaseCommand): @@ -29,7 +31,7 @@ class ShowCommand(BaseCommand): def __init__(self, name): super(ShowCommand, self).__init__(name) self.show_in_help = True - self.description = "Show the specify module's info" + self.description = "Show the specify module's info." self.parser = self.parser = argparse.ArgumentParser( description=self.__class__.__doc__, prog='%s %s ' % (ENTRY, name), @@ -59,7 +61,6 @@ class ShowCommand(BaseCommand): show_text += "Author:%s\n" % module.author show_text += "Author-Email:%s\n" % module.author_email show_text += "Location:%s\n" % module_dir - #TODO(wuzewu): add more signature info print(show_text) return True diff --git a/paddle_hub/commands/uninstall.py b/paddle_hub/commands/uninstall.py index e06bf713..05fa4999 100644 --- a/paddle_hub/commands/uninstall.py +++ b/paddle_hub/commands/uninstall.py @@ -15,11 +15,13 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function + +import argparse + from paddle_hub.tools.logger import logger from paddle_hub.commands.base_command import BaseCommand, ENTRY from paddle_hub.tools import utils from paddle_hub.module.manager import default_module_manager -import argparse class UninstallCommand(BaseCommand): @@ -28,7 +30,7 @@ class UninstallCommand(BaseCommand): def __init__(self, name): super(UninstallCommand, self).__init__(name) self.show_in_help = True - self.description = "Uninstall the specify module from current environment." + self.description = "Uninstall the specific module from current environment." self.parser = self.parser = argparse.ArgumentParser( description=self.__class__.__doc__, prog='%s %s ' % (ENTRY, name), diff --git a/paddle_hub/commands/version.py b/paddle_hub/commands/version.py index ee1fb282..bba0fe61 100644 --- a/paddle_hub/commands/version.py +++ b/paddle_hub/commands/version.py @@ -15,6 +15,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function + from paddle_hub.tools.logger import logger from paddle_hub.commands.base_command import BaseCommand from paddle_hub import version @@ -26,7 +27,7 @@ class VersionCommand(BaseCommand): def __init__(self, name): super(VersionCommand, self).__init__(name) self.show_in_help = True - self.description = "Get the paddle hub version" + self.description = "Get the paddle hub version." def exec(self, argv): print("hub %s" % version.hub_version) diff --git a/setup.py b/setup.py index 2e247cb7..559c496e 100644 --- a/setup.py +++ b/setup.py @@ -18,24 +18,22 @@ from __future__ import print_function from setuptools import find_packages from setuptools import setup -from paddle_hub import __version__ +from paddle_hub.version import hub_version REQUIRED_PACKAGES = [ - 'numpy >= 1.12.0', - 'six >= 1.10.0', - 'protobuf >= 3.1.0', + 'numpy >= 1.12.0', 'six >= 1.10.0', 'protobuf >= 3.1.0', 'pyyaml', 'numpy' ] setup( name='paddle_hub', - version=__version__.replace('-', ''), + version=hub_version.replace('-', ''), description=('PaddleHub is a library to foster the publication, ' 'discovery, and consumption of reusable parts of machine ' 'learning models.'), long_description='', url='https://github.com/PaddlePaddle/PaddleHub', author='PaddlePaddle Author', - author_email='chenzeyu01@baidu.com', + author_email='paddle-dev@baidu.com', install_requires=REQUIRED_PACKAGES, packages=find_packages(), # PyPI package information. @@ -59,4 +57,4 @@ setup( ], license='Apache 2.0', keywords=('paddlepaddle pretrained paddle-hub'), -) + entry_points={'console_scripts': ['hub=paddle_hub.commands.hub:main']}) -- GitLab