Question

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?
Was it helpful?

Solution

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.

OTHER TIPS

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.

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top