blob: 0ec7505ad38278bb8538ce09436ef9d71eb200c8 [file] [log] [blame]
Éric Araujo3a9f58f2011-06-01 20:42:49 +02001.. _packaging-command-reference:
2
3*****************
4Command Reference
5*****************
6
7This reference briefly documents all standard Packaging commands and some of
8their options.
9
10.. FIXME does not work: Use pysetup run --help-commands to list all
11 standard and extra commands availavble on your system, with their
12 description. Use pysetup run <command> --help to get help about the options
13 of one command.
14
Éric Araujo7dc76fd2011-08-06 16:58:15 +020015.. XXX sections from this document should be merged with other docs (e.g. check
16 and upload with uploading.rst, install_* with install/install.rst, etc.);
17 there is no value in partially duplicating information. this file could
18 however serve as an index, i.e. just a list of all commands with links to
19 every section that describes options or usage
20
Éric Araujo3a9f58f2011-06-01 20:42:49 +020021
22Preparing distributions
23=======================
24
25:command:`check`
26----------------
27
28Perform some tests on the metadata of a distribution.
29
30For example, it verifies that all required metadata fields are provided in the
31:file:`setup.cfg` file.
32
33.. TODO document reST checks
34
35
36:command:`test`
37---------------
38
39Run a test suite.
40
41When doing test-driven development, or running automated builds that need
42testing before they are installed for downloading or use, it's often useful to
43be able to run a project's unit tests without actually installing the project
44anywhere. The :command:`test` command runs project's unit tests without
45actually installing it, by temporarily putting the project's source on
46:data:`sys.path`, after first running :command:`build_ext -i` to ensure that any
47C extensions are built.
48
49You can use this command in one of two ways: either by specifying a
50unittest-compatible test suite for your project (or any callable that returns
51it) or by passing a test runner function that will run your tests and display
52results in the console. Both options take a Python dotted name in the form
53``package.module.callable`` to specify the object to use.
54
55If none of these options are specified, Packaging will try to perform test
56discovery using either unittest (for Python 3.2 and higher) or unittest2 (for
57older versions, if installed).
58
59.. this is a pseudo-command name used to disambiguate the options in indexes and
60 links
61.. program:: packaging test
62
63.. cmdoption:: --suite=NAME, -s NAME
64
65 Specify the test suite (or module, class, or method) to be run. The default
Georg Brandld3b41c62011-07-09 11:48:50 +020066 for this option can be set by in the project's :file:`setup.cfg` file:
Éric Araujo3a9f58f2011-06-01 20:42:49 +020067
68 .. code-block:: cfg
69
70 [test]
71 suite = mypackage.tests.get_all_tests
72
73.. cmdoption:: --runner=NAME, -r NAME
74
75 Specify the test runner to be called.
76
77
78:command:`config`
79-----------------
80
81Perform distribution configuration.
82
83
84The build step
85==============
86
87This step is mainly useful to compile C/C++ libraries or extension modules. The
88build commands can be run manually to check for syntax errors or packaging
89issues (for example if the addition of a new source file was forgotten in the
90:file:`setup.cfg` file), and is also run automatically by commands which need
91it. Packaging checks the mtime of source and built files to avoid re-building
92if it's not necessary.
93
94
95:command:`build`
96----------------
97
98Build all files of a distribution, delegating to the other :command:`build_*`
99commands to do the work.
100
101
102:command:`build_clib`
103---------------------
104
105Build C libraries.
106
107
108:command:`build_ext`
109--------------------
110
111Build C/C++ extension modules.
112
113
114:command:`build_py`
115-------------------
116
117Build the Python modules (just copy them to the build directory) and
118byte-compile them to .pyc files.
119
120
121:command:`build_scripts`
122------------------------
123Build the scripts (just copy them to the build directory and adjust their
124shebang if they're Python scripts).
125
126
127:command:`clean`
128----------------
129
130Clean the build tree of the release.
131
132.. program:: packaging clean
133
134.. cmdoption:: --all, -a
135
136 Remove build directories for modules, scripts, etc., not only temporary build
137 by-products.
138
139
140Creating source and built distributions
141=======================================
142
143:command:`sdist`
144----------------
145
146Build a source distribution for a release.
147
148It is recommended that you always build and upload a source distribution. Users
149of OSes with easy access to compilers and users of advanced packaging tools will
150prefer to compile from source rather than using pre-built distributions. For
151Windows users, providing a binary installer is also recommended practice.
152
153
154:command:`bdist`
155----------------
156
157Build a binary distribution for a release.
158
159This command will call other :command:`bdist_*` commands to create one or more
160distributions depending on the options given. The default is to create a
161.tar.gz archive on Unix and a zip archive on Windows or OS/2.
162
163.. program:: packaging bdist
164
165.. cmdoption:: --formats
166
167 Binary formats to build (comma-separated list).
168
169.. cmdoption:: --show-formats
170
171 Dump list of available formats.
172
173
174:command:`bdist_dumb`
175---------------------
176
177Build a "dumb" installer, a simple archive of files that could be unpacked under
178``$prefix`` or ``$exec_prefix``.
179
180
181:command:`bdist_wininst`
182------------------------
183
184Build a Windows installer.
185
186
187:command:`bdist_msi`
188--------------------
189
190Build a `Microsoft Installer`_ (.msi) file.
191
192.. _Microsoft Installer: http://msdn.microsoft.com/en-us/library/cc185688(VS.85).aspx
193
194In most cases, the :command:`bdist_msi` installer is a better choice than the
195:command:`bdist_wininst` installer, because it provides better support for Win64
196platforms, allows administrators to perform non-interactive installations, and
197allows installation through group policies.
198
199
200Publishing distributions
201========================
202
203:command:`register`
204-------------------
205
206This command registers the current release with the Python Package Index. This
207is described in more detail in :PEP:`301`.
208
209.. TODO explain user and project registration with the web UI
210
211
212:command:`upload`
213-----------------
214
215Upload source and/or binary distributions to PyPI.
216
217The distributions have to be built on the same command line as the
218:command:`upload` command; see :ref:`packaging-package-upload` for more info.
219
220.. program:: packaging upload
221
222.. cmdoption:: --sign, -s
223
224 Sign each uploaded file using GPG (GNU Privacy Guard). The ``gpg`` program
225 must be available for execution on the system ``PATH``.
226
227.. cmdoption:: --identity=NAME, -i NAME
228
229 Specify the identity or key name for GPG to use when signing. The value of
230 this option will be passed through the ``--local-user`` option of the
231 ``gpg`` program.
232
233.. cmdoption:: --show-response
234
235 Display the full response text from server; this is useful for debugging
236 PyPI problems.
237
238.. cmdoption:: --repository=URL, -r URL
239
240 The URL of the repository to upload to. Defaults to
241 http://pypi.python.org/pypi (i.e., the main PyPI installation).
242
243.. cmdoption:: --upload-docs
244
245 Also run :command:`upload_docs`. Mainly useful as a default value in
246 :file:`setup.cfg` (on the command line, it's shorter to just type both
247 commands).
248
249
250:command:`upload_docs`
251----------------------
252
253Upload HTML documentation to PyPI.
254
255PyPI now supports publishing project documentation at a URI of the form
256``http://packages.python.org/<project>``. :command:`upload_docs` will create
257the necessary zip file out of a documentation directory and will post to the
258repository.
259
260Note that to upload the documentation of a project, the corresponding version
261must already be registered with PyPI, using the :command:`register` command ---
262just like with :command:`upload`.
263
264Assuming there is an ``Example`` project with documentation in the subdirectory
265:file:`docs`, for example::
266
267 Example/
268 example.py
269 setup.cfg
270 docs/
271 build/
272 html/
273 index.html
274 tips_tricks.html
275 conf.py
276 index.txt
277 tips_tricks.txt
278
279You can simply specify the directory with the HTML files in your
280:file:`setup.cfg` file:
281
282.. code-block:: cfg
283
284 [upload_docs]
285 upload-dir = docs/build/html
286
287
288.. program:: packaging upload_docs
289
290.. cmdoption:: --upload-dir
291
292 The directory to be uploaded to the repository. By default documentation
293 is searched for in ``docs`` (or ``doc``) directory in project root.
294
295.. cmdoption:: --show-response
296
297 Display the full response text from server; this is useful for debugging
298 PyPI problems.
299
300.. cmdoption:: --repository=URL, -r URL
301
302 The URL of the repository to upload to. Defaults to
303 http://pypi.python.org/pypi (i.e., the main PyPI installation).
304
305
306The install step
307================
308
309These commands are used by end-users of a project using :program:`pysetup` or
310another compatible installer. Each command will run the corresponding
311:command:`build_*` command and then move the built files to their destination on
312the target system.
313
314
315:command:`install_dist`
316-----------------------
317
318Install a distribution, delegating to the other :command:`install_*` commands to
Éric Araujo7dc76fd2011-08-06 16:58:15 +0200319do the work. See :ref:`packaging-how-install-works` for complete usage
320instructions.
Éric Araujo3a9f58f2011-06-01 20:42:49 +0200321
322
323:command:`install_data`
324-----------------------
325
326Install data files.
327
328
329:command:`install_distinfo`
330---------------------------
331
332Install files recording details of the installation as specified in :PEP:`376`.
333
334
335:command:`install_headers`
336--------------------------
337
338Install C/C++ header files.
339
340
341:command:`install_lib`
342----------------------
343
344Install C library files.
345
346
347:command:`install_scripts`
348--------------------------
349
350Install scripts.