2009-02-21 21:33:52 -05:00
|
|
|
|
PEP: 376
|
|
|
|
|
Title: Changing the .egg-info structure
|
2009-02-22 17:42:22 -05:00
|
|
|
|
Version: $Revision$
|
|
|
|
|
Last-Modified: $Date$
|
2009-02-21 21:33:52 -05:00
|
|
|
|
Author: Tarek Ziadé <tarek@ziade.org>
|
|
|
|
|
Status: Draft
|
|
|
|
|
Type: Standards Track
|
|
|
|
|
Content-Type: text/x-rst
|
|
|
|
|
Created: 22-Feb-2009
|
2009-05-14 18:03:08 -04:00
|
|
|
|
Python-Version: 2.7, 3.2
|
2009-02-21 21:33:52 -05:00
|
|
|
|
Post-History:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Abstract
|
|
|
|
|
========
|
|
|
|
|
|
|
|
|
|
This PEP proposes various enhancements for Distutils:
|
|
|
|
|
|
2009-02-22 17:42:22 -05:00
|
|
|
|
- A new format for the .egg-info structure.
|
2009-06-22 09:06:55 -04:00
|
|
|
|
- Some APIs to read the meta-data of a distribution
|
2009-06-21 11:48:04 -04:00
|
|
|
|
- A replacement PEP 262
|
2009-05-25 06:22:46 -04:00
|
|
|
|
- An uninstall feature
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-04-24 12:03:02 -04:00
|
|
|
|
Definitions
|
|
|
|
|
===========
|
2009-02-28 09:22:01 -05:00
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
A **distribution** is a collection of files, which can be Python modules,
|
|
|
|
|
extensions or data. A distribution is managed by a special module called
|
2009-06-22 09:06:55 -04:00
|
|
|
|
`setup.py` which contains a call to the `distutils.core.setup` function.
|
2009-06-23 04:50:10 -04:00
|
|
|
|
The arguments passed to that function describe the distribution, like
|
2009-06-22 09:06:55 -04:00
|
|
|
|
its `name`, its `version`, and so on.
|
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
Disutils provides among other things **commands** that can be called
|
|
|
|
|
through the shell using the `setup.py` script. A `sdist` command is provided
|
2009-06-23 08:14:02 -04:00
|
|
|
|
for instance to create a source distribution archive. An `install` command
|
|
|
|
|
is also provided to perform an installation of the distribution in the Python
|
2009-06-22 09:06:55 -04:00
|
|
|
|
installation the script is invoked with::
|
|
|
|
|
|
|
|
|
|
$ python setup.py install
|
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
See the Distutils [#distutils]_ documentation for more information.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-16 12:02:06 -04:00
|
|
|
|
Once installed, the elements are located in various places in the system, like:
|
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
- in Python's site-packages (Python modules, Python modules organized into
|
2009-06-22 09:06:55 -04:00
|
|
|
|
packages, Extensions, etc.)
|
2009-05-16 12:02:06 -04:00
|
|
|
|
- in Python's `include` directory.
|
|
|
|
|
- in Python's `bin` or `Script` directory.
|
|
|
|
|
- etc.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-04-24 12:03:02 -04:00
|
|
|
|
Rationale
|
|
|
|
|
=========
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
There are two problems right now in the way distributions are installed in
|
2009-06-22 09:06:55 -04:00
|
|
|
|
Python:
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-16 12:02:06 -04:00
|
|
|
|
- There are too many ways to do it.
|
2009-06-22 09:06:55 -04:00
|
|
|
|
- There is no API to get the metadata of installed distributions.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-22 09:06:55 -04:00
|
|
|
|
How distributions are installed
|
|
|
|
|
-------------------------------
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-22 09:06:55 -04:00
|
|
|
|
Right now, when a distribution is installed in Python, every elements its contains
|
2009-05-25 06:22:46 -04:00
|
|
|
|
is installed in various directories.
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
|
|
|
|
The pure Python code for instance is installed in the `purelib` directory,
|
2009-06-23 08:14:02 -04:00
|
|
|
|
which is located in the Python installation in ``lib\python2.6\site-packages``
|
|
|
|
|
for example under unix-like systems or Mac OS X, and in ``Lib/site-packages``
|
2009-05-16 12:02:06 -04:00
|
|
|
|
under Windows. This is done with the Distutils `install` command, which calls
|
|
|
|
|
various subcommands.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
The `install_egg_info` subcommand is called during this process, in order to
|
2009-05-16 12:02:06 -04:00
|
|
|
|
create an `.egg-info` file in the `purelib` directory.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
For example, for the `docutils` distribution, which contains one package an
|
|
|
|
|
extra module and executable scripts, three elements will be installed in
|
2009-06-23 08:14:02 -04:00
|
|
|
|
`site-packages`:
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
- `docutils` : the ``docutils`` pakage
|
|
|
|
|
- `roman.py` : an extra module used by `docutils`
|
|
|
|
|
- `docutils-0.5-py2.6.egg-info` : a file containing the distribution metadata
|
|
|
|
|
as described in PEP 314 [#pep314]_. This file corresponds to the file
|
|
|
|
|
called `PKG-INFO`, built by the `sdist` command.
|
2009-04-24 12:03:02 -04:00
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
Some executable scripts such as `rst2html.py` will also be added in the `bin`
|
|
|
|
|
directory of the Python installation.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
The problem is that many people use `easy_install` (from the `setuptools`
|
|
|
|
|
project [#setuptools]_) or `pip` [#pip]_ to install their packages, and
|
|
|
|
|
these third-party tools do not install packages in the same way that Distutils
|
|
|
|
|
does:
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
- `easy_install` creates an `EGG-INFO` directory inside an `.egg` directory,
|
|
|
|
|
and adds a `PKG-INFO` file inside this directory. The `.egg` directory
|
2009-06-23 04:50:10 -04:00
|
|
|
|
contains in that case all the elements of the distribution that are supposed
|
2009-06-22 09:06:55 -04:00
|
|
|
|
to be installed in `site-packages`, and is placed in the `site-packages`
|
2009-05-16 12:02:06 -04:00
|
|
|
|
directory.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-16 12:02:06 -04:00
|
|
|
|
- `pip` creates an `.egg-info` directory inside the `site-packages` directory
|
2009-06-22 09:06:55 -04:00
|
|
|
|
and adds a `PKG-INFO` file inside it. Elements of the distribution are then
|
2009-05-16 12:02:06 -04:00
|
|
|
|
installed in various places like Distutils does.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
|
|
|
|
They both add other files in the `EGG-INFO` or `.egg-info` directory, and
|
2009-04-24 12:03:02 -04:00
|
|
|
|
create or modify `.pth` files.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-04-24 12:03:02 -04:00
|
|
|
|
Uninstall information
|
2009-02-21 21:33:52 -05:00
|
|
|
|
---------------------
|
|
|
|
|
|
2009-04-24 12:03:02 -04:00
|
|
|
|
Distutils doesn't provide any `uninstall` command. If you want to uninstall
|
2009-06-23 04:50:10 -04:00
|
|
|
|
a distribution, you have to be a power user and remove the various elements
|
2009-06-22 09:06:55 -04:00
|
|
|
|
that were installed. Then look over the `.pth` file to clean them if necessary.
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
|
|
|
|
And the process differs, depending on the tools you have used to install the
|
2009-06-23 04:50:10 -04:00
|
|
|
|
distribution, and if the distribution's `setup.py` uses Distutils or
|
2009-06-22 09:06:55 -04:00
|
|
|
|
Setuptools.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
Under some circumstances, you might not be able to know for sure that you
|
2009-06-22 09:06:55 -04:00
|
|
|
|
have removed everything, or that you didn't break another distribution by
|
2009-06-23 08:14:02 -04:00
|
|
|
|
removing a file that is shared among several distributions.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-22 09:06:55 -04:00
|
|
|
|
But there's common behavior: when you install a distribution, files are copied
|
2009-05-25 06:22:46 -04:00
|
|
|
|
in your system. And there's a way to keep track of theses files, so to remove
|
2009-05-16 12:02:06 -04:00
|
|
|
|
them.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
|
|
|
|
What this PEP proposes
|
|
|
|
|
----------------------
|
|
|
|
|
|
|
|
|
|
To address those issues, this PEP proposes a few changes:
|
|
|
|
|
|
2009-06-08 05:54:02 -04:00
|
|
|
|
- a new `.egg-info` structure using a directory, based on one form of
|
|
|
|
|
the `EggFormats` standard from `setuptools` [#eggformats]_.
|
2009-05-25 06:22:46 -04:00
|
|
|
|
- new APIs in `pkgutil` to be able to query the information of installed
|
2009-06-22 09:06:55 -04:00
|
|
|
|
distributions.
|
2009-05-25 06:22:46 -04:00
|
|
|
|
- a de-facto replacement for PEP 262
|
|
|
|
|
- an uninstall function in Distutils.
|
|
|
|
|
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
|
|
|
|
.egg-info becomes a directory
|
|
|
|
|
=============================
|
|
|
|
|
|
2009-02-28 09:22:01 -05:00
|
|
|
|
The first change would be to make `.egg-info` a directory and let it
|
2009-05-25 06:22:46 -04:00
|
|
|
|
hold the `PKG-INFO` file built by the `write_pkg_file` method of
|
2009-05-16 12:02:06 -04:00
|
|
|
|
the `Distribution` class in Distutils.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
Notice that this change is based on the standard proposed by `EggFormats`.
|
2009-06-08 05:54:02 -04:00
|
|
|
|
Although, this standard proposes two ways to install files :
|
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
- a self-contained directory that can be zipped or left unzipped and that
|
2009-06-22 09:06:55 -04:00
|
|
|
|
contains the distribution files *and* the `.egg-info` directory.
|
2009-06-08 05:54:02 -04:00
|
|
|
|
|
|
|
|
|
- a distinct `.egg-info` directory located in the site-packages directory.
|
|
|
|
|
|
|
|
|
|
You may refer to the `EggFormats` documentation for more details.
|
2009-05-25 06:22:46 -04:00
|
|
|
|
|
2009-05-16 12:02:06 -04:00
|
|
|
|
This change will not impact Python itself, because `egg-info` files are not
|
2009-05-25 06:22:46 -04:00
|
|
|
|
used anywhere yet in the standard library besides Distutils.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
Although it will impact the `setuptools` and `pip` projects, but given
|
|
|
|
|
the fact that they already work with a directory that contains a `PKG-INFO`
|
2009-05-16 12:02:06 -04:00
|
|
|
|
file, the change will have no deep consequences.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
For example, if the `docutils` package is installed, the elements that
|
2009-05-16 12:02:06 -04:00
|
|
|
|
will be installed in `site-packages` will become::
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
- docutils/
|
2009-06-23 04:50:10 -04:00
|
|
|
|
- roman.py
|
|
|
|
|
- docutils-0.5-py2.6.egg-info/
|
2009-02-21 21:33:52 -05:00
|
|
|
|
PKG-INFO
|
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
The syntax of the egg-info directory name is as follows::
|
|
|
|
|
|
|
|
|
|
name + '-' + version + '.egg-info'
|
|
|
|
|
|
|
|
|
|
The egg-info directory name is created using a new function called
|
2009-06-12 06:00:17 -04:00
|
|
|
|
``egginfo_dirname(name, version)`` added to ``pkgutil``. ``name`` is
|
2009-05-25 06:22:46 -04:00
|
|
|
|
converted to a standard distribution name any runs of non-alphanumeric
|
2009-06-04 05:36:32 -04:00
|
|
|
|
characters are replaced with a single '-'. ``version`` is converted
|
|
|
|
|
to a standard version string. Spaces become dots, and all other
|
|
|
|
|
non-alphanumeric characters become dashes, with runs of multiple dashes
|
|
|
|
|
condensed to a single dash. Both attributes are then converted into their
|
2009-05-25 06:22:46 -04:00
|
|
|
|
filename-escaped form. Any '-' characters are currently replaced with '_'.
|
|
|
|
|
|
|
|
|
|
Examples::
|
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
>>> egginfo_dirname('docutils', '0.5')
|
|
|
|
|
'docutils-0.5.egg-info'
|
2009-05-25 06:22:46 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
>>> egginfo_dirname('python-ldap', '2.5')
|
2009-05-25 06:22:46 -04:00
|
|
|
|
'python_ldap-2.5.egg-info'
|
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
>>> egginfo_dirname('python-ldap', '2.5 a---5')
|
2009-05-25 06:22:46 -04:00
|
|
|
|
'python_ldap-2.5.a_5.egg-info'
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
Adding a RECORD file in the .egg-info directory
|
|
|
|
|
===============================================
|
2009-02-28 09:22:01 -05:00
|
|
|
|
|
2009-04-24 12:03:02 -04:00
|
|
|
|
A `RECORD` file will be added inside the `.egg-info` directory at installation
|
2009-05-25 06:22:46 -04:00
|
|
|
|
time. The `RECORD` file will hold the list of installed files. These correspond
|
|
|
|
|
to the files listed by the `record` option of the `install` command, and will
|
2009-06-05 04:35:30 -04:00
|
|
|
|
be generated by default. This will allow uninstallation, as explained later in this
|
|
|
|
|
PEP. The `install` command will also provide an option to prevent the `RECORD`
|
2009-06-12 06:00:17 -04:00
|
|
|
|
file from being written and this option should be used when creating system
|
2009-06-05 04:35:30 -04:00
|
|
|
|
packages.
|
|
|
|
|
|
|
|
|
|
Third-party installation tools also should not overwrite or delete files
|
|
|
|
|
that are not in a RECORD file without prompting or warning.
|
|
|
|
|
|
|
|
|
|
This RECORD file is inspired from PEP 262 FILES [#pep262]_.
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
|
|
|
|
The RECORD format
|
|
|
|
|
-----------------
|
|
|
|
|
|
2009-06-08 05:54:02 -04:00
|
|
|
|
The `RECORD` file is a CSV file, composed of records, one line per
|
|
|
|
|
installed file. The ``csv`` module is used to read the file, with
|
|
|
|
|
the `excel` dialect, which uses these options to read the file:
|
|
|
|
|
|
|
|
|
|
- field delimiter : `,`
|
|
|
|
|
- quoting char : `"`.
|
2009-06-23 08:14:02 -04:00
|
|
|
|
- line terminator : ``os.linesep`` (so ``\r\n`` or ``\r``)
|
2009-06-08 05:54:02 -04:00
|
|
|
|
|
|
|
|
|
Each record is composed of three elements.
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
|
|
|
|
- the file's full **path**
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
- if the installed file is located in the directory where the `.egg-info`
|
2009-05-25 06:22:46 -04:00
|
|
|
|
directory of the package is located, it will be a '/'-separated relative
|
|
|
|
|
path, no matter what is the target system. This makes this information
|
2009-05-19 08:43:34 -04:00
|
|
|
|
cross-compatible and allows simple installation to be relocatable.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
- if the installed file is located elsewhere in the system, a
|
2009-05-16 12:02:06 -04:00
|
|
|
|
'/'-separated absolute path is used.
|
2009-04-24 12:03:02 -04:00
|
|
|
|
|
2009-05-16 12:02:06 -04:00
|
|
|
|
- the **MD5** hash of the file, encoded in hex. Notice that `pyc` and `pyo`
|
2009-06-23 04:50:10 -04:00
|
|
|
|
generated files will not have a hash because they are automatically produced
|
|
|
|
|
from `py` files. So checking the hash of the corresponding `py` file is
|
|
|
|
|
enough to decide if the file and its associated `pyc` or `pyo` files have
|
|
|
|
|
changed.
|
2009-04-24 12:03:02 -04:00
|
|
|
|
|
2009-05-16 12:02:06 -04:00
|
|
|
|
- the file's size in bytes
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
The ``csv`` module with its default options will be used to generate this file,
|
|
|
|
|
so the field separator will be ",". Any "," characters found within a field
|
|
|
|
|
will be escaped automatically by ``csv``.
|
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
When the file is read, the `U` option will be used so the universal newline
|
2009-06-23 08:14:02 -04:00
|
|
|
|
support (see PEP 278 [#pep278]_) will be activated, avoiding any trouble
|
2009-06-23 04:50:10 -04:00
|
|
|
|
reading a file produced on a platform that uses a different new line
|
|
|
|
|
terminator.
|
|
|
|
|
|
2009-05-16 12:02:06 -04:00
|
|
|
|
Example
|
|
|
|
|
-------
|
2009-04-24 12:03:02 -04:00
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
Back to our `docutils` example, we will have::
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
- docutils/
|
|
|
|
|
- roman.py
|
|
|
|
|
- docutils-0.5-py2.6.egg-info/
|
2009-02-21 21:33:52 -05:00
|
|
|
|
PKG-INFO
|
|
|
|
|
RECORD
|
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
And the RECORD file will contain (extract)::
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
docutils/__init__.py,b690274f621402dda63bf11ba5373bf2,9544
|
|
|
|
|
docutils/core.py,9c4b84aff68aa55f2e9bf70481b94333,66188
|
|
|
|
|
roman.py,a4b84aff68aa55f2e9bf70481b943D3,234
|
|
|
|
|
/usr/local/bin/rst2html.py,a4b84aff68aa55f2e9bf70481b943D3,234
|
|
|
|
|
docutils-0.5-py2.6.egg-info/PKG-INFO,6fe57de576d749536082d8e205b77748,195
|
|
|
|
|
docutils-0.5-py2.6.egg-info/RECORD
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
|
|
|
|
Notice that:
|
|
|
|
|
|
|
|
|
|
- the `RECORD` file can't contain a hash of itself and is just mentioned here
|
2009-06-23 08:14:02 -04:00
|
|
|
|
- `docutils` and `docutils-0.5-py2.6.egg-info` are located in `site-packages` so the file
|
2009-05-16 12:02:06 -04:00
|
|
|
|
paths are relative to it.
|
|
|
|
|
|
2009-06-05 04:35:30 -04:00
|
|
|
|
Adding an INSTALLER file in the .egg-info directory
|
|
|
|
|
===================================================
|
|
|
|
|
|
|
|
|
|
The `install` command will have a new option called `installer`. This option
|
|
|
|
|
is the name of the tool used to invoke the installation. It's an normalized
|
2009-06-12 06:00:17 -04:00
|
|
|
|
lower-case string matching `[a-z0-9_\-\.]`.
|
2009-06-05 04:35:30 -04:00
|
|
|
|
|
|
|
|
|
$ python setup.py install --installer=pkg-system
|
|
|
|
|
|
|
|
|
|
It will default to `distutils` if not provided.
|
|
|
|
|
|
2009-06-22 09:06:55 -04:00
|
|
|
|
When a distribution is installed, the INSTALLER file is generated in the
|
2009-06-12 06:00:17 -04:00
|
|
|
|
`.egg-info` directory with this value, to keep track of **who** installed the
|
2009-06-22 09:06:55 -04:00
|
|
|
|
distribution. The file is a single-line text file.
|
2009-06-05 04:35:30 -04:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
New APIs in pkgutil
|
|
|
|
|
===================
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
To use the `.egg-info` directory content, we need to add in the standard
|
2009-04-13 16:52:58 -04:00
|
|
|
|
library a set of APIs. The best place to put these APIs seems to be `pkgutil`.
|
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
The API is organized in five classes that work with directories and Zip files
|
|
|
|
|
(so its works with files included in Zip files, see PEP 273 for more details
|
2009-06-23 08:14:02 -04:00
|
|
|
|
[#pep273]_.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
- ``Distribution``: manages an `.egg-info` directory.
|
2009-06-21 11:48:04 -04:00
|
|
|
|
- ``ZippedDistribution``: manages an `.egg-info` directory contained in a zip
|
|
|
|
|
file.
|
2009-06-24 15:50:58 -04:00
|
|
|
|
- ``DistributionDir``: manages a directory that contains some `.egg-info`
|
2009-06-04 05:36:32 -04:00
|
|
|
|
directories.
|
2009-06-24 15:50:58 -04:00
|
|
|
|
- ``ZippedDistributionDir``: manages a zipped directory that contains
|
2009-06-21 11:48:04 -04:00
|
|
|
|
some `.egg.info` directory.
|
2009-06-24 15:50:58 -04:00
|
|
|
|
- ``DistributionDirMap``: manages ``DistributionDir`` instances.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
Distribution class
|
|
|
|
|
------------------
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
A new class called ``Distribution`` is created with a the path of the
|
|
|
|
|
`.egg-info` directory provided to the contructor. It reads the metadata
|
|
|
|
|
contained in `PKG-INFO` when it is instanciated.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
``Distribution(path)`` -> instance
|
|
|
|
|
|
|
|
|
|
Creates a ``Distribution`` instance for the given ``path``.
|
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
``Distribution`` provides the following attributes:
|
2009-05-19 08:43:34 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
- ``name``: The name of the distribution.
|
2009-05-25 06:22:46 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
- ``metadata``: A ``DistributionMetadata`` instance loaded with the
|
|
|
|
|
distribution's PKG-INFO file.
|
2009-05-25 06:22:46 -04:00
|
|
|
|
|
2009-06-04 05:36:32 -04:00
|
|
|
|
And following methods:
|
2009-05-25 06:22:46 -04:00
|
|
|
|
|
|
|
|
|
- ``get_installed_files(local=False)`` -> iterator of (path, md5, size)
|
|
|
|
|
|
2009-06-04 05:36:32 -04:00
|
|
|
|
Iterates over the `RECORD` entries and return a tuple ``(path, md5, size)``
|
|
|
|
|
for each line. If ``local`` is ``True``, the path is transformed into a
|
2009-05-25 06:22:46 -04:00
|
|
|
|
local absolute path. Otherwise the raw value from `RECORD` is returned.
|
|
|
|
|
|
|
|
|
|
- ``uses(path)`` -> Boolean
|
|
|
|
|
|
|
|
|
|
Returns ``True`` if ``path`` is listed in `RECORD`. ``path``
|
|
|
|
|
can be a local absolute path or a relative '/'-separated path.
|
2009-05-19 08:43:34 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
- ``get_egginfo_file(path, binary=False)`` -> file object
|
2009-06-08 05:54:02 -04:00
|
|
|
|
|
|
|
|
|
Returns a file located under the `.egg-info` directory.
|
|
|
|
|
|
|
|
|
|
Returns a ``file`` instance for the file pointed by ``path``.
|
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
``path`` has to be a '/'-separated path relative to the `.egg-info`
|
2009-06-08 05:54:02 -04:00
|
|
|
|
directory or an absolute path.
|
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
If ``path`` is an absolute path and doesn't start with the `.egg-info`
|
2009-06-08 05:54:02 -04:00
|
|
|
|
directory path, a ``DistutilsError`` is raised.
|
|
|
|
|
|
2009-06-23 04:55:56 -04:00
|
|
|
|
If ``binary`` is ``True``, opens the file in read-only binary mode (`rb`),
|
|
|
|
|
otherwise opens it in read-only mode (`r`).
|
2009-06-08 05:54:02 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
- ``get_egginfo_files(local=False)`` -> iterator of paths
|
2009-06-08 05:54:02 -04:00
|
|
|
|
|
|
|
|
|
Iterates over the `RECORD` entries and return paths for each line if the path
|
|
|
|
|
is pointing a file located in the `.egg-info` directory or one of its
|
|
|
|
|
subdirectory.
|
|
|
|
|
|
|
|
|
|
If ``local`` is ``True``, each path is transformed into a
|
|
|
|
|
local absolute path. Otherwise the raw value from `RECORD` is returned.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-21 11:48:04 -04:00
|
|
|
|
ZippedDistribution class
|
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
|
|
A ``ZippedDistribution`` class is provided. It overrides the ``Distribution``
|
|
|
|
|
class so its methods work with an `.egg.info` directory located in a zip file.
|
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
``ZippedDistribution(zipfile, path)`` -> instance
|
|
|
|
|
|
|
|
|
|
Creates a ``ZippedDistribution`` instance for the given relative ``path``
|
|
|
|
|
located in the ``zipfile`` file.
|
|
|
|
|
|
|
|
|
|
Other public methods and attributes are similar to ``Distribution``.
|
2009-05-14 17:52:58 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
DistributionDir class
|
2009-06-12 06:00:17 -04:00
|
|
|
|
---------------------------
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
A new class called ``DistributionDir`` is created with a path
|
2009-06-12 06:00:17 -04:00
|
|
|
|
corresponding to a directory. For each `.egg-info` directory founded in
|
|
|
|
|
`path`, the class creates a corresponding ``Distribution``.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
The class is a ``set`` of ``Distribution`` instances. ``DistributionDir``
|
2009-06-12 06:00:17 -04:00
|
|
|
|
provides a ``path`` attribute corresponding to the path is was created with.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
``DistributionDir(path)`` -> instance
|
2009-06-23 08:14:02 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
Creates a ``DistributionDir`` instance for the given ``path``.
|
2009-06-23 08:14:02 -04:00
|
|
|
|
|
|
|
|
|
It also provides one extra method besides the ones from ``set``:
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
- ``get_file_users(path)`` -> Iterator of ``Distribution``.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
Returns all ``Distribution`` which uses ``path``, by calling
|
|
|
|
|
``Distribution.uses(path)`` on all ``Distribution`` instances.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
ZippedDistributionDir class
|
2009-06-21 11:48:04 -04:00
|
|
|
|
---------------------------------
|
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
A ``ZippedDistributionDir`` is provided. It overrides the
|
|
|
|
|
``DistributionDir`` class so its methods work with a Zip file.
|
2009-06-21 11:48:04 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
``ZippedDistributionDir(path)`` -> instance
|
2009-06-23 08:14:02 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
Creates a ``ZippedDistributionDir`` instance for the given ``path``.
|
2009-06-23 08:14:02 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
Other public methods and attributes are similar to ``DistributionDir``.
|
2009-06-23 08:14:02 -04:00
|
|
|
|
|
2009-06-21 11:48:04 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
DistributionDirMap class
|
2009-06-12 06:00:17 -04:00
|
|
|
|
-----------------------------
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
A new class called ``DistributionDirMap`` is created. It's a collection of
|
|
|
|
|
``DistributionDir`` and ``ZippedDistributionDir`` instances.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
``DistributionDirMap(paths=None, use_cache=True)`` -> instance
|
2009-06-23 08:14:02 -04:00
|
|
|
|
|
|
|
|
|
If ``paths`` is not not, it's a sequence of paths the constructor loads
|
|
|
|
|
in the instance.
|
|
|
|
|
|
|
|
|
|
The constructor also takes an optional ``use_cache`` argument.
|
2009-06-24 15:50:58 -04:00
|
|
|
|
When it's ``True``, ``DistributionDirMap`` will use a global
|
2009-06-23 08:14:02 -04:00
|
|
|
|
cache to reduce the numbers of I/O accesses and speed up the lookups.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
The cache is a global mapping containing ``DistributionDir`` and
|
|
|
|
|
``ZippedDistributionDir`` instances. When a
|
|
|
|
|
``DistributionDirMap`` object is created, it will use the cache to
|
2009-06-23 08:14:02 -04:00
|
|
|
|
add an entry for each path it visits, or reuse existing entries. The
|
|
|
|
|
cache usage can be disabled at any time with the ``use_cache`` attribute.
|
|
|
|
|
|
|
|
|
|
The cache can also be emptied with the global ``purge_cache`` function.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
The class is a ``dict`` where the values are ``DistributionDir``
|
|
|
|
|
and ``ZippedDistributionDir`` instances and the keys are their path
|
2009-06-21 11:48:04 -04:00
|
|
|
|
attributes.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
``DistributionDirMap`` also provides the following methods besides the ones
|
2009-06-23 08:14:02 -04:00
|
|
|
|
from ``dict``:
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
- ``load(*paths)``
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
Creates and adds ``DistributionDir`` (or
|
|
|
|
|
``ZippedDistributionDir``) instances corresponding to ``paths``.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
|
|
|
|
- ``reload()``
|
|
|
|
|
|
|
|
|
|
Reloads existing entries.
|
|
|
|
|
|
2009-06-21 11:48:04 -04:00
|
|
|
|
- ``get_distributions()`` -> Iterator of ``Distribution`` (or
|
|
|
|
|
``ZippedDistribution``) instances.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-21 11:48:04 -04:00
|
|
|
|
Iterates over all ``Distribution`` and ``ZippedDistribution`` contained
|
2009-06-24 15:50:58 -04:00
|
|
|
|
in ``DistributionDir`` and ``ZippedDistributionDir`` instances.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-22 09:06:55 -04:00
|
|
|
|
- ``get_distribution(dist_name)`` -> ``Distribution`` (or
|
2009-06-21 11:48:04 -04:00
|
|
|
|
``ZippedDistribution``) or None.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-21 11:48:04 -04:00
|
|
|
|
Returns a ``Distribution`` (or ``ZippedDistribution``) instance for the
|
2009-06-22 09:06:55 -04:00
|
|
|
|
given distribution name. If not found, returns None.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-21 11:48:04 -04:00
|
|
|
|
- ``get_file_users(path)`` -> Iterator of ``Distribution`` (or
|
|
|
|
|
``ZippedDistribution``) instances.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-06-22 09:06:55 -04:00
|
|
|
|
Iterates over all distributions to find out which distributions use the file.
|
2009-06-21 11:48:04 -04:00
|
|
|
|
Returns ``Distribution`` (or ``ZippedDistribution``) instances.
|
2009-06-04 05:36:32 -04:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
.egg-info functions
|
|
|
|
|
-------------------
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
The new functions added in the ``pkgutil`` are :
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-21 11:48:04 -04:00
|
|
|
|
- ``get_distributions()`` -> iterator of ``Distribution`` (or
|
|
|
|
|
``ZippedDistribution``) instance.
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
Provides an iterator that looks for ``.egg-info`` directories in ``sys.path``
|
2009-06-21 11:48:04 -04:00
|
|
|
|
and returns ``Distribution`` (or ``ZippedDistribution``) instances for
|
|
|
|
|
each one of them.
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
2009-06-21 11:48:04 -04:00
|
|
|
|
- ``get_distribution(name)`` -> ``Distribution`` (or ``ZippedDistribution``)
|
|
|
|
|
or None.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
Scans all elements in ``sys.path`` and looks for all directories ending with
|
2009-06-21 11:48:04 -04:00
|
|
|
|
``.egg-info``. Returns a ``Distribution`` (or ``ZippedDistribution``)
|
|
|
|
|
corresponding to the ``.egg-info`` directory that contains a PKG-INFO that
|
|
|
|
|
matches `name` for the `name` metadata.
|
2009-05-19 08:43:34 -04:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
Notice that there should be at most one result. The first result founded
|
|
|
|
|
will be returned. If the directory is not found, returns None.
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
2009-06-21 11:48:04 -04:00
|
|
|
|
- ``get_file_users(path)`` -> iterator of ``Distribution`` (or
|
|
|
|
|
``ZippedDistribution``) instances.
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
2009-06-22 09:06:55 -04:00
|
|
|
|
Iterates over all distributions to find out which distributions uses ``path``.
|
2009-05-25 06:22:46 -04:00
|
|
|
|
``path`` can be a local absolute path or a relative '/'-separated path.
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
2009-06-24 15:50:58 -04:00
|
|
|
|
All these functions use the same global instance of ``DistributionDirMap``
|
2009-06-21 11:48:04 -04:00
|
|
|
|
to use the cache. Notice that the cache is never emptied explicitely.
|
2009-05-25 06:22:46 -04:00
|
|
|
|
|
|
|
|
|
Example
|
|
|
|
|
-------
|
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
Let's use some of the new APIs with our `docutils` example::
|
2009-05-25 06:22:46 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
>>> from pkgutil import get_distribution, get_file_users
|
2009-06-23 08:14:02 -04:00
|
|
|
|
>>> dist = get_distribution('docutils')
|
2009-06-12 06:00:17 -04:00
|
|
|
|
>>> dist.name
|
2009-06-23 08:14:02 -04:00
|
|
|
|
'docutils'
|
2009-06-12 06:00:17 -04:00
|
|
|
|
>>> dist.metadata.version
|
2009-06-23 08:14:02 -04:00
|
|
|
|
'0.5'
|
2009-05-25 06:22:46 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
>>> for path, hash, size in dist.get_installed_files()::
|
2009-06-23 04:50:10 -04:00
|
|
|
|
... print '%s %s %d' % (path, hash, size)
|
2009-05-16 12:02:06 -04:00
|
|
|
|
...
|
2009-06-23 08:14:02 -04:00
|
|
|
|
docutils/__init__.py b690274f621402dda63bf11ba5373bf2 9544
|
|
|
|
|
docutils/core.py 9c4b84aff68aa55f2e9bf70481b94333 66188
|
|
|
|
|
roman.py a4b84aff68aa55f2e9bf70481b943D3 234
|
|
|
|
|
/usr/local/bin/rst2html.py a4b84aff68aa55f2e9bf70481b943D3 234
|
|
|
|
|
docutils-0.5-py2.6.egg-info/PKG-INFO 6fe57de576d749536082d8e205b77748 195
|
|
|
|
|
docutils-0.5-py2.6.egg-info/RECORD None None
|
|
|
|
|
|
|
|
|
|
>>> dist.uses('docutils/core.py')
|
|
|
|
|
True
|
|
|
|
|
|
|
|
|
|
>>> dist.uses('/usr/local/bin/rst2html.py')
|
2009-05-25 06:22:46 -04:00
|
|
|
|
True
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
>>> dist.get_egginfo_file('PKG-INFO')
|
2009-05-25 06:22:46 -04:00
|
|
|
|
<open file at ...>
|
|
|
|
|
|
|
|
|
|
PEP 262 replacement
|
|
|
|
|
===================
|
|
|
|
|
|
|
|
|
|
In the past an attempt was made to create a installation database (see PEP 262
|
|
|
|
|
[#pep262]_).
|
|
|
|
|
|
|
|
|
|
Extract from PEP 262 Requirements:
|
|
|
|
|
|
|
|
|
|
" We need a way to figure out what distributions, and what versions of
|
|
|
|
|
those distributions, are installed on a system..."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Since the APIs proposed in the current PEP provide everything needed to meet
|
|
|
|
|
this requirement, PEP 376 will replace PEP 262 and will become the official
|
|
|
|
|
`installation database` standard.
|
|
|
|
|
|
|
|
|
|
The new version of PEP 345 (XXX work in progress) will extend the Metadata
|
|
|
|
|
standard and will fullfill the requirements described in PEP 262, like the
|
|
|
|
|
`REQUIRES` section.
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-05-07 05:02:23 -04:00
|
|
|
|
Adding an Uninstall function
|
|
|
|
|
============================
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-06-23 04:50:10 -04:00
|
|
|
|
Distutils already provides a very basic way to install a distribution, which
|
|
|
|
|
is running the `install` command over the `setup.py` script of the
|
2009-06-22 09:06:55 -04:00
|
|
|
|
distribution.
|
2009-03-28 15:08:48 -04:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
Distutils will provide a very basic ``uninstall`` function, that will be added
|
2009-06-23 04:50:10 -04:00
|
|
|
|
in ``distutils.util`` and will take the name of the distribution to uninstall
|
2009-06-22 09:06:55 -04:00
|
|
|
|
as its argument. ``uninstall`` will use the APIs desribed earlier and remove all
|
2009-05-16 12:02:06 -04:00
|
|
|
|
unique files, as long as their hash didn't change. Then it will remove
|
2009-05-25 06:22:46 -04:00
|
|
|
|
empty directories left behind.
|
2009-03-28 15:08:48 -04:00
|
|
|
|
|
2009-05-16 12:02:06 -04:00
|
|
|
|
``uninstall`` will return a list of uninstalled files::
|
2009-03-28 15:08:48 -04:00
|
|
|
|
|
2009-04-24 12:03:02 -04:00
|
|
|
|
>>> from distutils.util import uninstall
|
2009-06-23 08:14:02 -04:00
|
|
|
|
>>> uninstall('docutils')
|
|
|
|
|
['/opt/local/lib/python2.6/site-packages/docutils/core.py',
|
|
|
|
|
...
|
|
|
|
|
'/opt/local/lib/python2.6/site-packages/docutils/__init__.py']
|
2009-05-07 05:02:23 -04:00
|
|
|
|
|
2009-06-22 09:06:55 -04:00
|
|
|
|
If the distribution is not found, a ``DistutilsUninstallError`` will be raised.
|
2009-03-28 15:08:48 -04:00
|
|
|
|
|
2009-06-05 04:35:30 -04:00
|
|
|
|
Filtering
|
|
|
|
|
---------
|
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
To make it a reference API for third-party projects that wish to control
|
|
|
|
|
how `uninstall` works, a second callable argument can be used. It will be
|
|
|
|
|
called for each file that is removed. If the callable returns `True`, the
|
2009-05-16 12:02:06 -04:00
|
|
|
|
file will be removed. If it returns False, it will be left alone.
|
2009-03-28 15:08:48 -04:00
|
|
|
|
|
2009-04-24 12:03:02 -04:00
|
|
|
|
Examples::
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-04-24 12:03:02 -04:00
|
|
|
|
>>> def _remove_and_log(path):
|
|
|
|
|
... logging.info('Removing %s' % path)
|
|
|
|
|
... return True
|
2009-05-16 12:02:06 -04:00
|
|
|
|
...
|
2009-06-23 08:14:02 -04:00
|
|
|
|
>>> uninstall('docutils', _remove_and_log)
|
2009-05-07 05:02:23 -04:00
|
|
|
|
|
2009-04-24 12:03:02 -04:00
|
|
|
|
>>> def _dry_run(path):
|
|
|
|
|
... logging.info('Removing %s (dry run)' % path)
|
|
|
|
|
... return False
|
2009-05-16 12:02:06 -04:00
|
|
|
|
...
|
2009-06-23 08:14:02 -04:00
|
|
|
|
>>> uninstall('docutils', _dry_run)
|
2009-03-28 15:08:48 -04:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
Of course, a third-party tool can use ``pkgutil`` APIs to implement
|
2009-05-16 13:13:54 -04:00
|
|
|
|
its own uninstall feature.
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
2009-06-05 04:35:30 -04:00
|
|
|
|
Installer marker
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
|
|
As explained earlier in this PEP, the `install` command adds an `INSTALLER`
|
|
|
|
|
file in the `.egg-info` directory with the name of the installer.
|
|
|
|
|
|
2009-06-22 09:06:55 -04:00
|
|
|
|
To avoid removing distributions that where installed by another packaging system,
|
2009-06-05 04:35:30 -04:00
|
|
|
|
the ``uninstall`` function takes an extra argument ``installer`` which default
|
|
|
|
|
to ``distutils``.
|
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
When called, ``uninstall`` will control that the ``INSTALLER`` file matches
|
2009-06-05 04:35:30 -04:00
|
|
|
|
this argument. If not, it will raise a ``DistutilsUninstallError``::
|
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
>>> uninstall('docutils')
|
2009-06-05 04:35:30 -04:00
|
|
|
|
Traceback (most recent call last):
|
|
|
|
|
...
|
2009-06-23 08:14:02 -04:00
|
|
|
|
DistutilsUninstallError: docutils was installed by 'cool-pkg-manager'
|
2009-06-05 04:35:30 -04:00
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
>>> uninstall('docutils', installer='cool-pkg-manager')
|
2009-06-05 04:35:30 -04:00
|
|
|
|
|
2009-06-12 06:00:17 -04:00
|
|
|
|
This allows a third-party application to use the ``uninstall`` function
|
2009-06-22 09:06:55 -04:00
|
|
|
|
and make sure it's the only program that can remove a distribution it has
|
2009-06-05 04:35:30 -04:00
|
|
|
|
previously installed. This is useful when a third-party program that relies
|
|
|
|
|
on Distutils APIs does extra steps on the system at installation time,
|
|
|
|
|
it has to undo at uninstallation time.
|
|
|
|
|
|
2009-05-14 05:32:29 -04:00
|
|
|
|
Backward compatibility and roadmap
|
|
|
|
|
==================================
|
|
|
|
|
|
|
|
|
|
These changes will not introduce any compatibility problems with the previous
|
|
|
|
|
version of Distutils, and will also work with existing third-party tools.
|
|
|
|
|
|
2009-05-14 18:19:41 -04:00
|
|
|
|
Although, a backport of the new Distutils for 2.5, 2.6, 3.0 and 3.1 will be
|
2009-05-16 12:02:06 -04:00
|
|
|
|
provided so people can benefit from these new features.
|
2009-05-14 18:19:41 -04:00
|
|
|
|
|
2009-05-14 05:32:29 -04:00
|
|
|
|
The plan is to integrate them for Python 2.7 and Python 3.2
|
2009-03-28 15:08:48 -04:00
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
|
2009-05-16 12:02:06 -04:00
|
|
|
|
References
|
|
|
|
|
==========
|
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
.. [#distutils]
|
|
|
|
|
http://docs.python.org/distutils
|
|
|
|
|
|
2009-05-16 12:02:06 -04:00
|
|
|
|
.. [#pep262]
|
|
|
|
|
http://www.python.org/dev/peps/pep-0262
|
|
|
|
|
|
|
|
|
|
.. [#pep314]
|
|
|
|
|
http://www.python.org/dev/peps/pep-0314
|
|
|
|
|
|
2009-05-16 13:13:54 -04:00
|
|
|
|
.. [#setuptools]
|
|
|
|
|
http://peak.telecommunity.com/DevCenter/setuptools
|
|
|
|
|
|
|
|
|
|
.. [#pip]
|
|
|
|
|
http://pypi.python.org/pypi/pip
|
2009-05-16 12:02:06 -04:00
|
|
|
|
|
2009-05-25 06:22:46 -04:00
|
|
|
|
.. [#eggformats]
|
|
|
|
|
http://peak.telecommunity.com/DevCenter/EggFormats
|
|
|
|
|
|
2009-06-22 09:06:55 -04:00
|
|
|
|
.. [#pep273]
|
|
|
|
|
http://www.python.org/dev/peps/pep-0273
|
|
|
|
|
|
2009-06-23 08:14:02 -04:00
|
|
|
|
.. [#pep278]
|
2009-06-23 04:50:10 -04:00
|
|
|
|
http://www.python.org/dev/peps/pep-0278
|
|
|
|
|
|
|
|
|
|
|
2009-03-28 15:08:48 -04:00
|
|
|
|
Aknowledgments
|
|
|
|
|
==============
|
2009-02-21 21:33:52 -05:00
|
|
|
|
|
2009-03-28 15:08:48 -04:00
|
|
|
|
Jim Fulton, Ian Bicking, Phillip Eby, and many people at Pycon and Distutils-SIG.
|
2009-02-28 09:22:01 -05:00
|
|
|
|
|
2009-02-21 21:33:52 -05:00
|
|
|
|
Copyright
|
|
|
|
|
=========
|
|
|
|
|
|
|
|
|
|
This document has been placed in the public domain.
|
|
|
|
|
|
|
|
|
|
|
2009-02-28 09:22:01 -05:00
|
|
|
|
|
2009-02-21 21:33:52 -05:00
|
|
|
|
..
|
|
|
|
|
Local Variables:
|
|
|
|
|
mode: indented-text
|
|
|
|
|
indent-tabs-mode: nil
|
|
|
|
|
sentence-end-double-space: t
|
|
|
|
|
fill-column: 70
|
|
|
|
|
coding: utf-8
|
|
|
|
|
End:
|