将别名添加到setup()中的console_scripts

时间:2019-05-31 06:58:09

标签: python python-3.x command-line package python-packaging

我想知道是否可以为setup()的entry_points arg中的console_scripts中定义的命令指定别名。

我可以做这样的事情吗?

entry_points={
          'console_scripts': ['[command,alias0,alias1,alias2]=packagename.__main__:main'],
      },

1 个答案:

答案 0 :(得分:1)

Aliasing absolutely works, but not quite in the way you want it to. As long as a slight amount of code duplication is fine for you, you can do this instead:

entry_points={
    'console_scripts': [
        'command=packagename.__main__:main',
        'alias0=packagename.__main__:main',
        'alias1=packagename.__main__:main',
        'alias2=packagename.__main__:main'
]}