2

I develop a python package that, at the moment, consists of sub-packages, modules and functions that can be found in these modules. Now, I have a script, that uses certain elements of the package (as well as other packages), and I want to ship this script with the package. The goal in mind is that a potential user could, after installing the package, simple run the script and get the results.

What is the right way to do it? I could simply include the script in the tree structure of the package, and then it will be included with the distribution. But, in turn, the package will be installed on the user's box in a directory that is normally not too accessible to the user.

2 Answers 2

2

If your package is being distributed with setuptools or something similar, you can use the scripts keyword and setuptools will place it correctly in the PATH. See Command Line Scripts

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

1 Comment

Plus, for this to work under windows, it seems like the box has to be restarted... errrr...
0

Distutils supports installing scripts, but the question of where to place them for user access is a more complex one (for instance, Windows uses file extensions rather than shebangs and AFAIK doesn't have a facility to register them as commands). Scripts that are installed along with a module traditionally test using __name__=='__main__' if they are the primary program, and can be run from there using (for example) python -m SimpleHTTPServer.

Comments

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.