4

I've got a python module with __main__.py file and I want to make it an app, which I can call from anywhere.

Something like this: $my_app [args] or python3 my_app args
How can I do this? I suppose, that I need to write something in setup.py. Now it looks like this:

import vk_mutual_friends_finder from distutils.core import setup setup( name="vk_mutual_friends_finder", packages=["vk_mutual_friends_finder"], version="1.0", description="""Finds mutual friends in social network 'vkontakte' (https://vk.com)""", author="Stepan Kholodov", url="https://github.com/stepuncius/vk_mutual_friends_finder", classifiers=[ "Programming Language :: Python", "Programming Language :: Python :: 3", "Intended Audience :: Developers and linux power users", "License :: OSI Approved :: BSD", "Environment :: Console" "Operating System :: Linux" ], ) 
2
  • 1
    FWIW if you install a module you can run it as python3 -m my_app [args] Commented Jun 18, 2016 at 18:01
  • Thank ypu! I've forgotten about it. It's the best way in my situation. Commented Jun 18, 2016 at 18:27

2 Answers 2

1

I think the easiest way is to set up an alias (http://www.linfo.org/alias.html). If you are using bash, you can add the line "alias myapp="python3 /path/to/your/app/myapp.py"" to you ~/.bashrc
After that you can call your app from everywhere with $myapp args

Sign up to request clarification or add additional context in comments.

Comments

0

If you want to be able to run just vkmff instead of python3 -m vk_mutual_friends_finder then use console_scripts in setup.py:

setup( name="vk_mutual_friends_finder", packages=["vk_mutual_friends_finder"], ... entry_points={ 'console_scripts': [ 'vkmff=vk_mutual_friends_finder:main', ], }) 

Also I think you should not import vk_mutual_friends_finder in setup.py.

Some useful links:

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.