Skip to content

Commit 98b9b89

Browse files
committed
Fix #185: Update documentation to correct links.
1 parent 2b33be1 commit 98b9b89

File tree

8 files changed

+542
-324
lines changed

8 files changed

+542
-324
lines changed

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ Released: 2013-04-30
992992

993993
- metadata
994994

995-
- Added missing condition in :meth:`todict`.
995+
- Added missing condition in :meth:`~distlib.metadata.Metadata.todict`.
996996

997997
- scripts
998998

distlib/manifest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535
_PYTHON_VERSION = sys.version_info[:2]
3636

3737
class Manifest(object):
38-
"""A list of files built by on exploring the filesystem and filtered by
39-
applying various patterns to what we find there.
38+
"""
39+
A list of files built by exploring the filesystem and filtered by applying various
40+
patterns to what we find there.
4041
"""
4142

4243
def __init__(self, base=None):

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# You can set these variables from the command line.
55
SPHINXOPTS =
6-
SPHINXBUILD = sphinx-build
6+
SPHINXBUILD = sphinx-build -n
77
PAPER =
88
BUILDDIR = _build
99

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263

264264

265265
# Example configuration for intersphinx: refer to the Python standard library.
266-
intersphinx_mapping = {'http://docs.python.org/': None}
266+
intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
267267

268268
def skip_module_docstring(app, what, name, obj, options, lines):
269269
if (what, name) == ('module', 'distlib'):

docs/internals.rst

Lines changed: 76 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,24 @@ Locating distributions
6464
~~~~~~~~~~~~~~~~~~~~~~
6565

6666
It seems that the simplest API to locate a distribution would look like
67-
``locate(requirement)``, where ``requirement`` is a string giving the
68-
distribution name and optional version constraints. Given that we know that
69-
distributions can be found in different places, it's best to consider a
70-
:class:`Locator` class which has a :meth:`locate` method with a corresponding
67+
``locate(requirement)``, where ``requirement`` is a string giving the distribution
68+
name and optional version constraints. Given that we know that distributions can be
69+
found in different places, it's best to consider a :class:`~distlib.locators.Locator`
70+
class which has a :meth:`~distlib.locators.Locator.locate` method with a corresponding
7171
signature, with subclasses for each of the different types of location that
72-
distributions inhabit. It's also reasonable to provide a default locator in
73-
a module attribute :attr:`default_locator`, and a module-level :func:`locate`
74-
function which calls the :meth:`locate` method on the default locator.
75-
76-
Since we'll often need to locate all the versions of a project before picking
77-
one, we can imagine that a locator would need a :meth:`get_project` method for
78-
fetching all versions of a project; and since we will be likely to want to use
79-
caching, we can assume there will be a :meth:`_get_project` method to do the
80-
actual work of fetching the version data, which the higher-level
81-
:meth:`get_project` will call (and probably cache). So our locator base class
82-
will look something like this::
72+
distributions inhabit. It's also reasonable to provide a default locator in a module
73+
attribute :attr:`~distlib.locators.default_locator`, and a module-level
74+
:func:`~distlib.locators.locate` function which calls the
75+
:meth:`~distlib.locators.Locator.locate` method on the default locator.
76+
77+
Since we'll often need to locate all the versions of a project before picking one, we
78+
can imagine that a locator would need a :meth:`~distlib.locators.Locator.get_project`
79+
method for fetching all versions of a project; and since we will be likely to want to
80+
use caching, we can assume there will be a
81+
:meth:`~distlib.locators.Locator._get_project` method to do the actual work of
82+
fetching the version data, which the higher-level
83+
:meth:`~distlib.locators.Locator.get_project` will call (and probably cache). So our
84+
locator base class will look something like this::
8385

8486
class Locator(object):
8587
"""
@@ -114,20 +116,20 @@ will look something like this::
114116
instance, or an empty dictionary if nothing was found.
115117
"""
116118

117-
When attempting to :meth:`locate`, it would be useful to pass requirement
118-
information to :meth:`get_project` / :meth:`_get_project`. This can be done in
119-
a :attr:`matcher` attribute which is normally ``None`` but set to a
120-
:class:`distlib.version.Matcher` instance when a :meth:`locate` call is in
121-
progress.
119+
When attempting to :meth:`~distlib.locators.Locator.locate`, it would be useful to
120+
pass requirement information to :meth:`~distlib.locators.Locator.get_project` /
121+
:meth:`~distlib.locators.Locator._get_project`. This can be done in a :attr:`~distlib.locators.Locator.matcher`
122+
attribute which is normally ``None`` but set to a :class:`~distlib.version.Matcher`
123+
instance when a :meth:`~distlib.locators.Locator.locate` call is in progress.
122124

123125
Note that in order to work with legacy version numbers (those not complying with PEP
124126
440), you need to pass ``scheme='legacy'`` to the initializer for a locator.
125127

126128
Finding dependencies
127129
~~~~~~~~~~~~~~~~~~~~
128130

129-
A dependency finder will depend on a locator to locate dependencies. A simple
130-
approach will be to consider a :class:`DependencyFinder` class which takes a
131+
A dependency finder will depend on a locator to locate dependencies. A simple approach
132+
will be to consider a :class:`~distlib.locators.DependencyFinder` class which takes a
131133
locator as a constructor argument. It might look something like this::
132134

133135
class DependencyFinder(object):
@@ -195,17 +197,19 @@ A minimal solution
195197
^^^^^^^^^^^^^^^^^^
196198

197199
The distutils approach was to have several separate command classes called
198-
``register``, ``upload`` and ``upload_doc``, where really all that was needed
199-
was some methods. That's the approach ``distlib`` takes, by implementing a
200-
:class:`PackageIndex` class with :meth:`register`, :meth:`upload_file` and
201-
:meth:`upload_documentation` methods. The :class:`PackageIndex` class contains
202-
no user interface code whatsoever: that's assumed to be the domain of the
203-
packaging tool. The packaging tool is expected to get the required information
204-
from a user using whatever means the developers of that tool deem to be the
205-
most appropriate; the required attributes are then set on the
206-
:class:`PackageIndex` instance. (Examples of this kind of information: user
207-
name, password, whether the user wants to save a default configuration, where
208-
the signing program and its keys live.)
200+
``register``, ``upload`` and ``upload_doc``, where really all that was needed was some
201+
methods. That's the approach ``distlib`` takes, by implementing a
202+
:class:`~distlib.index.PackageIndex` class with
203+
:meth:`~distlib.index.PackageIndex.register`,
204+
:meth:`~distlib.index.PackageIndex.upload_file` and
205+
:meth:`~distlib.index.PackageIndex.upload_documentation` methods. The
206+
:class:`~distlib.index.PackageIndex` class contains no user interface code whatsoever:
207+
that's assumed to be the domain of the packaging tool. The packaging tool is expected
208+
to get the required information from a user using whatever means the developers of
209+
that tool deem to be the most appropriate; the required attributes are then set on the
210+
:class:`~distlib.index.PackageIndex` instance. (Examples of this kind of information:
211+
user name, password, whether the user wants to save a default configuration, where the
212+
signing program and its keys live.)
209213

210214
The minimal interface to provide the required functionality thus looks like
211215
this::
@@ -245,8 +249,8 @@ this::
245249
archiving the directory contents into a .zip file.
246250
"""
247251

248-
The following additional attributes can be identified on :class:`PackageIndex`
249-
instances:
252+
The following additional attributes can be identified on
253+
:class:`~distlib.index.PackageIndex` instances:
250254

251255
* ``username`` - the username to use for authentication.
252256
* ``password`` - the password to use for authentication.
@@ -465,7 +469,7 @@ available via a file on the file system, we'll assume a simple caching
465469
solution that saves any such resources to a local file system cache, and
466470
returns the filename of the resource in the cache. We need to divide the
467471
work between the finder and the cache. We'll deliver the cache function
468-
through a :class:`Cache` class, which will have the following methods:
472+
through a :class:`~distlib.util.Cache` class, which will have the following methods:
469473

470474
* A constructor which takes an optional base directory for the cache. If
471475
none is provided, we'll construct a base directory of the form::
@@ -477,36 +481,36 @@ through a :class:`Cache` class, which will have the following methods:
477481
will be used as ``<rootdir>`` -- otherwise, the user's home directory
478482
will be used.
479483

480-
* A :meth:`get` method which takes a ``Resource`` and returns a file system
481-
filename, such that the contents of that named file will be the contents
482-
of the resource.
483-
484-
* An :meth:`is_stale` method which takes a ``Resource`` and its corresponding
485-
file system filename, and returns whether the file system file is stale
486-
when compared with the resource. Knowing that cache invalidation is hard,
487-
the default implementation just returns ``True``.
488-
489-
* A :meth:`prefix_to_dir` method which converts a prefix to a directory name.
490-
We'll assume that for the cache, a resource path can be divided into two
491-
parts: the *prefix* and the *subpath*. For resources in a .zip file, the
492-
prefix would be the pathname of the archive, while the subpath would be the
493-
path inside the archive. For a file system resource, since it is already in
494-
the file system, the prefix would be ``None`` and the subpath would be the
495-
absolute path name of the resource. The :meth:`prefix_to_dir` method's job
496-
is to convert a prefix (if not ``None``) to a subdirectory in the cache
497-
that holds the cached files for all resources with that prefix. We'll
498-
delegate the determination of a resource's prefix and subpath to its finder,
499-
using a :meth:`get_cache_info` method on finders, which takes a ``Resource``
500-
and returns a (``prefix``, ``subpath``) tuple.
501-
502-
The default implementation will use :func:`os.splitdrive` to see if there's
484+
* A :meth:`~distlib.resources.ResourceCache.get` method which takes a ``Resource`` and
485+
returns a file system filename, such that the contents of that named file will be
486+
the contents of the resource.
487+
488+
* An :meth:`~distlib.resources.ResourceCache.is_stale` method which takes a
489+
``Resource`` and its corresponding file system filename, and returns whether the
490+
file system file is stale when compared with the resource. Knowing that cache
491+
invalidation is hard, the default implementation just returns ``True``.
492+
493+
* A :meth:`~distlib.util.Cache.prefix_to_dir` method which converts a
494+
prefix to a directory name. We'll assume that for the cache, a resource path can be
495+
divided into two parts: the *prefix* and the *subpath*. For resources in a .zip
496+
file, the prefix would be the pathname of the archive, while the subpath would be
497+
the path inside the archive. For a file system resource, since it is already in the
498+
file system, the prefix would be ``None`` and the subpath would be the absolute path
499+
name of the resource. The :meth:`~distlib.util.Cache.prefix_to_dir` method's job is
500+
to convert a prefix (if not ``None``) to a subdirectory in the cache that holds the
501+
cached files for all resources with that prefix. We'll delegate the determination of
502+
a resource's prefix and subpath to its finder, using a
503+
:meth:`~distlib.resources.ResourceFinder.get_cache_info` method on finders, which
504+
takes a ``Resource`` and returns a (``prefix``, ``subpath``) tuple.
505+
506+
The default implementation will use :func:`os.path.splitdrive` to see if there's
503507
a Windows drive, if present, and convert its ``':'`` to ``'---'``. The rest
504508
of the prefix will be converted by replacing ``'/'`` by ``'--'``, and
505509
appending ``'.cache'`` to the result.
506510

507511
The cache will be activated when the ``file_path`` property of a ``Resource``
508512
is accessed. This will be a cached property, and will call the cache's
509-
:meth:`get` method to obtain the file system path.
513+
:meth:`~distlib.resources.ResourceCache.get` method to obtain the file system path.
510514

511515
The ``scripts`` API
512516
-------------------
@@ -602,9 +606,9 @@ In addition, other methods suggest themselves for :class:`ScriptMaker`:
602606
analysis tool, over all the installed files.
603607

604608
* The details of the callable specification can be encapsulated in a utility
605-
function, :func:`~distlib.util.get_exports_entry`. This would take a
606-
specification and return ``None``, if the specification didn't match the
607-
callable format, or an instance of :class:`ExportEntry` if it did match.
609+
function, :func:`~distlib.util.get_export_entry`. This would take a specification
610+
and return ``None``, if the specification didn't match the callable format, or an
611+
instance of :class:`~distlib.util.ExportEntry` if it did match.
608612

609613
In addition, the following attributes on a ``ScriptMaker`` could be further used
610614
to refine its behaviour:
@@ -863,11 +867,10 @@ each scheme are bundled into a simple :class:`VersionScheme` class::
863867
Of course, the version class is also available through the matcher's
864868
``version_class`` attribute.
865869

866-
:class:`VersionScheme` makes it easier to work with alternative version schemes.
867-
For example, say we decide to experiment with an "adaptive" version scheme,
868-
which is based on the PEP 386 scheme, but when handed a non-conforming version,
869-
automatically tries to convert it to a normalized version using
870-
:func:`suggest_normalized_version`. Then, code which has to deal with version
870+
:class:`VersionScheme` makes it easier to work with alternative version schemes. For
871+
example, say we decide to experiment with an "adaptive" version scheme, which is based
872+
on the PEP 386 scheme, but when handed a non-conforming version, automatically tries
873+
to convert it to a normalized version. Then, code which has to deal with version
871874
schemes just has to pick the appropriate scheme by name.
872875

873876
Creating the adaptive scheme is easy::
@@ -927,10 +930,10 @@ There are basically two operations which need to be performed on wheels:
927930
A minimal solution
928931
^^^^^^^^^^^^^^^^^^
929932

930-
Since we're talking about wheels, it seems likely that a :class:`Wheel` class
931-
would be part of the design. This allows for extensibility over a purely
932-
function-based API. The :class:`Wheel` would be expected to have methods that
933-
support the required operations::
933+
Since we're talking about wheels, it seems likely that a :class:`~distlib.wheel.Wheel`
934+
class would be part of the design. This allows for extensibility over a purely
935+
function-based API. The :class:`~distlib.wheel.Wheel` would be expected to have
936+
methods that support the required operations::
934937

935938
class Wheel(object):
936939
def __init__(self, spec):
@@ -985,7 +988,7 @@ support the required operations::
985988
"""
986989

987990
In addition to the above, the following attributes can be identified for a
988-
:class:`Wheel` instance:
991+
:class:`~distlib.wheel.Wheel` instance:
989992

990993
* ``name`` -- the name of the distribution
991994
* ``version`` -- the version of the distribution

docs/migration.rst

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ Resource extraction
4040

4141
resources.cache = resources.Cache(extraction_path)
4242

43-
before accessing the ``file_path`` property of any :class:`Resource`.
44-
Note that if you have accessed the ``file_path`` property for a resource
45-
*before* doing this, the cache may already have extracted files.
43+
before accessing the ``file_path`` property of any
44+
:class:`~distlib.resources.Resource`. Note that if you have accessed the
45+
``file_path`` property for a resource *before* doing this, the cache may already
46+
have extracted files.
4647

4748
``cleanup_resources(force=False)``
4849
This is not actually implemented in ``pkg_resources`` -- it's a no-op.
@@ -55,9 +56,9 @@ Resource extraction
5556
Provider interface
5657
~~~~~~~~~~~~~~~~~~
5758

58-
You can provide an ``XXXResourceFinder`` class which finds resources in custom
59-
storage containers, and works like ``ResourceFinder``. Although it shouldn't
60-
be necessary, you could also return a subclass of :class:`Resource` from your
59+
You can provide an ``XXXResourceFinder`` class which finds resources in custom storage
60+
containers, and works like ``ResourceFinder``. Although it shouldn't be necessary, you
61+
could also return a subclass of :class:`~distlib.resources.Resource` from your
6162
finders, to deal with custom requirements which aren't catered for.
6263

6364
``get_cache_path(archive_name, names=())``
@@ -66,17 +67,18 @@ finders, to deal with custom requirements which aren't catered for.
6667
API, please give feedback with more information about your use cases.
6768

6869
``extraction_error()``
69-
There's no analogue for this. The :meth:`Cache.get` method, which writes
70-
a resource's bytes to a file in the cache, will raise any exception caused
71-
by underlying I/O. If you need to handle this in the cache layer, you can
72-
subclass :class:`Cache` and override :meth:`get`. If that doesn't work for
73-
you, please give feedback with more information about your use cases.
70+
There's no analogue for this. The :meth:`~distlib.resources.ResourceCache.get`
71+
method, which writes a resource's bytes to a file in the cache, will raise any
72+
exception caused by underlying I/O. If you need to handle this in the cache layer,
73+
you can subclass :class:`~distlib.resources.ResourceCache` and override
74+
:meth:`~distlib.resources.ResourceCache.get`. If that doesn't work for you, please
75+
give feedback with more information about your use cases.
7476

7577
``postprocess(tempname, filename)``
76-
There's no analogue for this. The :meth:`Cache.get` method, which writes
77-
a resource's bytes to a file in the cache, can be overridden to perform any
78-
custom post-processing. If that doesn't work for you, please give feedback
79-
with more information about your use cases.
78+
There's no analogue for this. The :meth:`~distlib.resources.ResourceCache.get`
79+
method, which writes a resource's bytes to a file in the cache, can be overridden
80+
to perform any custom post-processing. If that doesn't work for you, please give
81+
feedback with more information about your use cases.
8082

8183
The ``pkg_resources`` entry point API
8284
-------------------------------------
@@ -89,15 +91,15 @@ term is a little ambiguous. In Eclipse, for example, they are called *extension
8991
point IDs*, which is a little closer to the intended usage, but a bit of a
9092
mouthful. In ``distlib``, we'll use the term ``category`` or ``export category``.
9193

92-
In ``distlib``, the implementation of exports is slightly different from
93-
entry points of ``pkg_resources``. A :class:`Distribution` instance has an
94-
``exports`` attribute, which is a dictionary keyed by category and whose values
95-
are dictionaries that map names to :class:`ExportEntry` instances.
94+
In ``distlib``, the implementation of exports is slightly different from entry points
95+
of ``pkg_resources``. A :class:`~distlib.database.Distribution` instance has an
96+
``exports`` attribute, which is a dictionary keyed by category and whose values are
97+
dictionaries that map names to :class:`~distlib.util.ExportEntry` instances.
9698

97-
Below are the ``pkg_resources`` functions and how to achieve the equivalent
98-
in ``distlib``. In cases where the ``pkg_resources`` functions take distribution
99-
names, in ``distlib`` you get the corresponding :class:`Distribution` instance,
100-
using::
99+
Below are the ``pkg_resources`` functions and how to achieve the equivalent in
100+
``distlib``. In cases where the ``pkg_resources`` functions take distribution names,
101+
in ``distlib`` you get the corresponding :class:`~distlib.database.Distribution`
102+
instance, using::
101103

102104
dist = dist_path.get_distribution(distname)
103105

0 commit comments

Comments
 (0)