Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
2 | <html> | |
3 | <head> | |
4 | <link rel="STYLESHEET" href="dist.css" type='text/css' /> | |
5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> | |
6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> | |
7 | <link rel="first" href="dist.html" title='Distributing Python Modules' /> | |
8 | <link rel='index' href='genindex.html' title='Index' /> | |
9 | <link rel='last' href='about.html' title='About this document...' /> | |
10 | <link rel='help' href='about.html' title='About this document...' /> | |
11 | <link rel="next" href="node12.html" /> | |
12 | <link rel="prev" href="node10.html" /> | |
13 | <link rel="parent" href="setup-script.html" /> | |
14 | <link rel="next" href="node12.html" /> | |
15 | <meta name='aesop' content='information' /> | |
16 | <title>2.5 Installing Package Data</title> | |
17 | </head> | |
18 | <body> | |
19 | <DIV CLASS="navigation"> | |
20 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> | |
21 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
22 | <tr> | |
23 | <td class='online-navigation'><a rel="prev" title="2.4 Installing Scripts" | |
24 | href="node10.html"><img src='../icons/previous.png' | |
25 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
26 | <td class='online-navigation'><a rel="parent" title="2. Writing the Setup" | |
27 | href="setup-script.html"><img src='../icons/up.png' | |
28 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
29 | <td class='online-navigation'><a rel="next" title="2.6 Installing Additional Files" | |
30 | href="node12.html"><img src='../icons/next.png' | |
31 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
32 | <td align="center" width="100%">Distributing Python Modules</td> | |
33 | <td class='online-navigation'><img src='../icons/blank.png' | |
34 | border='0' height='32' alt='' width='32' /></td> | |
35 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
36 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
37 | <td class='online-navigation'><a rel="index" title="Index" | |
38 | href="genindex.html"><img src='../icons/index.png' | |
39 | border='0' height='32' alt='Index' width='32' /></A></td> | |
40 | </tr></table> | |
41 | <div class='online-navigation'> | |
42 | <b class="navlabel">Previous:</b> | |
43 | <a class="sectref" rel="prev" href="node10.html">2.4 Installing Scripts</A> | |
44 | <b class="navlabel">Up:</b> | |
45 | <a class="sectref" rel="parent" href="setup-script.html">2. Writing the Setup</A> | |
46 | <b class="navlabel">Next:</b> | |
47 | <a class="sectref" rel="next" href="node12.html">2.6 Installing Additional Files</A> | |
48 | </div> | |
49 | <hr /></div> | |
50 | </DIV> | |
51 | <!--End of Navigation Panel--> | |
52 | ||
53 | <H1><A NAME="SECTION002500000000000000000"> | |
54 | 2.5 Installing Package Data</A> | |
55 | </H1> | |
56 | ||
57 | <P> | |
58 | Often, additional files need to be installed into a package. These | |
59 | files are often data that's closely related to the package's | |
60 | implementation, or text files containing documentation that might be | |
61 | of interest to programmers using the package. These files are called | |
62 | <i class="dfn">package data</i>. | |
63 | ||
64 | <P> | |
65 | Package data can be added to packages using the <code>package_data</code> | |
66 | keyword argument to the <tt class="function">setup()</tt> function. The value must | |
67 | be a mapping from package name to a list of relative path names that | |
68 | should be copied into the package. The paths are interpreted as | |
69 | relative to the directory containing the package (information from the | |
70 | <code>package_dir</code> mapping is used if appropriate); that is, the files | |
71 | are expected to be part of the package in the source directories. | |
72 | They may contain glob patterns as well. | |
73 | ||
74 | <P> | |
75 | The path names may contain directory portions; any necessary | |
76 | directories will be created in the installation. | |
77 | ||
78 | <P> | |
79 | For example, if a package should contain a subdirectory with several | |
80 | data files, the files can be arranged like this in the source tree: | |
81 | ||
82 | <P> | |
83 | <div class="verbatim"><pre> | |
84 | setup.py | |
85 | src/ | |
86 | mypkg/ | |
87 | __init__.py | |
88 | module.py | |
89 | data/ | |
90 | tables.dat | |
91 | spoons.dat | |
92 | forks.dat | |
93 | </pre></div> | |
94 | ||
95 | <P> | |
96 | The corresponding call to <tt class="function">setup()</tt> might be: | |
97 | ||
98 | <P> | |
99 | <div class="verbatim"><pre> | |
100 | setup(..., | |
101 | packages=['mypkg'], | |
102 | package_dir={'mypkg': 'src/mypkg'}, | |
103 | package_data={'mypkg': ['data/*.dat']}, | |
104 | ) | |
105 | </pre></div> | |
106 | ||
107 | <P> | |
108 | ||
109 | <span class="versionnote">New in version 2.4.</span> | |
110 | ||
111 | <P> | |
112 | ||
113 | <DIV CLASS="navigation"> | |
114 | <div class='online-navigation'> | |
115 | <p></p><hr /> | |
116 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> | |
117 | <tr> | |
118 | <td class='online-navigation'><a rel="prev" title="2.4 Installing Scripts" | |
119 | href="node10.html"><img src='../icons/previous.png' | |
120 | border='0' height='32' alt='Previous Page' width='32' /></A></td> | |
121 | <td class='online-navigation'><a rel="parent" title="2. Writing the Setup" | |
122 | href="setup-script.html"><img src='../icons/up.png' | |
123 | border='0' height='32' alt='Up One Level' width='32' /></A></td> | |
124 | <td class='online-navigation'><a rel="next" title="2.6 Installing Additional Files" | |
125 | href="node12.html"><img src='../icons/next.png' | |
126 | border='0' height='32' alt='Next Page' width='32' /></A></td> | |
127 | <td align="center" width="100%">Distributing Python Modules</td> | |
128 | <td class='online-navigation'><img src='../icons/blank.png' | |
129 | border='0' height='32' alt='' width='32' /></td> | |
130 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' | |
131 | border='0' height='32' alt='Module Index' width='32' /></a></td> | |
132 | <td class='online-navigation'><a rel="index" title="Index" | |
133 | href="genindex.html"><img src='../icons/index.png' | |
134 | border='0' height='32' alt='Index' width='32' /></A></td> | |
135 | </tr></table> | |
136 | <div class='online-navigation'> | |
137 | <b class="navlabel">Previous:</b> | |
138 | <a class="sectref" rel="prev" href="node10.html">2.4 Installing Scripts</A> | |
139 | <b class="navlabel">Up:</b> | |
140 | <a class="sectref" rel="parent" href="setup-script.html">2. Writing the Setup</A> | |
141 | <b class="navlabel">Next:</b> | |
142 | <a class="sectref" rel="next" href="node12.html">2.6 Installing Additional Files</A> | |
143 | </div> | |
144 | </div> | |
145 | <hr /> | |
146 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> | |
147 | </DIV> | |
148 | <!--End of Navigation Panel--> | |
149 | <ADDRESS> | |
150 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. | |
151 | </ADDRESS> | |
152 | </BODY> | |
153 | </HTML> |