Including libraries in project. Best practice
I'm writing a Python open-source app. My app uses some open source Python libraries. These libraries in turn use other open-source libraries.
I intend to release my code at Sourceforge or Google Code but do I need to include the sources of the other libraries? Is this a good practice? ...or should I simply write this information into a README file informing the use about the other required libraries.
I've placed all these libraries into a libs sub folder in my source directory. When checking my code into SVN, should I use something called svn:externals to link to other sources?
Is there a way to dynamically update my libraries to the latest version or is this something I have to do manually when I release a new version.
My sincerest apologies if my question sounds vague but I'm pretty lost in this matter and I开发者_如何学Python don't know what to Google for.
Thanks all.
Use the pip requirements text file.
Just name the packages [and optionally version]
Ask the users to execute the following command in the README. (If you provide an install script, then you should call this within that; In that case you should also use Virtualenv)
pip install -r requirements.txt
and all the libraries you included in the requirements will be installed in that environment.
You can also include svn path, git path, mercurial path, or bzr path in the pip requirements.
Refer to the documentation: http://pip.openplans.org/requirement-format.html
If all your libraries are available from svn, and all your package users install it from the svn, you can also use svn externals; But pip is a lot more cleaner.
As others say, do not include the libraries, state the requirements in documentation. This way your project can use the libraries users already have, sometimes provided by their operating system distribution.
But then, keep in mind those external dependencies, that may exist in different versions or even configurations. Choose a stable branch (not the bleeding edge development snapshots) of the libraries whenever possible. When you really need a specific snapshot of the library, then including it in your package may be a better choice then forcing users to install something non-standard in their systems.
Normally you would just include the libraries in the final released version, but not necessarily include them in the source releases.
I think the most common practice is to inform your user which libraries and version numbers your code uses in something like a README.txt file. You can create a Python Egg package for you code that includes the library dependencies (if they have eggs as well), that can be download with your package upon installation. Use the setuptools package to create python eggs.
In general (for Python): don't ship the source of other libraries which you depend upon in your code.
Just state the required dependencies (complete with minimum required version, installation instructions etc) on a website and in instructions shipped with the source.
精彩评论