Search code examples
pythonpython-3.x

How to install Python script on Windows?


I wrote a small command-line utility in Python. I also created setup.py script:

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = {
    'name': 'clitool',
    'author': 'aa',
    'author_email': 'ww',
    'version': '1.0-rc',
    'install_requires': ['nose'],
    'packages': [],
    'scripts': ['clitool']
}

setup(**config)

When I call:

setup.py install

my script copied to C:\Python34\Scripts path. This path is in the PATH variable, but Windows when I try to start my clitool from some direcory writes:

"clitool" not recognized as an internal or external command

It's possible to run from any directory, only the files from C:\Python34\Scripts with the exe extension.
But my script is copied as a file without extension and in Windows it does not run it.


Solution

  • Solution:

    try:
        from setuptools import setup
    except ImportError:
        from distutils.core import setup
    
    config = {
        'name': 'clitool',
        'author': 'aa',
        'author_email': 'ww',
        'version': '1.0-rc',
        'install_requires': ['nose'],
        'packages': [],    
        'entry_points' : {
            'console_scripts': ['clitool=clitool.cli:main'],
        }
    }
    
    setup(**config)