blob: 04f41e519de95c618d92eb5359a5b9707cacb9e0 [file] [log] [blame]
Éric Araujo3a9f58f2011-06-01 20:42:49 +02001==================
2Packaging tutorial
3==================
4
5Welcome to the Packaging tutorial! We will learn how to use Packaging
6to package your project.
7
8.. TODO merge with introduction.rst
9
10
11Getting started
12---------------
13
14Packaging works with the *setup.cfg* file. It contains all the metadata for
15your project, as defined in PEP 345, but also declare what your project
16contains.
17
18Let's say you have a project called *CLVault* containing one package called
19*clvault*, and a few scripts inside. You can use the *pysetup* script to create
20a *setup.cfg* file for the project. The script will ask you a few questions::
21
22 $ mkdir CLVault
23 $ cd CLVault
24 $ pysetup create
25 Project name [CLVault]:
26 Current version number: 0.1
27 Package description:
28 >Command-line utility to store and retrieve passwords
29 Author name: Tarek Ziade
30 Author e-mail address: tarek@ziade.org
31 Project Home Page: http://bitbucket.org/tarek/clvault
32 Do you want to add a package ? (y/n): y
33 Package name: clvault
34 Do you want to add a package ? (y/n): n
35 Do you want to set Trove classifiers? (y/n): y
36 Please select the project status:
37
38 1 - Planning
39 2 - Pre-Alpha
40 3 - Alpha
41 4 - Beta
42 5 - Production/Stable
43 6 - Mature
44 7 - Inactive
45
46 Status: 3
47 What license do you use: GPL
48 Matching licenses:
49
50 1) License :: OSI Approved :: GNU General Public License (GPL)
51 2) License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
52
53 Type the number of the license you wish to use or ? to try again:: 1
54 Do you want to set other trove identifiers (y/n) [n]: n
55 Wrote "setup.cfg".
56
57
58A setup.cfg file is created, containing the metadata of your project and the
59list of the packages it contains::
60
61 $ cat setup.cfg
62 [metadata]
63 name = CLVault
64 version = 0.1
65 author = Tarek Ziade
66 author_email = tarek@ziade.org
67 description = Command-line utility to store and retrieve passwords
68 home_page = http://bitbucket.org/tarek/clvault
69
70 classifier = Development Status :: 3 - Alpha
71 License :: OSI Approved :: GNU General Public License (GPL)
72
73 [files]
74 packages = clvault
75
76
77Our project will depend on the *keyring* project. Let's add it in the
78[metadata] section::
79
80 [metadata]
81 ...
82 requires_dist =
83 keyring
84
85
86Running commands
87----------------
88
89You can run useful commands on your project once the setup.cfg file is ready:
90
91- sdist: creates a source distribution
92- register: register your project to PyPI
93- upload: upload the distribution to PyPI
94- install_dist: install it
95
96All commands are run using the run script::
97
98 $ pysetup run install_dist
99 $ pysetup run sdist
100 $ pysetup run upload
101
102If you want to push a source distribution of your project to PyPI, do::
103
104 $ pysetup run sdist register upload
105
106
107Installing the project
108----------------------
109
110The project can be installed by manually running the packaging install command::
111
112 $ pysetup run install_dist