1

I have a Python project stored in GitHub that is going to use tweepy, a Twitter Python library stored in GitHub too. In the INSTALL file says that I can use git to bundle it in my project but I have no idea on how to do this. I thought to use git submodule but this will fetch all the project, not only the sources that is what I need. How could I do it? Is there a best way to work with external libraries in a project?

David Moreno García
  • 4,423
  • 8
  • 49
  • 82

1 Answers1

1

You can't get just a subdirectory with git-submodule (see this question).

Bundling is also bad practice (it makes updating the library code in the case of a library bug more difficult, and results in useless duplication). tweepy is on PyPI, so the best way would not be bundling it, but to require it in your setup.py or list it in your requirements.txt (depends on whether you're packaging it for PyPI or just building need to have an easy way to install your projects dependencies). You can specify what versions of the library are permissible when doing so, so tweepy can't change out from under your feet.

If you're planning on making changes to tweepy, the polite thing would be to submit those changes to the project, rather than making the changes within your project (or perhaps maintaining your own fork on GitHub if tweepy won't accept the changes). Note that pip has ways to install git versions of a package if you need a version that's not available in PyPI.

Community
  • 1
  • 1
Mike Larsen
  • 346
  • 1
  • 4
  • Thanks for your great answer. About tweepy is more an option that a requirement. The user will be able to choose which library to use. I'll have adapters for some of them. What is the best way to ask force a user to choose and have at least one? I can't require all in my setup.py – David Moreno García Nov 02 '12 at 00:31
  • Probably a runtime exception of some sort -- do a check that importing at least one library works, and display an error if they all fail? Maybe consider a plugin architecture, and require at least one of your plugins (if the adapters aren't really small). – Mike Larsen Nov 02 '12 at 00:39
  • I would make sure the documentation states that at least one library is required. Then list all available options. As @MikeLarsen stated, also throw an exception if you cannot find any supported libraries. – tasos Nov 02 '12 at 08:27