2000-11-22 14:17:36 -05:00
|
|
|
PEP: 229
|
|
|
|
Title: Using Distutils to Build Python
|
|
|
|
Version: $Revision$
|
2006-03-23 15:13:19 -05:00
|
|
|
Last-Modified: $Date$
|
2002-10-30 20:35:08 -05:00
|
|
|
Author: A.M. Kuchling <amk@amk.ca>
|
2001-10-25 18:03:18 -04:00
|
|
|
Status: Final
|
2007-04-14 22:10:27 -04:00
|
|
|
Type: Standards Track
|
2017-01-10 01:52:57 -05:00
|
|
|
Content-Type: text/x-rst
|
2000-11-22 14:17:36 -05:00
|
|
|
Created: 16-Nov-2000
|
2022-08-24 18:40:18 -04:00
|
|
|
Python-Version: 2.1
|
2000-11-22 14:17:36 -05:00
|
|
|
Post-History:
|
|
|
|
|
|
|
|
|
|
|
|
Introduction
|
2017-01-10 01:52:57 -05:00
|
|
|
============
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-04-05 12:14:26 -04:00
|
|
|
The ``Modules/Setup`` mechanism has some flaws:
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-04-05 12:14:26 -04:00
|
|
|
* People have to remember to uncomment bits of ``Modules/Setup`` in
|
2017-01-10 01:52:57 -05:00
|
|
|
order to get all the possible modules.
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-04-05 12:14:26 -04:00
|
|
|
* Moving ``Setup`` to a new version of Python is tedious; new modules
|
2017-01-10 01:52:57 -05:00
|
|
|
have been added, so you can't just copy the older version, but
|
|
|
|
have to reconcile the two versions.
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
* Users have to figure out where the needed libraries, such as
|
|
|
|
``zlib``, are installed.
|
2000-11-22 14:17:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
Proposal
|
2017-01-10 01:52:57 -05:00
|
|
|
========
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
Use the Distutils to build the modules that come with Python.
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
The changes can be broken up into several pieces:
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
1. The Distutils needs some Python modules to be able to build
|
2017-04-05 12:14:26 -04:00
|
|
|
modules. Currently I believe the minimal list is ``posix``, ``_sre``,
|
|
|
|
and ``string``.
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
These modules will have to be built before the Distutils can be
|
2017-04-05 12:14:26 -04:00
|
|
|
used, so they'll simply be hardwired into ``Modules/Makefile`` and
|
2017-01-10 01:52:57 -05:00
|
|
|
be automatically built.
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
2. A top-level setup.py script will be written that checks the
|
|
|
|
libraries installed on the system and compiles as many modules
|
|
|
|
as possible.
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-04-05 12:14:26 -04:00
|
|
|
3. ``Modules/Setup`` will be kept and settings in it will override
|
|
|
|
``setup.py``'s usual behavior, so you can disable a module known
|
2017-01-10 01:52:57 -05:00
|
|
|
to be buggy, or specify particular compilation or linker flags.
|
2017-04-05 12:14:26 -04:00
|
|
|
However, in the common case where ``setup.py`` works correctly,
|
|
|
|
everything in ``Setup`` will remain commented out. The other
|
|
|
|
``Setup.*`` become unnecessary, since nothing will be generating
|
|
|
|
``Setup`` automatically.
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
The patch was checked in for Python 2.1, and has been subsequently
|
|
|
|
modified.
|
2001-10-25 16:58:17 -04:00
|
|
|
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2000-12-01 18:50:46 -05:00
|
|
|
Implementation
|
2017-01-10 01:52:57 -05:00
|
|
|
==============
|
2000-12-01 18:50:46 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
Patch #102588 on SourceForge contains the proposed patch.
|
|
|
|
Currently the patch tries to be conservative and to change as few
|
|
|
|
files as possible, in order to simplify backing out the patch.
|
|
|
|
For example, no attempt is made to rip out the existing build
|
|
|
|
mechanisms. Such simplifications can wait for later in the beta
|
|
|
|
cycle, when we're certain the patch will be left in, or they can
|
|
|
|
wait for Python 2.2.
|
2001-01-16 22:45:35 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
The patch makes the following changes:
|
2001-01-16 22:45:35 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
* Makes some required changes to distutils/sysconfig (these will
|
|
|
|
be checked in separately)
|
2001-01-16 22:45:35 -05:00
|
|
|
|
2017-04-05 12:14:26 -04:00
|
|
|
* In the top-level ``Makefile.in``, the "sharedmods" target simply
|
|
|
|
runs ``"./python setup.py build"``, and "sharedinstall" runs
|
|
|
|
``"./python setup.py install"``. The "clobber" target also deletes
|
|
|
|
the ``build/`` subdirectory where Distutils puts its output.
|
2001-01-16 22:45:35 -05:00
|
|
|
|
2017-04-05 12:14:26 -04:00
|
|
|
* ``Modules/Setup.config.in`` only contains entries for the ``gc`` and ``thread``
|
|
|
|
modules; the ``readline``, ``curses``, and ``db`` modules are removed because
|
|
|
|
it's now ``setup.py``'s job to handle them.
|
2001-01-16 22:45:35 -05:00
|
|
|
|
2017-04-05 12:14:26 -04:00
|
|
|
* ``Modules/Setup.dist`` now contains entries for only 3 modules --
|
|
|
|
``_sre``, ``posix``, and ``strop``.
|
2001-01-16 22:45:35 -05:00
|
|
|
|
2017-04-05 12:14:26 -04:00
|
|
|
* The ``configure`` script builds ``setup.cfg`` from ``setup.cfg.in``. This
|
2017-01-10 01:52:57 -05:00
|
|
|
is needed for two reasons: to make building in subdirectories
|
|
|
|
work, and to get the configured installation prefix.
|
|
|
|
|
2017-04-05 12:14:26 -04:00
|
|
|
* Adds ``setup.py`` to the top directory of the source tree. ``setup.py``
|
2017-01-10 01:52:57 -05:00
|
|
|
is the largest piece of the puzzle, though not the most
|
2017-04-05 12:14:26 -04:00
|
|
|
complicated. ``setup.py`` contains a subclass of the ``BuildExt``
|
|
|
|
class, and extends it with a ``detect_modules()`` method that does
|
2017-01-10 01:52:57 -05:00
|
|
|
the work of figuring out when modules can be compiled, and adding
|
|
|
|
them to the 'exts' list.
|
2000-12-01 18:50:46 -05:00
|
|
|
|
|
|
|
|
2000-11-22 14:17:36 -05:00
|
|
|
Unresolved Issues
|
2017-01-10 01:52:57 -05:00
|
|
|
=================
|
|
|
|
|
|
|
|
Do we need to make it possible to disable the 3 hard-wired modules
|
|
|
|
without manually hacking the Makefiles? [Answer: No.]
|
2000-11-22 14:17:36 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
The Distutils always compile modules as shared libraries. How do
|
|
|
|
we support compiling them statically into the resulting Python
|
|
|
|
binary?
|
2000-12-01 18:50:46 -05:00
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
[Answer: building a Python binary with the Distutils should be
|
|
|
|
feasible, though no one has implemented it yet. This should be
|
|
|
|
done someday, but isn't a pressing priority as messing around with
|
2017-04-05 12:14:26 -04:00
|
|
|
the top-level ``Makefile.pre.in`` is good enough.]
|
2000-11-22 14:17:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
Copyright
|
2017-01-10 01:52:57 -05:00
|
|
|
=========
|
|
|
|
|
|
|
|
This document has been placed in the public domain.
|
2000-11-22 14:17:36 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-10 01:52:57 -05:00
|
|
|
..
|
|
|
|
Local Variables:
|
|
|
|
mode: indented-text
|
|
|
|
indent-tabs-mode: nil
|
|
|
|
End:
|