Python's setup.py installed CLI script doesn't allow importing same module

非 Y 不嫁゛ 提交于 2019-12-04 08:59:41

You need some more __init__'s. The __init__.py file tells python that the folder is a python module. You are refrencing these as modules in your setup script, so you need to tell python that they are modules.

knife/
    knife/
        bin/
            knife-cli.py
        core/
            main/
                __init__.py
            __init__.py
        __init__.py
    setup.py

That should fix the main problem. However, you are also declaring two scripts, one using the scripts section and another using the console_scripts. Console scripts will actually create the script for you, so you dont need to include your own in "bin".

Here is a better setup.py for you: (note I just removed the scripts section)

#!/usr/bin/env python

from setuptools import setup, find_packages

exclude = ['knife.bin']

setup(name='Knife',
      version='0.3',
      description='Very cool project',
      author='John Doe',
      author_email='author@email.com',
      packages=find_packages(exclude=exclude),
      include_package_data=True,
      entry_points={
        'console_scripts': [
            'knife-cli = knife.core.main:main'
        ]
      },
      zip_safe=False,
     )

Got it, The script was executing the old /usr/bin/knife.pyc file, I just deleted it and now works well.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!