blob: 876f350f90e8b8c5e126d1424b9cab64d79c91bd [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +00001.. highlightlang:: none
2
3.. _install-index:
4
Larry Hastings3732ed22014-03-15 21:13:56 -07005********************************************
6 Installing Python Modules (Legacy version)
7********************************************
Georg Brandl116aa622007-08-15 14:28:22 +00008
9:Author: Greg Ward
Georg Brandl116aa622007-08-15 14:28:22 +000010
Christian Heimes5b5e81c2007-12-31 16:14:33 +000011.. TODO: Fill in XXX comments
Georg Brandl116aa622007-08-15 14:28:22 +000012
Christian Heimes5b5e81c2007-12-31 16:14:33 +000013.. The audience for this document includes people who don't know anything
14 about Python and aren't about to learn the language just in order to
15 install and maintain it for their users, i.e. system administrators.
16 Thus, I have to be sure to explain the basics at some point:
17 sys.path and PYTHONPATH at least. Should probably give pointers to
18 other docs on "import site", PYTHONSTARTUP, PYTHONHOME, etc.
Georg Brandl48310cd2009-01-03 21:18:54 +000019
Christian Heimes5b5e81c2007-12-31 16:14:33 +000020 Finally, it might be useful to include all the material from my "Care
21 and Feeding of a Python Installation" talk in here somewhere. Yow!
Georg Brandl116aa622007-08-15 14:28:22 +000022
Nick Coghlanb5c4fd02013-12-10 21:24:55 +100023This document describes the Python Distribution Utilities ("Distutils") from the
24end-user's point-of-view, describing how to extend the capabilities of a
25standard Python installation by building and installing third-party Python
26modules and extensions.
Georg Brandl116aa622007-08-15 14:28:22 +000027
Nick Coghlanb5c4fd02013-12-10 21:24:55 +100028
29.. note::
30
31 This guide only covers the basic tools for installing extensions that are
32 provided as part of this version of Python. Third party tools offer easier
33 to use and more secure alternatives. Refer to the
34 `quick recommendations section
35 <https://python-packaging-user-guide.readthedocs.org/en/latest/current.html>`__
36 in the Python Packaging User Guide for more information.
Georg Brandl116aa622007-08-15 14:28:22 +000037
38
39.. _inst-intro:
40
41Introduction
42============
43
44Although Python's extensive standard library covers many programming needs,
45there often comes a time when you need to add some new functionality to your
46Python installation in the form of third-party modules. This might be necessary
47to support your own programming, or to support an application that you want to
48use and that happens to be written in Python.
49
50In the past, there has been little support for adding third-party modules to an
51existing Python installation. With the introduction of the Python Distribution
52Utilities (Distutils for short) in Python 2.0, this changed.
53
54This document is aimed primarily at the people who need to install third-party
55Python modules: end-users and system administrators who just need to get some
56Python application running, and existing Python programmers who want to add some
57new goodies to their toolbox. You don't need to know Python to read this
58document; there will be some brief forays into using Python's interactive mode
59to explore your installation, but that's it. If you're looking for information
60on how to distribute your own Python modules so that others may use them, see
Larry Hastings3732ed22014-03-15 21:13:56 -070061the :ref:`distutils-index` manual. :ref:`debug-setup-script` may also be of
62interest.
Georg Brandl116aa622007-08-15 14:28:22 +000063
64
65.. _inst-trivial-install:
66
67Best case: trivial installation
68-------------------------------
69
70In the best case, someone will have prepared a special version of the module
71distribution you want to install that is targeted specifically at your platform
72and is installed just like any other software on your platform. For example,
73the module developer might make an executable installer available for Windows
74users, an RPM package for users of RPM-based Linux systems (Red Hat, SuSE,
75Mandrake, and many others), a Debian package for users of Debian-based Linux
76systems, and so forth.
77
78In that case, you would download the installer appropriate to your platform and
79do the obvious thing with it: run it if it's an executable installer, ``rpm
80--install`` it if it's an RPM, etc. You don't need to run Python or a setup
81script, you don't need to compile anything---you might not even need to read any
Éric Araujo59e387e2011-07-26 16:53:17 +020082instructions (although it's always a good idea to do so anyway).
Georg Brandl116aa622007-08-15 14:28:22 +000083
84Of course, things will not always be that easy. You might be interested in a
85module distribution that doesn't have an easy-to-use installer for your
86platform. In that case, you'll have to start with the source distribution
87released by the module's author/maintainer. Installing from a source
88distribution is not too hard, as long as the modules are packaged in the
89standard way. The bulk of this document is about building and installing
90modules from standard source distributions.
91
92
93.. _inst-new-standard:
94
95The new standard: Distutils
96---------------------------
97
98If you download a module source distribution, you can tell pretty quickly if it
99was packaged and distributed in the standard way, i.e. using the Distutils.
100First, the distribution's name and version number will be featured prominently
101in the name of the downloaded archive, e.g. :file:`foo-1.0.tar.gz` or
102:file:`widget-0.9.7.zip`. Next, the archive will unpack into a similarly-named
103directory: :file:`foo-1.0` or :file:`widget-0.9.7`. Additionally, the
104distribution will contain a setup script :file:`setup.py`, and a file named
105:file:`README.txt` or possibly just :file:`README`, which should explain that
Éric Araujob805c472011-06-08 01:11:36 +0200106building and installing the module distribution is a simple matter of running
107one command from a terminal::
Georg Brandl116aa622007-08-15 14:28:22 +0000108
109 python setup.py install
110
Éric Araujo355d48a2011-08-19 09:28:46 +0200111For Windows, this command should be run from a command prompt window
Éric Araujoa2d26182011-08-19 03:12:38 +0200112(:menuselection:`Start --> Accessories`)::
Éric Araujob805c472011-06-08 01:11:36 +0200113
114 setup.py install
115
Georg Brandl116aa622007-08-15 14:28:22 +0000116If all these things are true, then you already know how to build and install the
117modules you've just downloaded: Run the command above. Unless you need to
118install things in a non-standard way or customize the build process, you don't
119really need this manual. Or rather, the above command is everything you need to
120get out of this manual.
121
122
123.. _inst-standard-install:
124
125Standard Build and Install
126==========================
127
128As described in section :ref:`inst-new-standard`, building and installing a module
Éric Araujob805c472011-06-08 01:11:36 +0200129distribution using the Distutils is usually one simple command to run from a
130terminal::
Georg Brandl116aa622007-08-15 14:28:22 +0000131
132 python setup.py install
133
Georg Brandl116aa622007-08-15 14:28:22 +0000134
135.. _inst-platform-variations:
136
137Platform variations
138-------------------
139
140You should always run the setup command from the distribution root directory,
141i.e. the top-level subdirectory that the module source distribution unpacks
142into. For example, if you've just downloaded a module source distribution
143:file:`foo-1.0.tar.gz` onto a Unix system, the normal thing to do is::
144
145 gunzip -c foo-1.0.tar.gz | tar xf - # unpacks into directory foo-1.0
146 cd foo-1.0
147 python setup.py install
148
149On Windows, you'd probably download :file:`foo-1.0.zip`. If you downloaded the
150archive file to :file:`C:\\Temp`, then it would unpack into
151:file:`C:\\Temp\\foo-1.0`; you can use either a archive manipulator with a
152graphical user interface (such as WinZip) or a command-line tool (such as
153:program:`unzip` or :program:`pkunzip`) to unpack the archive. Then, open a
Éric Araujoa2d26182011-08-19 03:12:38 +0200154command prompt window and run::
Georg Brandl116aa622007-08-15 14:28:22 +0000155
156 cd c:\Temp\foo-1.0
157 python setup.py install
158
159
160.. _inst-splitting-up:
161
162Splitting the job up
163--------------------
164
165Running ``setup.py install`` builds and installs all modules in one run. If you
166prefer to work incrementally---especially useful if you want to customize the
167build process, or if things are going wrong---you can use the setup script to do
168one thing at a time. This is particularly helpful when the build and install
169will be done by different users---for example, you might want to build a module
170distribution and hand it off to a system administrator for installation (or do
171it yourself, with super-user privileges).
172
173For example, you can build everything in one step, and then install everything
174in a second step, by invoking the setup script twice::
175
176 python setup.py build
177 python setup.py install
178
179If you do this, you will notice that running the :command:`install` command
180first runs the :command:`build` command, which---in this case---quickly notices
181that it has nothing to do, since everything in the :file:`build` directory is
182up-to-date.
183
184You may not need this ability to break things down often if all you do is
185install modules downloaded off the 'net, but it's very handy for more advanced
186tasks. If you get into distributing your own Python modules and extensions,
187you'll run lots of individual Distutils commands on their own.
188
189
190.. _inst-how-build-works:
191
192How building works
193------------------
194
195As implied above, the :command:`build` command is responsible for putting the
196files to install into a *build directory*. By default, this is :file:`build`
197under the distribution root; if you're excessively concerned with speed, or want
198to keep the source tree pristine, you can change the build directory with the
199:option:`--build-base` option. For example::
200
Petri Lehtinen9f74c6c2013-02-23 19:26:56 +0100201 python setup.py build --build-base=/path/to/pybuild/foo-1.0
Georg Brandl116aa622007-08-15 14:28:22 +0000202
203(Or you could do this permanently with a directive in your system or personal
204Distutils configuration file; see section :ref:`inst-config-files`.) Normally, this
205isn't necessary.
206
207The default layout for the build tree is as follows::
208
209 --- build/ --- lib/
210 or
211 --- build/ --- lib.<plat>/
212 temp.<plat>/
213
214where ``<plat>`` expands to a brief description of the current OS/hardware
215platform and Python version. The first form, with just a :file:`lib` directory,
216is used for "pure module distributions"---that is, module distributions that
217include only pure Python modules. If a module distribution contains any
218extensions (modules written in C/C++), then the second form, with two ``<plat>``
219directories, is used. In that case, the :file:`temp.{plat}` directory holds
220temporary files generated by the compile/link process that don't actually get
221installed. In either case, the :file:`lib` (or :file:`lib.{plat}`) directory
222contains all Python modules (pure Python and extensions) that will be installed.
223
224In the future, more directories will be added to handle Python scripts,
225documentation, binary executables, and whatever else is needed to handle the job
226of installing Python modules and applications.
227
228
229.. _inst-how-install-works:
230
231How installation works
232----------------------
233
234After the :command:`build` command runs (whether you run it explicitly, or the
235:command:`install` command does it for you), the work of the :command:`install`
236command is relatively simple: all it has to do is copy everything under
237:file:`build/lib` (or :file:`build/lib.{plat}`) to your chosen installation
238directory.
239
240If you don't choose an installation directory---i.e., if you just run ``setup.py
241install``\ ---then the :command:`install` command installs to the standard
242location for third-party Python modules. This location varies by platform and
243by how you built/installed Python itself. On Unix (and Mac OS X, which is also
244Unix-based), it also depends on whether the module distribution being installed
245is pure Python or contains extensions ("non-pure"):
246
Georg Brandl44ea77b2013-03-28 13:28:44 +0100247.. tabularcolumns:: |l|l|l|l|
248
Georg Brandl116aa622007-08-15 14:28:22 +0000249+-----------------+-----------------------------------------------------+--------------------------------------------------+-------+
250| Platform | Standard installation location | Default value | Notes |
251+=================+=====================================================+==================================================+=======+
252| Unix (pure) | :file:`{prefix}/lib/python{X.Y}/site-packages` | :file:`/usr/local/lib/python{X.Y}/site-packages` | \(1) |
253+-----------------+-----------------------------------------------------+--------------------------------------------------+-------+
254| Unix (non-pure) | :file:`{exec-prefix}/lib/python{X.Y}/site-packages` | :file:`/usr/local/lib/python{X.Y}/site-packages` | \(1) |
255+-----------------+-----------------------------------------------------+--------------------------------------------------+-------+
Brian Curtin308053e2011-05-03 21:57:00 -0500256| Windows | :file:`{prefix}\\Lib\\site-packages` | :file:`C:\\Python{XY}\\Lib\\site-packages` | \(2) |
Georg Brandl116aa622007-08-15 14:28:22 +0000257+-----------------+-----------------------------------------------------+--------------------------------------------------+-------+
258
259Notes:
260
261(1)
262 Most Linux distributions include Python as a standard part of the system, so
263 :file:`{prefix}` and :file:`{exec-prefix}` are usually both :file:`/usr` on
264 Linux. If you build Python yourself on Linux (or any Unix-like system), the
265 default :file:`{prefix}` and :file:`{exec-prefix}` are :file:`/usr/local`.
266
267(2)
268 The default installation directory on Windows was :file:`C:\\Program
269 Files\\Python` under Python 1.6a1, 1.5.2, and earlier.
270
271:file:`{prefix}` and :file:`{exec-prefix}` stand for the directories that Python
272is installed to, and where it finds its libraries at run-time. They are always
273the same under Windows, and very often the same under Unix and Mac OS X. You
274can find out what your Python installation uses for :file:`{prefix}` and
275:file:`{exec-prefix}` by running Python in interactive mode and typing a few
276simple commands. Under Unix, just type ``python`` at the shell prompt. Under
277Windows, choose :menuselection:`Start --> Programs --> Python X.Y -->
278Python (command line)`. Once the interpreter is started, you type Python code
279at the prompt. For example, on my Linux system, I type the three Python
280statements shown below, and get the output as shown, to find out my
281:file:`{prefix}` and :file:`{exec-prefix}`::
282
Georg Brandl48310cd2009-01-03 21:18:54 +0000283 Python 2.4 (#26, Aug 7 2004, 17:19:02)
Georg Brandl116aa622007-08-15 14:28:22 +0000284 Type "help", "copyright", "credits" or "license" for more information.
285 >>> import sys
286 >>> sys.prefix
287 '/usr'
288 >>> sys.exec_prefix
289 '/usr'
290
Éric Araujo6ef038e2011-08-06 16:30:42 +0200291A few other placeholders are used in this document: :file:`{X.Y}` stands for the
292version of Python, for example ``3.2``; :file:`{abiflags}` will be replaced by
293the value of :data:`sys.abiflags` or the empty string for platforms which don't
294define ABI flags; :file:`{distname}` will be replaced by the name of the module
295distribution being installed. Dots and capitalization are important in the
296paths; for example, a value that uses ``python3.2`` on UNIX will typically use
297``Python32`` on Windows.
298
Georg Brandl116aa622007-08-15 14:28:22 +0000299If you don't want to install modules to the standard location, or if you don't
300have permission to write there, then you need to read about alternate
301installations in section :ref:`inst-alt-install`. If you want to customize your
302installation directories more heavily, see section :ref:`inst-custom-install` on
303custom installations.
304
305
306.. _inst-alt-install:
307
308Alternate Installation
309======================
310
311Often, it is necessary or desirable to install modules to a location other than
312the standard location for third-party Python modules. For example, on a Unix
313system you might not have permission to write to the standard third-party module
314directory. Or you might wish to try out a module before making it a standard
315part of your local Python installation. This is especially true when upgrading
316a distribution already present: you want to make sure your existing base of
317scripts still works with the new version before actually upgrading.
318
319The Distutils :command:`install` command is designed to make installing module
320distributions to an alternate location simple and painless. The basic idea is
321that you supply a base directory for the installation, and the
322:command:`install` command picks a set of directories (called an *installation
323scheme*) under this base directory in which to install files. The details
324differ across platforms, so read whichever of the following sections applies to
325you.
326
Éric Araujo6ef038e2011-08-06 16:30:42 +0200327Note that the various alternate installation schemes are mutually exclusive: you
328can pass ``--user``, or ``--home``, or ``--prefix`` and ``--exec-prefix``, or
329``--install-base`` and ``--install-platbase``, but you can't mix from these
330groups.
Georg Brandl116aa622007-08-15 14:28:22 +0000331
Éric Araujo6ef038e2011-08-06 16:30:42 +0200332
333.. _inst-alt-install-user:
334
335Alternate installation: the user scheme
336---------------------------------------
337
338This scheme is designed to be the most convenient solution for users that don't
339have write permission to the global site-packages directory or don't want to
340install into it. It is enabled with a simple option::
341
342 python setup.py install --user
343
344Files will be installed into subdirectories of :data:`site.USER_BASE` (written
345as :file:`{userbase}` hereafter). This scheme installs pure Python modules and
346extension modules in the same location (also known as :data:`site.USER_SITE`).
347Here are the values for UNIX, including Mac OS X:
348
349=============== ===========================================================
350Type of file Installation directory
351=============== ===========================================================
352modules :file:`{userbase}/lib/python{X.Y}/site-packages`
353scripts :file:`{userbase}/bin`
354data :file:`{userbase}`
355C headers :file:`{userbase}/include/python{X.Y}{abiflags}/{distname}`
356=============== ===========================================================
357
358And here are the values used on Windows:
359
360=============== ===========================================================
361Type of file Installation directory
362=============== ===========================================================
363modules :file:`{userbase}\\Python{XY}\\site-packages`
Steve Dower17be5142015-02-14 09:50:59 -0800364scripts :file:`{userbase}\\Python{XY}\\Scripts`
Éric Araujo6ef038e2011-08-06 16:30:42 +0200365data :file:`{userbase}`
366C headers :file:`{userbase}\\Python{XY}\\Include\\{distname}`
367=============== ===========================================================
368
369The advantage of using this scheme compared to the other ones described below is
370that the user site-packages directory is under normal conditions always included
371in :data:`sys.path` (see :mod:`site` for more information), which means that
372there is no additional step to perform after running the :file:`setup.py` script
373to finalize the installation.
374
375The :command:`build_ext` command also has a ``--user`` option to add
376:file:`{userbase}/include` to the compiler search path for header files and
377:file:`{userbase}/lib` to the compiler search path for libraries as well as to
378the runtime search path for shared C libraries (rpath).
379
380
381.. _inst-alt-install-home:
Georg Brandl116aa622007-08-15 14:28:22 +0000382
383Alternate installation: the home scheme
384---------------------------------------
385
386The idea behind the "home scheme" is that you build and maintain a personal
387stash of Python modules. This scheme's name is derived from the idea of a
388"home" directory on Unix, since it's not unusual for a Unix user to make their
389home directory have a layout similar to :file:`/usr/` or :file:`/usr/local/`.
Georg Brandlf6914aa2010-07-26 15:11:49 +0000390This scheme can be used by anyone, regardless of the operating system they
391are installing for.
Georg Brandl116aa622007-08-15 14:28:22 +0000392
393Installing a new module distribution is as simple as ::
394
395 python setup.py install --home=<dir>
396
397where you can supply any directory you like for the :option:`--home` option. On
398Unix, lazy typists can just type a tilde (``~``); the :command:`install` command
399will expand this to your home directory::
400
401 python setup.py install --home=~
402
Éric Araujo6ef038e2011-08-06 16:30:42 +0200403To make Python find the distributions installed with this scheme, you may have
404to :ref:`modify Python's search path <inst-search-path>` or edit
405:mod:`sitecustomize` (see :mod:`site`) to call :func:`site.addsitedir` or edit
406:data:`sys.path`.
407
Georg Brandl116aa622007-08-15 14:28:22 +0000408The :option:`--home` option defines the installation base directory. Files are
409installed to the following directories under the installation base as follows:
410
Éric Araujo6ef038e2011-08-06 16:30:42 +0200411=============== ===========================================================
412Type of file Installation directory
413=============== ===========================================================
414modules :file:`{home}/lib/python`
415scripts :file:`{home}/bin`
416data :file:`{home}`
417C headers :file:`{home}/include/python/{distname}`
418=============== ===========================================================
419
420(Mentally replace slashes with backslashes if you're on Windows.)
Georg Brandl116aa622007-08-15 14:28:22 +0000421
Georg Brandl116aa622007-08-15 14:28:22 +0000422
Éric Araujo6ef038e2011-08-06 16:30:42 +0200423.. _inst-alt-install-prefix-unix:
Georg Brandl116aa622007-08-15 14:28:22 +0000424
425Alternate installation: Unix (the prefix scheme)
426------------------------------------------------
427
428The "prefix scheme" is useful when you wish to use one Python installation to
429perform the build/install (i.e., to run the setup script), but install modules
430into the third-party module directory of a different Python installation (or
431something that looks like a different Python installation). If this sounds a
Éric Araujo6ef038e2011-08-06 16:30:42 +0200432trifle unusual, it is---that's why the user and home schemes come before. However,
Georg Brandl116aa622007-08-15 14:28:22 +0000433there are at least two known cases where the prefix scheme will be useful.
434
435First, consider that many Linux distributions put Python in :file:`/usr`, rather
436than the more traditional :file:`/usr/local`. This is entirely appropriate,
437since in those cases Python is part of "the system" rather than a local add-on.
438However, if you are installing Python modules from source, you probably want
439them to go in :file:`/usr/local/lib/python2.{X}` rather than
440:file:`/usr/lib/python2.{X}`. This can be done with ::
441
442 /usr/bin/python setup.py install --prefix=/usr/local
443
444Another possibility is a network filesystem where the name used to write to a
445remote directory is different from the name used to read it: for example, the
446Python interpreter accessed as :file:`/usr/local/bin/python` might search for
447modules in :file:`/usr/local/lib/python2.{X}`, but those modules would have to
448be installed to, say, :file:`/mnt/{@server}/export/lib/python2.{X}`. This could
449be done with ::
450
451 /usr/local/bin/python setup.py install --prefix=/mnt/@server/export
452
453In either case, the :option:`--prefix` option defines the installation base, and
454the :option:`--exec-prefix` option defines the platform-specific installation
455base, which is used for platform-specific files. (Currently, this just means
456non-pure module distributions, but could be expanded to C libraries, binary
457executables, etc.) If :option:`--exec-prefix` is not supplied, it defaults to
458:option:`--prefix`. Files are installed as follows:
459
Éric Araujo6ef038e2011-08-06 16:30:42 +0200460================= ==========================================================
461Type of file Installation directory
462================= ==========================================================
463Python modules :file:`{prefix}/lib/python{X.Y}/site-packages`
464extension modules :file:`{exec-prefix}/lib/python{X.Y}/site-packages`
465scripts :file:`{prefix}/bin`
466data :file:`{prefix}`
467C headers :file:`{prefix}/include/python{X.Y}{abiflags}/{distname}`
468================= ==========================================================
Georg Brandl116aa622007-08-15 14:28:22 +0000469
470There is no requirement that :option:`--prefix` or :option:`--exec-prefix`
471actually point to an alternate Python installation; if the directories listed
472above do not already exist, they are created at installation time.
473
474Incidentally, the real reason the prefix scheme is important is simply that a
475standard Unix installation uses the prefix scheme, but with :option:`--prefix`
476and :option:`--exec-prefix` supplied by Python itself as ``sys.prefix`` and
477``sys.exec_prefix``. Thus, you might think you'll never use the prefix scheme,
478but every time you run ``python setup.py install`` without any other options,
479you're using it.
480
481Note that installing extensions to an alternate Python installation has no
482effect on how those extensions are built: in particular, the Python header files
483(:file:`Python.h` and friends) installed with the Python interpreter used to run
484the setup script will be used in compiling extensions. It is your
485responsibility to ensure that the interpreter used to run extensions installed
486in this way is compatible with the interpreter used to build them. The best way
487to do this is to ensure that the two interpreters are the same version of Python
488(possibly different builds, or possibly copies of the same build). (Of course,
489if your :option:`--prefix` and :option:`--exec-prefix` don't even point to an
490alternate Python installation, this is immaterial.)
491
492
Éric Araujo6ef038e2011-08-06 16:30:42 +0200493.. _inst-alt-install-prefix-windows:
Georg Brandl116aa622007-08-15 14:28:22 +0000494
495Alternate installation: Windows (the prefix scheme)
496---------------------------------------------------
497
498Windows has no concept of a user's home directory, and since the standard Python
499installation under Windows is simpler than under Unix, the :option:`--prefix`
500option has traditionally been used to install additional packages in separate
501locations on Windows. ::
502
503 python setup.py install --prefix="\Temp\Python"
504
505to install modules to the :file:`\\Temp\\Python` directory on the current drive.
506
507The installation base is defined by the :option:`--prefix` option; the
Éric Araujo6ef038e2011-08-06 16:30:42 +0200508:option:`--exec-prefix` option is not supported under Windows, which means that
509pure Python modules and extension modules are installed into the same location.
510Files are installed as follows:
Georg Brandl116aa622007-08-15 14:28:22 +0000511
Éric Araujo6ef038e2011-08-06 16:30:42 +0200512=============== ==========================================================
513Type of file Installation directory
514=============== ==========================================================
515modules :file:`{prefix}\\Lib\\site-packages`
516scripts :file:`{prefix}\\Scripts`
517data :file:`{prefix}`
518C headers :file:`{prefix}\\Include\\{distname}`
519=============== ==========================================================
Georg Brandl116aa622007-08-15 14:28:22 +0000520
521
522.. _inst-custom-install:
523
524Custom Installation
525===================
526
527Sometimes, the alternate installation schemes described in section
528:ref:`inst-alt-install` just don't do what you want. You might want to tweak just
529one or two directories while keeping everything under the same base directory,
530or you might want to completely redefine the installation scheme. In either
531case, you're creating a *custom installation scheme*.
532
Éric Araujo6ef038e2011-08-06 16:30:42 +0200533To create a custom installation scheme, you start with one of the alternate
534schemes and override some of the installation directories used for the various
535types of files, using these options:
536
537====================== =======================
538Type of file Override option
539====================== =======================
540Python modules ``--install-purelib``
541extension modules ``--install-platlib``
542all modules ``--install-lib``
543scripts ``--install-scripts``
544data ``--install-data``
545C headers ``--install-headers``
546====================== =======================
547
548These override options can be relative, absolute,
Georg Brandl116aa622007-08-15 14:28:22 +0000549or explicitly defined in terms of one of the installation base directories.
550(There are two installation base directories, and they are normally the same---
551they only differ when you use the Unix "prefix scheme" and supply different
Éric Araujo6ef038e2011-08-06 16:30:42 +0200552``--prefix`` and ``--exec-prefix`` options; using ``--install-lib`` will
553override values computed or given for ``--install-purelib`` and
554``--install-platlib``, and is recommended for schemes that don't make a
555difference between Python and extension modules.)
Georg Brandl116aa622007-08-15 14:28:22 +0000556
557For example, say you're installing a module distribution to your home directory
558under Unix---but you want scripts to go in :file:`~/scripts` rather than
559:file:`~/bin`. As you might expect, you can override this directory with the
560:option:`--install-scripts` option; in this case, it makes most sense to supply
561a relative path, which will be interpreted relative to the installation base
562directory (your home directory, in this case)::
563
564 python setup.py install --home=~ --install-scripts=scripts
565
566Another Unix example: suppose your Python installation was built and installed
567with a prefix of :file:`/usr/local/python`, so under a standard installation
568scripts will wind up in :file:`/usr/local/python/bin`. If you want them in
569:file:`/usr/local/bin` instead, you would supply this absolute directory for the
570:option:`--install-scripts` option::
571
572 python setup.py install --install-scripts=/usr/local/bin
573
574(This performs an installation using the "prefix scheme," where the prefix is
575whatever your Python interpreter was installed with--- :file:`/usr/local/python`
576in this case.)
577
578If you maintain Python on Windows, you might want third-party modules to live in
579a subdirectory of :file:`{prefix}`, rather than right in :file:`{prefix}`
580itself. This is almost as easy as customizing the script installation directory
581---you just have to remember that there are two types of modules to worry about,
Éric Araujo6ef038e2011-08-06 16:30:42 +0200582Python and extension modules, which can conveniently be both controlled by one
583option::
Georg Brandl116aa622007-08-15 14:28:22 +0000584
Éric Araujo6ef038e2011-08-06 16:30:42 +0200585 python setup.py install --install-lib=Site
Georg Brandl116aa622007-08-15 14:28:22 +0000586
Éric Araujo6ef038e2011-08-06 16:30:42 +0200587The specified installation directory is relative to :file:`{prefix}`. Of
588course, you also have to ensure that this directory is in Python's module
589search path, such as by putting a :file:`.pth` file in a site directory (see
590:mod:`site`). See section :ref:`inst-search-path` to find out how to modify
591Python's search path.
Georg Brandl116aa622007-08-15 14:28:22 +0000592
593If you want to define an entire installation scheme, you just have to supply all
594of the installation directory options. The recommended way to do this is to
595supply relative paths; for example, if you want to maintain all Python
596module-related files under :file:`python` in your home directory, and you want a
597separate directory for each platform that you use your home directory from, you
598might define the following installation scheme::
599
600 python setup.py install --home=~ \
601 --install-purelib=python/lib \
602 --install-platlib=python/lib.$PLAT \
603 --install-scripts=python/scripts
604 --install-data=python/data
605
Georg Brandl81ac1ce2007-08-31 17:17:17 +0000606or, equivalently, ::
Georg Brandl116aa622007-08-15 14:28:22 +0000607
608 python setup.py install --home=~/python \
609 --install-purelib=lib \
610 --install-platlib='lib.$PLAT' \
611 --install-scripts=scripts
612 --install-data=data
613
614``$PLAT`` is not (necessarily) an environment variable---it will be expanded by
615the Distutils as it parses your command line options, just as it does when
616parsing your configuration file(s).
617
Georg Brandl116aa622007-08-15 14:28:22 +0000618Obviously, specifying the entire installation scheme every time you install a
619new module distribution would be very tedious. Thus, you can put these options
620into your Distutils config file (see section :ref:`inst-config-files`)::
621
622 [install]
623 install-base=$HOME
624 install-purelib=python/lib
625 install-platlib=python/lib.$PLAT
626 install-scripts=python/scripts
627 install-data=python/data
628
629or, equivalently, ::
630
631 [install]
632 install-base=$HOME/python
633 install-purelib=lib
634 install-platlib=lib.$PLAT
635 install-scripts=scripts
636 install-data=data
637
638Note that these two are *not* equivalent if you supply a different installation
639base directory when you run the setup script. For example, ::
640
641 python setup.py install --install-base=/tmp
642
Éric Araujo6ef038e2011-08-06 16:30:42 +0200643would install pure modules to :file:`/tmp/python/lib` in the first case, and
644to :file:`/tmp/lib` in the second case. (For the second case, you probably
Georg Brandl116aa622007-08-15 14:28:22 +0000645want to supply an installation base of :file:`/tmp/python`.)
646
647You probably noticed the use of ``$HOME`` and ``$PLAT`` in the sample
648configuration file input. These are Distutils configuration variables, which
649bear a strong resemblance to environment variables. In fact, you can use
650environment variables in config files on platforms that have such a notion but
651the Distutils additionally define a few extra variables that may not be in your
652environment, such as ``$PLAT``. (And of course, on systems that don't have
653environment variables, such as Mac OS 9, the configuration variables supplied by
654the Distutils are the only ones you can use.) See section :ref:`inst-config-files`
655for details.
656
Georg Brandl521ed522013-05-12 12:36:07 +0200657.. note:: When a :ref:`virtual environment <venv-def>` is activated, any options
658 that change the installation path will be ignored from all distutils configuration
659 files to prevent inadvertently installing projects outside of the virtual
660 environment.
661
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000662.. XXX need some Windows examples---when would custom installation schemes be
663 needed on those platforms?
Georg Brandl116aa622007-08-15 14:28:22 +0000664
Georg Brandl116aa622007-08-15 14:28:22 +0000665
Éric Araujo6ef038e2011-08-06 16:30:42 +0200666.. XXX Move this to Doc/using
Georg Brandl116aa622007-08-15 14:28:22 +0000667
668.. _inst-search-path:
669
670Modifying Python's Search Path
671------------------------------
672
673When the Python interpreter executes an :keyword:`import` statement, it searches
674for both Python code and extension modules along a search path. A default value
675for the path is configured into the Python binary when the interpreter is built.
676You can determine the path by importing the :mod:`sys` module and printing the
677value of ``sys.path``. ::
678
679 $ python
680 Python 2.2 (#11, Oct 3 2002, 13:31:27)
681 [GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
Georg Brandl1f01deb2009-01-03 22:47:39 +0000682 Type "help", "copyright", "credits" or "license" for more information.
Georg Brandl116aa622007-08-15 14:28:22 +0000683 >>> import sys
684 >>> sys.path
Georg Brandl48310cd2009-01-03 21:18:54 +0000685 ['', '/usr/local/lib/python2.3', '/usr/local/lib/python2.3/plat-linux2',
686 '/usr/local/lib/python2.3/lib-tk', '/usr/local/lib/python2.3/lib-dynload',
Georg Brandl116aa622007-08-15 14:28:22 +0000687 '/usr/local/lib/python2.3/site-packages']
688 >>>
689
690The null string in ``sys.path`` represents the current working directory.
691
Georg Brandl116aa622007-08-15 14:28:22 +0000692The expected convention for locally installed packages is to put them in the
693:file:`{...}/site-packages/` directory, but you may want to install Python
694modules into some arbitrary directory. For example, your site may have a
695convention of keeping all software related to the web server under :file:`/www`.
696Add-on Python modules might then belong in :file:`/www/python`, and in order to
697import them, this directory must be added to ``sys.path``. There are several
698different ways to add the directory.
699
700The most convenient way is to add a path configuration file to a directory
701that's already on Python's path, usually to the :file:`.../site-packages/`
702directory. Path configuration files have an extension of :file:`.pth`, and each
703line must contain a single path that will be appended to ``sys.path``. (Because
704the new paths are appended to ``sys.path``, modules in the added directories
705will not override standard modules. This means you can't use this mechanism for
706installing fixed versions of standard modules.)
707
708Paths can be absolute or relative, in which case they're relative to the
Christian Heimes9cd17752007-11-18 19:35:23 +0000709directory containing the :file:`.pth` file. See the documentation of
Thomas Woutersed03b412007-08-28 21:37:11 +0000710the :mod:`site` module for more information.
Georg Brandl116aa622007-08-15 14:28:22 +0000711
712A slightly less convenient way is to edit the :file:`site.py` file in Python's
713standard library, and modify ``sys.path``. :file:`site.py` is automatically
714imported when the Python interpreter is executed, unless the :option:`-S` switch
715is supplied to suppress this behaviour. So you could simply edit
716:file:`site.py` and add two lines to it::
717
718 import sys
719 sys.path.append('/www/python/')
720
721However, if you reinstall the same major version of Python (perhaps when
722upgrading from 2.2 to 2.2.2, for example) :file:`site.py` will be overwritten by
723the stock version. You'd have to remember that it was modified and save a copy
724before doing the installation.
725
726There are two environment variables that can modify ``sys.path``.
727:envvar:`PYTHONHOME` sets an alternate value for the prefix of the Python
728installation. For example, if :envvar:`PYTHONHOME` is set to ``/www/python``,
729the search path will be set to ``['', '/www/python/lib/pythonX.Y/',
730'/www/python/lib/pythonX.Y/plat-linux2', ...]``.
731
732The :envvar:`PYTHONPATH` variable can be set to a list of paths that will be
733added to the beginning of ``sys.path``. For example, if :envvar:`PYTHONPATH` is
734set to ``/www/python:/opt/py``, the search path will begin with
735``['/www/python', '/opt/py']``. (Note that directories must exist in order to
736be added to ``sys.path``; the :mod:`site` module removes paths that don't
737exist.)
738
739Finally, ``sys.path`` is just a regular Python list, so any Python application
740can modify it by adding or removing entries.
741
742
743.. _inst-config-files:
744
745Distutils Configuration Files
746=============================
747
748As mentioned above, you can use Distutils configuration files to record personal
749or site preferences for any Distutils options. That is, any option to any
750command can be stored in one of two or three (depending on your platform)
751configuration files, which will be consulted before the command-line is parsed.
752This means that configuration files will override default values, and the
753command-line will in turn override configuration files. Furthermore, if
754multiple configuration files apply, values from "earlier" files are overridden
755by "later" files.
756
757
758.. _inst-config-filenames:
759
760Location and names of config files
761----------------------------------
762
763The names and locations of the configuration files vary slightly across
764platforms. On Unix and Mac OS X, the three configuration files (in the order
765they are processed) are:
766
767+--------------+----------------------------------------------------------+-------+
768| Type of file | Location and filename | Notes |
769+==============+==========================================================+=======+
770| system | :file:`{prefix}/lib/python{ver}/distutils/distutils.cfg` | \(1) |
771+--------------+----------------------------------------------------------+-------+
772| personal | :file:`$HOME/.pydistutils.cfg` | \(2) |
773+--------------+----------------------------------------------------------+-------+
774| local | :file:`setup.cfg` | \(3) |
775+--------------+----------------------------------------------------------+-------+
776
777And on Windows, the configuration files are:
778
779+--------------+-------------------------------------------------+-------+
780| Type of file | Location and filename | Notes |
781+==============+=================================================+=======+
782| system | :file:`{prefix}\\Lib\\distutils\\distutils.cfg` | \(4) |
783+--------------+-------------------------------------------------+-------+
784| personal | :file:`%HOME%\\pydistutils.cfg` | \(5) |
785+--------------+-------------------------------------------------+-------+
786| local | :file:`setup.cfg` | \(3) |
787+--------------+-------------------------------------------------+-------+
788
Tarek Ziadéc7c71ff2009-10-27 23:12:01 +0000789On all platforms, the "personal" file can be temporarily disabled by
790passing the `--no-user-cfg` option.
791
Georg Brandl116aa622007-08-15 14:28:22 +0000792Notes:
793
794(1)
795 Strictly speaking, the system-wide configuration file lives in the directory
796 where the Distutils are installed; under Python 1.6 and later on Unix, this is
797 as shown. For Python 1.5.2, the Distutils will normally be installed to
798 :file:`{prefix}/lib/python1.5/site-packages/distutils`, so the system
799 configuration file should be put there under Python 1.5.2.
800
801(2)
802 On Unix, if the :envvar:`HOME` environment variable is not defined, the user's
803 home directory will be determined with the :func:`getpwuid` function from the
Tarek Ziadéf3b33222009-08-21 14:22:45 +0000804 standard :mod:`pwd` module. This is done by the :func:`os.path.expanduser`
805 function used by Distutils.
Georg Brandl116aa622007-08-15 14:28:22 +0000806
807(3)
808 I.e., in the current directory (usually the location of the setup script).
809
810(4)
811 (See also note (1).) Under Python 1.6 and later, Python's default "installation
812 prefix" is :file:`C:\\Python`, so the system configuration file is normally
813 :file:`C:\\Python\\Lib\\distutils\\distutils.cfg`. Under Python 1.5.2, the
814 default prefix was :file:`C:\\Program Files\\Python`, and the Distutils were not
815 part of the standard library---so the system configuration file would be
816 :file:`C:\\Program Files\\Python\\distutils\\distutils.cfg` in a standard Python
817 1.5.2 installation under Windows.
818
819(5)
Tarek Ziadéf3b33222009-08-21 14:22:45 +0000820 On Windows, if the :envvar:`HOME` environment variable is not defined,
821 :envvar:`USERPROFILE` then :envvar:`HOMEDRIVE` and :envvar:`HOMEPATH` will
822 be tried. This is done by the :func:`os.path.expanduser` function used
823 by Distutils.
Georg Brandl116aa622007-08-15 14:28:22 +0000824
825
826.. _inst-config-syntax:
827
828Syntax of config files
829----------------------
830
831The Distutils configuration files all have the same syntax. The config files
832are grouped into sections. There is one section for each Distutils command,
833plus a ``global`` section for global options that affect every command. Each
834section consists of one option per line, specified as ``option=value``.
835
836For example, the following is a complete config file that just forces all
837commands to run quietly by default::
838
839 [global]
840 verbose=0
841
842If this is installed as the system config file, it will affect all processing of
843any Python module distribution by any user on the current system. If it is
844installed as your personal config file (on systems that support them), it will
845affect only module distributions processed by you. And if it is used as the
846:file:`setup.cfg` for a particular module distribution, it affects only that
847distribution.
848
849You could override the default "build base" directory and make the
850:command:`build\*` commands always forcibly rebuild all files with the
851following::
852
853 [build]
854 build-base=blib
855 force=1
856
857which corresponds to the command-line arguments ::
858
859 python setup.py build --build-base=blib --force
860
861except that including the :command:`build` command on the command-line means
862that command will be run. Including a particular command in config files has no
863such implication; it only means that if the command is run, the options in the
864config file will apply. (Or if other commands that derive values from it are
865run, they will use the values in the config file.)
866
867You can find out the complete list of options for any command using the
868:option:`--help` option, e.g.::
869
870 python setup.py build --help
871
872and you can find out the complete list of global options by using
873:option:`--help` without a command::
874
875 python setup.py --help
876
877See also the "Reference" section of the "Distributing Python Modules" manual.
878
879
880.. _inst-building-ext:
881
882Building Extensions: Tips and Tricks
883====================================
884
885Whenever possible, the Distutils try to use the configuration information made
886available by the Python interpreter used to run the :file:`setup.py` script.
887For example, the same compiler and linker flags used to compile Python will also
888be used for compiling extensions. Usually this will work well, but in
889complicated situations this might be inappropriate. This section discusses how
890to override the usual Distutils behaviour.
891
892
893.. _inst-tweak-flags:
894
895Tweaking compiler/linker flags
896------------------------------
897
898Compiling a Python extension written in C or C++ will sometimes require
899specifying custom flags for the compiler and linker in order to use a particular
900library or produce a special kind of object code. This is especially true if the
901extension hasn't been tested on your platform, or if you're trying to
902cross-compile Python.
903
904In the most general case, the extension author might have foreseen that
905compiling the extensions would be complicated, and provided a :file:`Setup` file
906for you to edit. This will likely only be done if the module distribution
907contains many separate extension modules, or if they often require elaborate
908sets of compiler flags in order to work.
909
910A :file:`Setup` file, if present, is parsed in order to get a list of extensions
911to build. Each line in a :file:`Setup` describes a single module. Lines have
912the following structure::
913
914 module ... [sourcefile ...] [cpparg ...] [library ...]
915
916
917Let's examine each of the fields in turn.
918
919* *module* is the name of the extension module to be built, and should be a
920 valid Python identifier. You can't just change this in order to rename a module
921 (edits to the source code would also be needed), so this should be left alone.
922
923* *sourcefile* is anything that's likely to be a source code file, at least
924 judging by the filename. Filenames ending in :file:`.c` are assumed to be
925 written in C, filenames ending in :file:`.C`, :file:`.cc`, and :file:`.c++` are
926 assumed to be C++, and filenames ending in :file:`.m` or :file:`.mm` are assumed
927 to be in Objective C.
928
929* *cpparg* is an argument for the C preprocessor, and is anything starting with
930 :option:`-I`, :option:`-D`, :option:`-U` or :option:`-C`.
931
932* *library* is anything ending in :file:`.a` or beginning with :option:`-l` or
933 :option:`-L`.
934
935If a particular platform requires a special library on your platform, you can
936add it by editing the :file:`Setup` file and running ``python setup.py build``.
937For example, if the module defined by the line ::
938
939 foo foomodule.c
940
941must be linked with the math library :file:`libm.a` on your platform, simply add
942:option:`-lm` to the line::
943
944 foo foomodule.c -lm
945
946Arbitrary switches intended for the compiler or the linker can be supplied with
947the :option:`-Xcompiler` *arg* and :option:`-Xlinker` *arg* options::
948
949 foo foomodule.c -Xcompiler -o32 -Xlinker -shared -lm
950
951The next option after :option:`-Xcompiler` and :option:`-Xlinker` will be
952appended to the proper command line, so in the above example the compiler will
953be passed the :option:`-o32` option, and the linker will be passed
954:option:`-shared`. If a compiler option requires an argument, you'll have to
955supply multiple :option:`-Xcompiler` options; for example, to pass ``-x c++``
956the :file:`Setup` file would have to contain ``-Xcompiler -x -Xcompiler c++``.
957
958Compiler flags can also be supplied through setting the :envvar:`CFLAGS`
959environment variable. If set, the contents of :envvar:`CFLAGS` will be added to
960the compiler flags specified in the :file:`Setup` file.
961
962
963.. _inst-non-ms-compilers:
964
965Using non-Microsoft compilers on Windows
966----------------------------------------
967
968.. sectionauthor:: Rene Liebscher <R.Liebscher@gmx.de>
969
970
971
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000972Borland/CodeGear C++
973^^^^^^^^^^^^^^^^^^^^
Georg Brandl116aa622007-08-15 14:28:22 +0000974
Christian Heimesdd15f6c2008-03-16 00:07:10 +0000975This subsection describes the necessary steps to use Distutils with the Borland
Georg Brandl116aa622007-08-15 14:28:22 +0000976C++ compiler version 5.5. First you have to know that Borland's object file
977format (OMF) is different from the format used by the Python version you can
978download from the Python or ActiveState Web site. (Python is built with
979Microsoft Visual C++, which uses COFF as the object file format.) For this
980reason you have to convert Python's library :file:`python25.lib` into the
981Borland format. You can do this as follows:
982
Christian Heimes5b5e81c2007-12-31 16:14:33 +0000983.. Should we mention that users have to create cfg-files for the compiler?
984.. see also http://community.borland.com/article/0,1410,21205,00.html
Georg Brandl116aa622007-08-15 14:28:22 +0000985
986::
987
988 coff2omf python25.lib python25_bcpp.lib
989
990The :file:`coff2omf` program comes with the Borland compiler. The file
991:file:`python25.lib` is in the :file:`Libs` directory of your Python
992installation. If your extension uses other libraries (zlib, ...) you have to
993convert them too.
994
995The converted files have to reside in the same directories as the normal
996libraries.
997
998How does Distutils manage to use these libraries with their changed names? If
999the extension needs a library (eg. :file:`foo`) Distutils checks first if it
1000finds a library with suffix :file:`_bcpp` (eg. :file:`foo_bcpp.lib`) and then
1001uses this library. In the case it doesn't find such a special library it uses
1002the default name (:file:`foo.lib`.) [#]_
1003
1004To let Distutils compile your extension with Borland C++ you now have to type::
1005
1006 python setup.py build --compiler=bcpp
1007
1008If you want to use the Borland C++ compiler as the default, you could specify
1009this in your personal or system-wide configuration file for Distutils (see
1010section :ref:`inst-config-files`.)
1011
1012
1013.. seealso::
1014
Georg Brandl525d3552014-10-29 10:26:56 +01001015 `C++Builder Compiler <http://www.embarcadero.com/downloads>`_
Georg Brandl116aa622007-08-15 14:28:22 +00001016 Information about the free C++ compiler from Borland, including links to the
1017 download pages.
1018
1019 `Creating Python Extensions Using Borland's Free Compiler <http://www.cyberus.ca/~g_will/pyExtenDL.shtml>`_
1020 Document describing how to use Borland's free command-line C++ compiler to build
1021 Python.
1022
1023
1024GNU C / Cygwin / MinGW
1025^^^^^^^^^^^^^^^^^^^^^^
1026
Georg Brandl116aa622007-08-15 14:28:22 +00001027This section describes the necessary steps to use Distutils with the GNU C/C++
1028compilers in their Cygwin and MinGW distributions. [#]_ For a Python interpreter
1029that was built with Cygwin, everything should work without any of these
1030following steps.
1031
Éric Araujo2d6bb122010-12-15 22:06:35 +00001032Not all extensions can be built with MinGW or Cygwin, but many can. Extensions
1033most likely to not work are those that use C++ or depend on Microsoft Visual C
1034extensions.
1035
1036To let Distutils compile your extension with Cygwin you have to type::
1037
1038 python setup.py build --compiler=cygwin
1039
1040and for Cygwin in no-cygwin mode [#]_ or for MinGW type::
1041
1042 python setup.py build --compiler=mingw32
1043
1044If you want to use any of these options/compilers as default, you should
1045consider writing it in your personal or system-wide configuration file for
1046Distutils (see section :ref:`inst-config-files`.)
1047
1048Older Versions of Python and MinGW
1049""""""""""""""""""""""""""""""""""
1050The following instructions only apply if you're using a version of Python
1051inferior to 2.4.1 with a MinGW inferior to 3.0.0 (with
1052binutils-2.13.90-20030111-1).
1053
1054These compilers require some special libraries. This task is more complex than
Georg Brandl116aa622007-08-15 14:28:22 +00001055for Borland's C++, because there is no program to convert the library. First
1056you have to create a list of symbols which the Python DLL exports. (You can find
Georg Brandl495f7b52009-10-27 15:28:25 +00001057a good program for this task at
Georg Brandl1cef2642013-10-06 13:20:49 +02001058http://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/).
Georg Brandl116aa622007-08-15 14:28:22 +00001059
Christian Heimes5b5e81c2007-12-31 16:14:33 +00001060.. I don't understand what the next line means. --amk
1061.. (inclusive the references on data structures.)
Georg Brandl116aa622007-08-15 14:28:22 +00001062
1063::
1064
1065 pexports python25.dll >python25.def
1066
1067The location of an installed :file:`python25.dll` will depend on the
1068installation options and the version and language of Windows. In a "just for
1069me" installation, it will appear in the root of the installation directory. In
1070a shared installation, it will be located in the system directory.
1071
1072Then you can create from these information an import library for gcc. ::
1073
1074 /cygwin/bin/dlltool --dllname python25.dll --def python25.def --output-lib libpython25.a
1075
1076The resulting library has to be placed in the same directory as
1077:file:`python25.lib`. (Should be the :file:`libs` directory under your Python
1078installation directory.)
1079
1080If your extension uses other libraries (zlib,...) you might have to convert
1081them too. The converted files have to reside in the same directories as the
1082normal libraries do.
1083
Georg Brandl116aa622007-08-15 14:28:22 +00001084
1085.. seealso::
1086
Georg Brandl525d3552014-10-29 10:26:56 +01001087 `Building Python modules on MS Windows platform with MinGW <http://old.zope.org/Members/als/tips/win32_mingw_modules>`_
Georg Brandl116aa622007-08-15 14:28:22 +00001088 Information about building the required libraries for the MinGW environment.
1089
Georg Brandl116aa622007-08-15 14:28:22 +00001090
1091.. rubric:: Footnotes
1092
1093.. [#] This also means you could replace all existing COFF-libraries with OMF-libraries
1094 of the same name.
1095
Georg Brandl525d3552014-10-29 10:26:56 +01001096.. [#] Check http://www.sourceware.org/cygwin/ and http://www.mingw.org/ for more
Georg Brandl116aa622007-08-15 14:28:22 +00001097 information
1098
1099.. [#] Then you have no POSIX emulation available, but you also don't need
1100 :file:`cygwin1.dll`.