5

I'm using distutils.core.setup for the first time. I got it to install my module in /usr/lib/python/site-packages.

If I run python from any directory and do import my_module it all works great.

However, I need to run my module as script. It's not intended as a library, but rather as an application. If I run from terminal python my_module it does not find the file.

I wanted to make an executable script that will run my module and put a sym link to it in /usr/bin, but that seems like a hacky way to solve this. I presume distutils has something to install your module as an executable script, except I wasn't able to find it. Could someone please point me to an example or doc file for this?

Edit: Also, if this is not the right way to distribute a python application, what should I use instead?

1 Answer 1

5

Use

distutils.core.setup(scripts=['myprogram'])

instead of py_modules=['mymodule.py']

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

2 Comments

Hi! Thank you! I looked at this and tried it. And indeed my setup.py now installs the main script of my code in /usr/local/bin. My problem is now that this particular script is looking for the other modules in my source tree, which are not in /usr/local/bin. I'm thinking I should have only a symlink in /usr/local/bin, not the actual script. Any idea how to do this through distutils?
Actually, never mind my previous comment. I figured I should have had all my imports referencing the full package path. :) All working! Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.