RSS

(root)/pkg-python/python-defaults-debian : /dh_python2.rst (revision 359)

To get this branch, use:
bzr branch /scm/loggerhead/pkg-python/python-defaults-debian
Line Revision Contents
1 189
============
2
 dh_python2
3
============
4
5
-----------------------------------------------------------------------------------
6
calculates Python dependencies, adds maintainer scripts to byte compile files, etc.
7
-----------------------------------------------------------------------------------
8
9
SYNOPSIS
10
========
11
  dh_python2 -p PACKAGE [-V [X.Y][-][A.B]] DIR_OR_FILE [-X REGEXPR]
12
13
DESCRIPTION
14
===========
15
16
QUICK GUIDE FOR MAINTAINERS
17
---------------------------
18
19
 * if necessary, describe supported Python versions via X-Python-Version field
20
   in debian/control,
21
 * build-depend on python or python-all or python-all-dev (>= 2.6.6-3~),
22
 * build module/application using its standard build system,
23
   remember to build extensions for all supported Python versions (loop over
24
   ``pyversions -vr``),
25 328
 * install files to the *standard* locations, add `--install-layout=deb` to
26 189
   setup.py's install command if your package is using distutils,
27 328
 * add `python2` to dh's --with option, or:
28
 * `include /usr/share/cdbs/1/class/python-distutils.mk` in debian/rules and
29
   depend on `cdbs (>= 0.4.90)`, or:
30
 * call ``dh_python2`` in the `binary-*` target,
31
 * add `${python:Depends}` to Depends
32 189
33
NOTES
34
-----
35
36
In order to support more than one Python version in the same binary package,
37
dh_python2 (unlike dh_pycentral and dh_pysupport) creates symlinks to all
38
supported Python versions at build time. It means binNMU (or sourceful upload
39 190
in case of architecture independent packages) is required once a list of
40 189
supported Python version is changed. It's faster and more robust than its
41
competitors, though.
42
43 243
dependencies
44 245
~~~~~~~~~~~~
45 189
dh_python2 tries to translate Python dependencies from requires.txt file to
46 328
Debian dependencies. Use debian/pydist-overrides or --no-guessing-deps option
47
to override it if the guess is incorrect. If you want dh_python2 to generate
48
more strict dependencies (f.e. to avoid ABI problems) create
49
debian/python-foo.pydist file. See /usr/share/doc/python-doc/README.PyDist
50
(provided by python-doc package) for more information. If the pydist file
51
contains PEP386 flag or set of (uscan like) rules, dh_python2 will make the
52
depedency versioned (version requirements are ignored by default).
53 189
54 243
namespace feature
55 245
~~~~~~~~~~~~~~~~~
56 210
dh_python2 parses Egg's namespace_packages.txt files (in addition to
57
--namespace command line argument(s)) and drops empty __init__.py files from
58 305.1.1
binary package. pycompile will regenerate them at install time and pyclean
59 210
will remove them at uninstall time (if they're no longer used in installed
60 243
packages). It's still a good idea to provide __init__.py file in one of
61
binary packages (even if all other packages use this feature).
62
63
private dirs
64 245
~~~~~~~~~~~~
65 244
`/usr/share/foo`, `/usr/share/games/foo`, `/usr/lib/foo` and
66
`/usr/lib/games/foo` private directories are scanned for Python files
67
by default (where `foo` is binary package name). If your package is shipping
68
Python files in some other directory, add another dh_python2 call in
69
debian/rules with directory name as an argument - you can use different set of
70
options in this call. If you need to change options (f.e. a list of supported
71
Python versions) for a private directory that is checked by default, invoke
72
dh_python2 with --skip-private option and add another call with a path to this
73
directory and new options.
74
75 328
debug packages
76
~~~~~~~~~~~~~~
77
In binary packages which name ends with `-dbg`, all files in
78
`/usr/lib/python2.X/{site,dist}-packages/` directory 
79
that have extensions different than `so` or `h` are removed by default.
80
Use --no-dbg-cleaning option to disable this feature.
81
82 244
pyinstall files
83 245
~~~~~~~~~~~~~~~
84 244
Files listed in debian/pkg.pyinstall file will be installed as public modules
85
for all requested Python versions (dh_install doesn't know about python's site-
86
vs. dist-packages issue).
87
88 328
Syntax: ``path/to/file [VERSION_RANGE] [NAMESPACE]``
89
90
debian directory is automatically removed from the path, so you can place your
91
files in debian/ directory and install them from this location (if you want to
92
install them in "debian" namespace, set NAMESPACE to debian). If NAMESPACE is
93
set, all listed files will be installed in .../dist-packages/NAMESPACE/
94
directory.
95 244
96
Examples:
97 328
 * ``foo.py`` installs .../dist-packages/foo.py for all supported Python versions
98
 * ``foo/bar.py 2.6-`` installs .../dist-packages/foo/bar.py for versions >= 2.6
99
 * ``foo/bar.py spam`` installs .../dist-packages/spam/bar.py
100
 * ``debian/*.py spam.egg 2.5`` installs .../python2.5/site-packages/spam/egg/\*.py
101
   files
102 244
103
pyremove files
104 245
~~~~~~~~~~~~~~
105 244
If you want to remove some files installed by build system (from all supported
106
Python versions or only from a subset of these versions), add them to
107
debian/pkg.pyremove file.
108
109
Examples:
110 328
 * ``*.pth`` removes .pth files from .../dist-packages/
111
 * ``bar/baz.py 2.5`` removes .../python2.5/site-packages/bar/baz.py
112 243
113 321
overriding supported / default Python versions
114
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
115
If you want to override system's list of supported Python versions or the
116
default one (f.e. to build a package that includes symlinks for older version
117
of Python or compile .py files only for given interpreter version), you can do
118 328
that via `DEBPYTHON_SUPPORTED` and/or `DEBPYTHON_DEFAULT` env. variables.
119 321
120 328
Example: ``2.5,2.7`` limits the list of supported Python versions to Python 2.5
121 321
and Python 2.7.
122
123 210
124 189
OPTIONS
125
=======
126
--version	show program's version number and exit
127
128
-h, --help	show help message and exit
129
130
--no-guessing-versions	disable guessing other supported Python versions
131
132
--no-guessing-deps	disable guessing dependencies
133
134 259
--no-dbg-cleaning	do not remove any files from debug packages
135
136 317
--no-shebang-rewrite	do not rewrite shebangs
137
138 189
--skip-private	don't check private directories
139
140
-v, --verbose	turn verbose mode on
141
142
-i, --indep	act on architecture independent packages
143
144
-a, --arch	act on architecture dependent packages
145
146
-q, --quiet	be quiet
147
148
-p PACKAGE, --package=PACKAGE	act on the package named PACKAGE
149
150
-N NO_PACKAGE, --no-package=NO_PACKAGE	do not act on the specified package
151
152
-V VRANGE	specify list of supported Python versions. See
153
  pycompile(1) for examples
154
155
-X REGEXPR, --exclude=REGEXPR	exclude items that match given REGEXPR. You may
156
  use this option multiple times to build up a list of things to exclude.
157
158 258
--compile-all	compile all files from given private directory in postinst/rtupdate
159
  not just the ones provided by the package (i.e. do not pass the --package
160
  parameter to pycompile/pyclean)
161
162 189
--depends=DEPENDS	translate given requirements into Debian dependencies
163
  and add them to ${python:Depends}. Use it for missing items in requires.txt
164
165
--recommends=RECOMMENDS		translate given requirements into Debian dependencies
166
  and add them to ${python:Recommends}
167
168
--suggests=SUGGESTS	translate given requirements into Debian dependencies
169
  and add them to ${python:Suggests}
170
171 210
--namespace	use this option (multiple time if necessary) if
172
  namespace_packages.txt is not complete
173
174 231
--ignore-namespace	ignore Egg's namespace declaration and
175
  --namespace option. This option will disable removing (and recreating at
176
  install time) empty __init__.py files. Removing namespace_packages.txt from
177
  egg-info directory has the same effect.
178
179 223
--clean-pycentral	generate maintainer script that will remove byte code
180
  generated by python-central helper
181
182 317
--shebang=COMMAND	use given command as shebang in scripts
183
184 230
--ignore-shebangs	do not translate shebangs into Debian dependencies
185
186 189
SEE ALSO
187
========
188
* /usr/share/doc/python/python-policy.txt.gz
189
* /usr/share/doc/python-doc/README.PyDist (python-doc package)
190
* pycompile(1), pyclean(1)
191
* dh_python3(1), py3compile(1), py3clean(1)
192 272
* Wiki page about converting package to dh_python2:
193
  http://wiki.debian.org/Python/TransitionToDHPython2

Loggerhead 1.17 is a web-based interface for Bazaar branches