diff --git a/packaging.html b/packaging.html index 5903c2c..de9618a 100644 --- a/packaging.html +++ b/packaging.html @@ -20,13 +20,13 @@ body{counter-reset:h1 16}
So you want to release a Python library. Excellent. The world needs more Python libraries. +
So you want to release a Python script, library, framework, or application. Excellent. The world needs more Python code. -
Python 3 comes with a packaging framework called Distutils. Distutils is many things: a build tool (for you), an installation tool (for your users), a package metadata format (for search engines), and more. It integrates with the Python Package Index, a central repository for open source Python libraries. +
Python 3 comes with a packaging framework called Distutils. Distutils is many things: a build tool (for you), an installation tool (for your users), a package metadata format (for search engines), and more. It integrates with the Python Package Index (“PyPI”), a central repository for open source Python libraries.
All of these facets of Distutils center around the setup script, traditionally called setup.py. In fact, you’ve already seen a Distutils setup script: you used one to install httplib2 in the “HTTP Web Services” chapter.
-
In this chapter, we’ll see how the setup script for httplib2 works and step through the process of releasing your own Python library.
+
In this chapter, you’ll learn how the setup script for httplib2 works and step through the process of releasing your own Python software.
# httplib2's setup.py
from distutils.core import setup
@@ -98,14 +98,14 @@ A comprehensive HTTP client library, ``httplib2`` supports many features left ou
)
-☞
httplib2is open source, but there’s no requirement that you release your own Python libraries under any particular license. The process described in this chapter will work for any Python library, regardless of license. +☞
httplib2is open source, but there’s no requirement that you release your own Python libraries under any particular license. The process described in this chapter will work for any Python software, regardless of license.
⁂
Releasing your first Python library is a daunting process. (Releasing your second one is easier.) Distutils tries to automate as much of it as possible, but there are some things you simply must do yourself. +
Releasing your first Python package is a daunting process. (Releasing your second one is easier.) Distutils tries to automate as much of it as possible, but there are some things you simply must do yourself.
To start packaging your Python library, you need to get your files and directories in order. The httplib2 directory looks like this:
+
To start packaging your Python software, you need to get your files and directories in order. The httplib2 directory looks like this:
httplib2/ ①
@@ -140,7 +140,7 @@ A comprehensive HTTP client library, ``httplib2`` supports many features left ou
.txt extension, and it should use Windows-style carriage returns. Just because you use a fancy text editor that runs from the command line and includes its own macro language, that doesn’t mean you need to make life difficult for your users. (Your users use Notepad. Sad but true.) Even if you’re on Linux or Mac OS X, your fancy text editor undoubtedly has an option to save files with Windows-style carriage returns.
setup.py unless you have a good reason not to. You do not have a good reason not to.
-.py file, you should put it in the root directory along with your “read me” file and your setup script. If your library is a directory with a main __init__.py script, like httplib2, you should put the entire directory here. Yes, that means you’ll have an httplib2/ directory within an httplib2/ directory. Trust me, that’s not a problem. In fact, any other arrangement would be a problem.
+.py file, you should put it in the root directory along with your “read me” file and your setup script. If it’s a multi-file module (i.e. a directory with a main __init__.py script), like httplib2, you should put the entire directory here. Yes, that means you’ll have an httplib2/ directory within an httplib2/ directory. Trust me, that’s not a problem. In fact, any other arrangement would be a problem.
Depending on the license you chose, you may include the license text within your .py files themselves, or you may have a separate file containing license text, or both. GPL-licensed programs generally include a file called COPYING that includes the entire text of the GPL. If you have a separate license file, it should go in the root directory along with your “read me” file and your setup script.
@@ -159,6 +159,44 @@ A comprehensive HTTP client library, ``httplib2`` supports many features left ou
The Python Package Index (“PyPI”) contains thousands of Python libraries. Proper classification metadata will allow people to find yours more easily. + +
The PyPI classification system is based on SourceForce’s software map. Classifiers are strings, but they are not freeform. + +
++ +☞All of your classifiers should come from this master list on PyPI. +
You should always include at least these four classifiers: + +
"Programming Language :: Python"
+"Programming Language :: Python :: 3". If you do not include this, your package will not show up in this list of Python 3-compatible libraries, which linked from the sidebar of every single page of pypi.python.org.
+"License :: whatever". This is the absolute first thing I look for when I’m evaluating third-party libraries. Don’t make me hunt for this vital information.
+"Operating System :: whatever". If your software only runs on Windows, I want to know sooner rather than later. If it runs everywhere, use the classifier "Operating System :: OS Independent".
+I strongly recommend that you also include the following classifications: + +
"Development Status :: whatever". Be honest.
+"Intended Audience :: whatever".
+FIXME - look at several examples, including httplib2 +
Distutils is not the be-all and end-all of Python packaging, but as of this writing (August 2009), it’s the only one that works in Python 3. There are a number of other frameworks for Python 2; some focus on installation, others on testing and deployment. Some or all of these may end up being ported to Python 3 in the future. +
Distutils is not the be-all and end-all of Python packaging, but as of this writing (August 2009), it’s the only packaging framework that works in Python 3. There are a number of other frameworks for Python 2; some focus on installation, others on testing and deployment. Some or all of these may end up being ported to Python 3 in the future.
These frameworks focus on installation: