1
votes

I am working on a script and I would like to use like an executable. That means I wanna install with pip and run with its name. example:

pip install myscript.whl
myscript

I am already created a whl file (via 'python setup.py bdist_wheel'), however I am not sure what is the next step. How can I do that after pip install an executable automatically created and can be used from anywhere in powershell or linux terminal.

1
This is my answer from awhile ago, but it is a decent way to build out a package with an executable: stackoverflow.com/a/56534786/8468264 - d_kennetz
@d_kennetz The shell-based script in your answer won't work with Windows environments -- console_scripts will... - AKX
Oh true! @AKX, thanks for pointing that out. - d_kennetz

1 Answers

3
votes

Since you already have a setup.py, all you need to do is follow the steps outlined in the Packaging Guide to set up a console script entry point.

setup(
    ...
    entry_points = {
        'console_scripts': ['myscript=myscript.some_module:some_function'],
    }
    ...