tags:

views:

64

answers:

3

Hello.

For my project I would be using the argparse library. My question is, how do I distribute it with my project. I am asking this because of the technicalities and legalities involved.

Do I just:

  1. Put the argparse.py file along with my project. That is, in the tar file for my project.
  2. Create a package for it for my distro?
  3. Tell the user to install it himself?

Sorry for being such a noob, but I new to all this.

+1  A: 

It would be best for the user to install it so that only one copy is present on the system and so that it can be updated if there are any issues, but including it with your project is a viable option if you abide by all requirements specified in the license.

Try to import it from the public location, and if that fails then resort to using the included module.

Ignacio Vazquez-Abrams
A: 

What's your target Python version? It appears that argparse is included from version 2.7.

If you're building a small library with minimal dependencies, I would consider removing the dependency on an external module and only use facilities offered by the standard Python library. You can access command line parameters with sys.argv and parse them yourself, it's usually not that hard to do. Your users will definitely appreciate not having to install yet another third party module just to use your code.

Greg Hewgill
Actually argparse provides many features that would make my work easier. Would it really matter to the end user to install a simple library? Being new to development, I don't know the sentiment. But at least I wouldn't mind. :)I will be targeting Python 2.6.
A A
@Alfred: For what it's worth, it usually matters to me. The difference between *zero* dependencies and *one* dependency is quite a lot. For my own Python code, I always try to minimise dependencies wherever possible (one exception that jumps to mind is [`dnspython`](http://www.dnspython.org/) for [`pydkim`](http://hewgill.com/pydkim/)).
Greg Hewgill
@Greg: Apart from that, I think it would add somewhat to the performance also or not? I mean degrade it?
A A
@Alfred: I'm not sure what you're concerned about regarding performance. Command line argument parsing is almost never the performance-critical part of your code.
Greg Hewgill
Ok :) I will decide then. Thanks for the help. Good day!
A A
+1  A: 

You could go with Ignacio's suggestion.

But... For what it is worth, there's another library for argument parsing built into Python, which is quite powerful. Have you tried optparse? It belongs to the base Python distribution and has been there for a while...

Good luck!

Federico Cáceres
+1 for `optparse`.
Santa