Source

aodag.bitbucket.org / pep-0376-ja.html

Full commit
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>概要 &mdash; aodag documents v0.0 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '#',
        VERSION:     '0.0',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="aodag documents v0.0 documentation" href="index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li><a href="index.html">aodag documents v0.0 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <p>PEP: 376
Title: Database of Installed Python Distributions
Version: $Revision: 80514 $
Last-Modified: $Date: 2010-04-26 23:37:21 +0200 (Mon, 26 Apr 2010) $
Author: Tarek Ziadテゥ &lt;<a class="reference external" href="mailto:tarek&#37;&#52;&#48;ziade&#46;org">tarek<span>&#64;</span>ziade<span>&#46;</span>org</a>&gt;
Status: Accepted
Type: Standards Track
Content-Type: text/x-rst
Created: 22-Feb-2009
Python-Version: 2.7, 3.2
Post-History:
Transrator: Atsushi Odagiri</p>
<div class="section" id="id1">
<h1>概要<a class="headerlink" href="#id1" title="Permalink to this headline"></a></h1>
<p>The goal of this PEP is to provide a standard infrastructure to manage
project distributions installed on a system, so all tools that are
installing or removing projects are interoperable.</p>
<p>このPEPの目標は、システムにインストールされた配布物を管理するための標準的な仕組みを提供することである。
そして、すべてのインストール、アンインストールをするツールが相互運用できるようになる。</p>
<p>To achieve this goal, the PEP proposes a new format to describe installed
distributions on a system. It also describes a reference implementation
for the standard library.</p>
<p>この目標において、このPEPでは、システムにインストールされた配布物の詳細を表すためのフォーマットを提案する。
また、標準ライブラリの実装についても言及する。</p>
<p>In the past an attempt was made to create an installation database (see PEP 262
<a class="footnote-reference" href="#pep262" id="id2">[3]</a>).</p>
<p>過去に、インストールデータベースを作成が試みられている。 (see PEP 262
<a class="footnote-reference" href="#pep262" id="id3">[3]</a>).</p>
<p>Combined with PEP 345, the current proposal supersedes PEP 262.</p>
<p>PEP 345と統合し、PEP 262を置き換える。</p>
</div>
<div class="section" id="id4">
<h1>根拠<a class="headerlink" href="#id4" title="Permalink to this headline"></a></h1>
<p>There are two problems right now in the way distributions are installed in
Python:</p>
<ul class="simple">
<li>There are too many ways to do it and this makes interoperation difficult.</li>
<li>There is no API to get information on installed distributions.</li>
</ul>
<p>現在、Pythonにインストールされる配布物について、2つの問題がある。</p>
<ul class="simple">
<li>配布物をインストールするのに多くの方法があり相互運用が難しくなっている。</li>
<li>インストールされた配布物の情報を取得するためのAPIが存在しない。</li>
</ul>
<div class="section" id="id5">
<h2>配布物がどのようにインストールされるのか<a class="headerlink" href="#id5" title="Permalink to this headline"></a></h2>
<p>Right now, when a distribution is installed in Python, every element can
be installed in a different directory.</p>
<p>現在は、配布物がPythonにインストールする際に、各要素を別々のディレクトリにインストールできる。</p>
<p>For instance, <cite>Distutils</cite> installs the pure Python code in the <cite>purelib</cite>
directory, which is <tt class="docutils literal"><span class="pre">lib\python2.6\site-packages</span></tt> for unix-like systems and
Mac OS X, or <cite>Lib/site-packages</cite> under Python&#8217;s installation directory for
Windows.</p>
<p>例えば、 <cite>Distutils</cite> は、ピュアPythonコードを <cite>purelib</cite> ディレクトリにインストールする。
unixライクなシステムとMac OS Xでは、 <tt class="docutils literal"><span class="pre">lib\python2.6\site-packages</span></tt> にインストールされ、
Windowsでは、 <cite>Lib/site-packages</cite> にインストールされる。</p>
<p>Additionally, the <cite>install_egg_info</cite> subcommand of the Distutils <cite>install</cite>
command adds an <cite>.egg-info</cite> file for the project into the <cite>purelib</cite>
directory.</p>
<p>加えて、Distutilsの <cite>install</cite> コマンドのサブコマンド <cite>install_egg_info</cite> は、
<cite>.egg-info</cite> ファイルを <cite>purelib</cite> ディレクトリに作成する。</p>
<p>For example, for the <cite>docutils</cite> distribution, which contains one package an
extra module and executable scripts, three elements are installed in
<cite>site-packages</cite>:</p>
<ul class="simple">
<li><cite>docutils</cite>: The <tt class="docutils literal"><span class="pre">docutils</span></tt> package.</li>
<li><cite>roman.py</cite>: An extra module used by <cite>docutils</cite>.</li>
<li><cite>docutils-0.5-py2.6.egg-info</cite>: A file containing the distribution metadata
as described in PEP 314 <a class="footnote-reference" href="#pep314" id="id6">[4]</a>. This file corresponds to the file
called <cite>PKG-INFO</cite>, built by the <cite>sdist</cite> command.</li>
</ul>
<p>例えば、 <cite>docutils</cite> の配布物の場合、 1つのパッケージと、実行可能なスクリプトを含んでおり、
3つの要素が、 <cite>site-packages</cite> 以下にインストールされる。:</p>
<ul class="simple">
<li><cite>docutils</cite>: <tt class="docutils literal"><span class="pre">docutils</span></tt> パッケージ</li>
<li><cite>roman.py</cite>: <cite>docutils</cite> が利用する拡張モジュール</li>
<li><cite>docutils-0.5-py2.6.egg-info</cite>: 配布物のメタデータを含むファイル(PEP 314 <a class="footnote-reference" href="#pep314" id="id7">[4]</a>)
このファイルは、 <cite>PKG-INFO</cite> に相当し、 <cite>sdist</cite> コマンドで生成される。</li>
</ul>
<p>Some executable scripts, such as <cite>rst2html.py</cite>, are also added in the
<cite>bin</cite> directory of the Python installation.</p>
<p><cite>rst2html.py</cite> のような、いくつかの実行可能なスクリプトも、 Python環境の
<cite>bin</cite> ディレクトリにインストールされる。</p>
<p>Another project called <cite>setuptools</cite> <a class="footnote-reference" href="#setuptools" id="id8">[5]</a> has two other formats
to install distributions, called <cite>EggFormats</cite> <a class="footnote-reference" href="#eggformats" id="id9">[8]</a>:</p>
<ul class="simple">
<li>a self-contained <cite>.egg</cite> directory, that contains all the distribution files
and the distribution metadata in a file called <cite>PKG-INFO</cite> in a subdirectory
called <cite>EGG-INFO</cite>. <cite>setuptools</cite> creates other files in that directory that can
be considered as complementary metadata.</li>
<li>an <cite>.egg-info</cite> directory installed in <cite>site-packages</cite>, that contains the same
files <cite>EGG-INFO</cite> has in the <cite>.egg</cite> format.</li>
</ul>
<p><cite>setuptools</cite> <a class="footnote-reference" href="#setuptools" id="id10">[5]</a> プロジェクトでは、
<cite>EggFormats</cite> <a class="footnote-reference" href="#eggformats" id="id11">[8]</a> という2つのフォーマットが追加されている。</p>
<ul class="simple">
<li><cite>.egg</cite> ディレクトリ形式は、配布物のすべてと <cite>PKG-INFO</cite> というメタデータファイルを、
<cite>EGG-INFO</cite> というサブディレクトリに含める。
<cite>setuptools</cite> はメタデータを補完できるように考えられている。</li>
<li><cite>.egg-info</cite> ディレクトリは、 <cite>site-packages</cite> にインストールされ、
<cite>.egg</cite> 形式の <cite>EGG-INFO</cite> と同じ内容のファイルが含まれる。</li>
</ul>
<p>The first format is automatically used when you install a distribution that
uses the <tt class="docutils literal"><span class="pre">setuptools.setup</span></tt> function in its setup.py file, instead of
the <tt class="docutils literal"><span class="pre">distutils.core.setup</span></tt> one.</p>
<p>最初の形式は、配布物のsetup.pyの中で、
<tt class="docutils literal"><span class="pre">distutils.core.setup</span></tt> の代わりに <tt class="docutils literal"><span class="pre">setuptools.setup</span></tt> が使用されていると、
自動的に生成される。</p>
<p><cite>setuptools</cite> also add a reference to the distribution into an
<tt class="docutils literal"><span class="pre">easy-install.pth</span></tt> file.</p>
<p><cite>setuptools</cite> は、 <tt class="docutils literal"><span class="pre">easy-install.pth</span></tt> に配布物への参照を追加する。</p>
<p>Last, the <cite>setuptools</cite> project provides an executable script called
<cite>easy_install</cite> <a class="footnote-reference" href="#easyinstall" id="id12">[6]</a> that installs all distributions, including
distutils-based ones in self-contained <cite>.egg</cite> directories.</p>
<p>最後に、 <cite>setuptools</cite> プロジェクトは、 <cite>easy_install</cite> <a class="footnote-reference" href="#easyinstall" id="id13">[6]</a> というスクリプトを提供している。
これは、 distutilsベースのものも含めて、 <cite>.egg</cite> ディレクトリ形式にインストールする。</p>
<p>If you want to have standalone <cite>.egg-info</cite> directories for your distributions,
e.g. the second <cite>setuptools</cite> format, you have to force it when you work
with a setuptools-based distribution or with the <cite>easy_install</cite> script.
You can force it by using the <cite>-窶都ingle-version-externally-managed</cite> option
<strong>or</strong> the <cite>&#8211;root</cite> option. This will make the <cite>setuptools</cite> project install
the project like distutils does.</p>
<p>TODO: ここよく分からない</p>
<p>このオプションは以下のプロジェクトで利用されている :</p>
<ul class="simple">
<li>the <cite>pip</cite> <a class="footnote-reference" href="#pip" id="id14">[7]</a> installer</li>
<li>the Fedora packagers <a class="footnote-reference" href="#fedora" id="id15">[11]</a>.</li>
<li>the Debian packagers <a class="footnote-reference" href="#debian" id="id16">[12]</a>.</li>
</ul>
</div>
<div class="section" id="id17">
<h2>アンインストールの情報<a class="headerlink" href="#id17" title="Permalink to this headline"></a></h2>
<p>Distutils doesn&#8217;t provide an <cite>uninstall</cite> command. If you want to uninstall
a distribution, you have to be a power user and remove the various elements
that were installed, and then look over the <cite>.pth</cite> file to clean them if
necessary.</p>
<p>Distutils は、 <cite>uninstall</cite> コマンドを提供していない。
もし、配布物をアンインストールしたければ、権限のあるユーザーになり、
インストールした内容を削除する。
そして、必要であれば <cite>.pth</cite> ファイルを整理しなければならない。</p>
<p>And the process differs depending on the tools you have used to install the
distribution and if the distribution&#8217;s <cite>setup.py</cite> uses Distutils or
Setuptools.</p>
<p>さらに、このプロセスは、配布物をインストールするのに使用したツール、
配布物が <cite>setup.py</cite> がDistuitlsとSetuptoolsのどちらを使用しているのかによって異なる。</p>
<p>Under some circumstances, you might not be able to know for sure that you
have removed everything, or that you didn&#8217;t break another distribution by
removing a file that is shared among several distributions.</p>
<p>環境の状況によっては、
すべてを削除しきれたのか、複数の配布物から必要とされているような配布物を削除してしまわないか、
という確信が持てないことだろう。</p>
<p>But there&#8217;s a common behavior: when you install a distribution, files are
copied in your system. And it&#8217;s possible to keep track of these files for
later removal.</p>
<p>しかし、共通しているのは、配布物をインストールしたとき、ファイルはシステム中にコピーされることである。
後から削除できるように、これらを記録することは可能である。</p>
<p>Moreover, the Pip project has gained an <cite>uninstall</cite> feature lately. It
records all installed files, using the <cite>record</cite> option of the <cite>install</cite>
command.</p>
<p>加えて、 Pip プロジェクトでは、 <cite>uninstall</cite> 機能が追加された。
これは、`install` コマンドの <cite>record</cite> オプションを使うことで、インストールされたすべてのファイルを記録している。</p>
</div>
<div class="section" id="pep">
<h2>このPEPでの提案<a class="headerlink" href="#pep" title="Permalink to this headline"></a></h2>
<p>To address those issues, this PEP proposes a few changes:</p>
<ul class="simple">
<li>A new <cite>.dist-info</cite> structure using a directory, inspired on one format of
the <cite>EggFormats</cite> standard from <cite>setuptools</cite>.</li>
<li>New APIs in <cite>pkgutil</cite> to be able to query the information of installed
distributions.</li>
<li>An uninstall function and an uninstall script in Distutils.</li>
</ul>
<p>これらの問題を解決するため、このPEPでは、以下の内容を提案する:</p>
<ul class="simple">
<li>新たな <cite>.dist-info</cite> 構造のディレクトリ。
これは、 <cite>setuptools</cite><cite>EggFormats</cite> 標準のフォーマットをもとにしている。</li>
<li>インストールされた配布物の情報を取得する新しいAPIを <cite>pkgutil</cite> に追加する。</li>
<li>アンインストール機能と、アンインストールスクリプトをDistutilsに追加する。</li>
</ul>
</div>
</div>
<div class="section" id="dist-info">
<h1>インストールされた配布物ごとの .dist-info ディレクトリ<a class="headerlink" href="#dist-info" title="Permalink to this headline"></a></h1>
<p>This PEP proposes an installation format inspired by one of the options in the
<cite>EggFormats</cite> standard, the one that uses a distinct directory located in the
site-packages directory.</p>
<p>このPEPでは <cite>EggFormats</cite> をもとにした、インストールフォーマットを提案する。
このフォーマットは、site-packages ディレクトリ中の固有のディレクトリを使用する。</p>
<p>This distinct directory is named as follows:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">name</span> <span class="o">+</span> <span class="s">&#39;-&#39;</span> <span class="o">+</span> <span class="n">version</span> <span class="o">+</span> <span class="s">&#39;.dist-info&#39;</span>
</pre></div>
</div>
<p>固有のディレクトリは以下のように名前づけされる:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">name</span> <span class="o">+</span> <span class="s">&#39;-&#39;</span> <span class="o">+</span> <span class="n">version</span> <span class="o">+</span> <span class="s">&#39;.dist-info&#39;</span>
</pre></div>
</div>
<p>This <cite>.dist-info</cite> directory can contain these files:</p>
<ul>
<li><p class="first"><cite>METADATA</cite>: contains metadata, as described in PEP 345, PEP 314 and PEP 241.</p>
</li>
<li><p class="first"><cite>RECORD</cite>: records the list of installed files</p>
</li>
<li><p class="first"><cite>INSTALLER</cite>: records the name of the tool used to install the project</p>
</li>
<li><dl class="first docutils">
<dt><cite>REQUESTED</cite>: the presence of this file indicates that the project</dt>
<dd><p class="first last">installation was explicitly requested (i.e., not installed as a dependency).</p>
</dd>
</dl>
</li>
</ul>
<p>この <cite>.dist-info</cite> ディレクトリは、いかのファイルを含むことができる:</p>
<div class="highlight-python"><pre>- `METADATA`: PEP345, PEP314 と PEP241 で定義されているメタデータを含む
- `RECORD`: インストールしたファイル一覧を記録する
- `INSTALLER`: インストールに使用したツールの名前を記録する
- `REQUESTED`: このファイルの存在は、明示的にインストールされたことを示す。(依存関係の結果インストールされたのではない)</pre>
</div>
<p>The METADATA, RECORD and INSTALLER files are mandatory, while REQUESTED may
be missing.</p>
<p>METADATA, RECORD と INSTALLER ファイルは必須である。一方、 REQUESTED は、存在しないこともある。</p>
<p>This proposal will not impact Python itself because the metadata files are not
used anywhere yet in the standard library besides Distutils.</p>
<p>この提案はPython自身には影響を与えない。
なぜなら、メタデータファイルはまだDistutilsなどの標準ライブラリで取り扱っていないからである。</p>
<p>It will impact the <cite>setuptools</cite> and <cite>pip</cite> projects but, given the fact that
they already work with a directory that contains a <cite>PKG-INFO</cite> file, the change
will have no deep consequences.</p>
<p><cite>setuptools</cite><cite>pip</cite> には影響を与えることになる。
だが、実際には、すでに <cite>PKG-INFO</cite> ファイルを含むディレクトリで動作しているため、
この変更は大きな影響とならないであろう。</p>
<div class="section" id="record">
<h2>RECORD<a class="headerlink" href="#record" title="Permalink to this headline"></a></h2>
<p>A <cite>RECORD</cite> file is added inside the <cite>.dist-info</cite> directory at installation
time when installing a source distribution using the <cite>install</cite> command.
Notice that when installing a binary distribution created with <cite>bdist</cite> command
or a <cite>bdist</cite>-based command, the <cite>RECORD</cite> file will be installed as well since
these commands use the <cite>install</cite> command to create binary distributions.</p>
<p><cite>RECORD</cite> ファイルは、`install` コマンドを利用したソースディストリビューションの
インストール時に <cite>.dist-info</cite> ディレクトリ内に含まれる。
注意店として、 <cite>bdist</cite> コマンドや、 その他の <cite>bdist</cite>-based コマンドでも、
<cite>RECORD</cite> ファイルは作られる。
これらのコマンドは、配布物作成時に、 <cite>install</cite> コマンドを利用するからである。</p>
<p>The <cite>RECORD</cite> file holds the list of installed files. These correspond
to the files listed by the <cite>record</cite> option of the <cite>install</cite> command, and will
be generated by default. This allows the implementation of an uninstallation
feature, as explained later in this PEP. The <cite>install</cite> command also provides
an option to prevent the <cite>RECORD</cite> file from being written and this option
should be used when creating system packages.</p>
<p><cite>RECORD</cite> ファイルは、インストールされたファイル一覧を持っている。
これらは、 <cite>install</cite> コマンドの <cite>record</cite> オプションに相当し、
デフォルトで生成されるようになる。
これにより、後述するアンインストール機能の実装が可能。
<cite>install</cite> コマンドは、 <cite>RECORD</cite> ファイルを作成しないオプションも提供する。
このオプションは、システムパッケージを作成するときに利用される。</p>
<p>Third-party installation tools also should not overwrite or delete files
that are not in a RECORD file without prompting or warning.</p>
<p>サードパーティ製のインストールツールは、RECORDE ファイルを確認や警告なしで、削除、上書きをすべきでない。</p>
<p>This RECORD file is inspired from PEP 262 FILES <a class="footnote-reference" href="#pep262" id="id18">[3]</a>.</p>
<p>RECORD ファイルは、 PEP262 FILES <a class="footnote-reference" href="#pep262" id="id19">[3]</a> を基にしている。</p>
<p>The <cite>RECORD</cite> file is a CSV file, composed of records, one line per
installed file. The <tt class="docutils literal"><span class="pre">csv</span></tt> module is used to read the file, with
these options:</p>
<ul class="simple">
<li>field delimiter : <cite>,</cite></li>
<li>quoting char :  <cite>&#8220;</cite>.</li>
<li>line terminator : <tt class="docutils literal"><span class="pre">os.linesep</span></tt> (so <tt class="docutils literal"><span class="pre">\r\n</span></tt> or <tt class="docutils literal"><span class="pre">\n</span></tt>)</li>
</ul>
<p><cite>RECORD</cite> ファイルは、1行で1インストールファイルを構成するCSVファイルである。
<tt class="docutils literal"><span class="pre">csv</span></tt> モジュールが以下のオプションとともにファイル読み取りに使われる。:</p>
<ul class="simple">
<li>列区切り: <cite>,</cite></li>
<li>引用符: <cite>&#8220;</cite></li>
<li>行区切り: <tt class="docutils literal"><span class="pre">os.linesep</span></tt> (so <tt class="docutils literal"><span class="pre">\r\n</span></tt> or <tt class="docutils literal"><span class="pre">\n</span></tt> )</li>
</ul>
<p>When a distribution is installed, files can be installed under:</p>
<ul class="simple">
<li>the <strong>base location</strong>: path defined by the <tt class="docutils literal"><span class="pre">--install-lib</span></tt> option,
which defaults to the site-packages directory.</li>
<li>the <strong>installation prefix</strong>: path defined by the <tt class="docutils literal"><span class="pre">--prefix</span></tt> option, which
defaults to <tt class="docutils literal"><span class="pre">sys.prefix</span></tt>.</li>
<li>any other path on the system.</li>
</ul>
<p>配布物がインストールされるとき、これらのファイルは以下の場所にインストールされる:</p>
<div class="highlight-python"><pre>- ** ベースディレクトリ ** : ``--install-lib`` オプションで決定される。デフォルトは、site-packagesディレクトリ
- ** インストール先(prefix) ** : ``--prefix`` オプションで決定される。デフォルトは、 ``sys.path`` ディレクトリ
- その他のシステム上のパス</pre>
</div>
<p>Each record is composed of three elements:</p>
<ul class="simple">
<li>the file&#8217;s <strong>path</strong><ul>
<li>a &#8216;/&#8217;-separated path, relative to the <strong>base location</strong>, if the file is
under the <strong>base location</strong>.</li>
<li>a &#8216;/&#8217;-separated path, relative to the <strong>base location</strong>, if the file
is under the  <strong>installation prefix</strong> AND if the <strong>base location</strong> is a
subpath of the <strong>installation prefix</strong>.</li>
<li>an absolute path, using the local platform separator</li>
</ul>
</li>
<li>the <strong>MD5</strong> hash of the file, encoded in hex. Notice that <cite>pyc</cite> and <cite>pyo</cite>
generated files don&#8217;t have any hash because they are automatically produced
from <cite>py</cite> files. So checking the hash of the corresponding <cite>py</cite> file is
enough to decide if the file and its associated <cite>pyc</cite> or <cite>pyo</cite> files have
changed.</li>
<li>the file&#8217;s size in bytes</li>
</ul>
<p>各レコードは、以下の3要素で構成される。:</p>
<div class="highlight-python"><pre>- ファイルの ** パス **</pre>
</div>
<blockquote>
<ul class="simple">
<li>&#8216;/&#8217;で区切られたパス。 ** ベースディレクトリ ** にインストールされた場合は、 ** ベースディレクトリ ** からの相対パス</li>
<li>&#8216;/&#8217; で区切られたパス。 <strong>インストール先</strong> にインストールされ、 ** ベースディレクトリ** が  <strong>インストール先</strong> のサブディレクトリの場合は、
** ベースディレクトリ** からの相対パス</li>
<li>絶対パス。 システムローカルの区切り文字を使う</li>
</ul>
</blockquote>
<ul class="simple">
<li>ファイルの <strong>MD5</strong> ハッシュの16進表記。
注意点として、 <cite>pyc</cite><cite>pyo</cite> の生成されるファイルは、ハッシュを持たない。
これらは、 <cite>py</cite> ファイルから自動生成されるからである。
<cite>pyc</cite><cite>pyo</cite> ファイルの更新を確認するのは、 <cite>py</cite> ファイルのハッシュをチェックすれば十分である。</li>
</ul>
<p>The <tt class="docutils literal"><span class="pre">csv</span></tt> module is used to generate this file, so the field separator is
&#8220;,&#8221;. Any &#8220;,&#8221; character found within a field is escaped automatically by
<tt class="docutils literal"><span class="pre">csv</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">csv</span></tt> モジュールが、このファイルを生成するのに使われる。
そして、行の区切りは、&#8221;,&#8221; である。
&#8220;,&#8221; 文字がフィールド中に存在する場合は、 <tt class="docutils literal"><span class="pre">csv</span></tt> モジュールで自動的にエスケープされる。</p>
<p>When the file is read, the <cite>U</cite> option is used so the universal newline
support (see PEP 278 <a class="footnote-reference" href="#pep278" id="id20">[10]</a>) is activated, avoiding any trouble
reading a file produced on a platform that uses a different new line
terminator.</p>
<p>ファイルが読み込まれるとき、 <cite>U</cite> オプションにより、一般的な改行サポート(see PEP 278 <a class="footnote-reference" href="#pep278" id="id21">[10]</a>)が適用される。
これにより、プラットフォームごとに異なる改行コードによって引き起こされるトラブルを回避する。</p>
<p>Here&#8217;s an example of a RECORD file (extract):</p>
<div class="highlight-python"><pre>lib/python2.6/site-packages/docutils/__init__.py,b690274f621402dda63bf11ba5373bf2,9544
lib/python2.6/site-packages/docutils/__init__.pyc,,
lib/python2.6/site-packages/docutils/core.py,9c4b84aff68aa55f2e9bf70481b94333,66188
lib/python2.6/site-packages/docutils/core.pyc,,
lib/python2.6/site-packages/roman.py,a4b84aff68aa55f2e9bf70481b943D3,234
lib/python2.6/site-packages/roman.pyc,,
/usr/local/bin/rst2html.py,a4b84aff68aa55f2e9bf70481b943D3,234
/usr/local/bin/rst2html.pyc,,
python2.6/site-packages/docutils-0.5.dist-info/METADATA,6fe57de576d749536082d8e205b77748,195
lib/python2.6/site-packages/docutils-0.5.dist-info/RECORD,,</pre>
</div>
<p>RECORDファイルの例</p>
<div class="highlight-python"><pre>lib/python2.6/site-packages/docutils/__init__.py,b690274f621402dda63bf11ba5373bf2,9544
lib/python2.6/site-packages/docutils/__init__.pyc,,
lib/python2.6/site-packages/docutils/core.py,9c4b84aff68aa55f2e9bf70481b94333,66188
lib/python2.6/site-packages/docutils/core.pyc,,
lib/python2.6/site-packages/roman.py,a4b84aff68aa55f2e9bf70481b943D3,234
lib/python2.6/site-packages/roman.pyc,,
/usr/local/bin/rst2html.py,a4b84aff68aa55f2e9bf70481b943D3,234
/usr/local/bin/rst2html.pyc,,
python2.6/site-packages/docutils-0.5.dist-info/METADATA,6fe57de576d749536082d8e205b77748,195
lib/python2.6/site-packages/docutils-0.5.dist-info/RECORD,,</pre>
</div>
<p>Notice that the <cite>RECORD</cite> file can&#8217;t contain a hash of itself and is just mentioned here</p>
<p>注意点として、 <cite>RECORD</cite> ファイル自身と、これから言及するファイルは、ハッシュ値を持たない。</p>
<p>A project that installs a <cite>config.ini</cite> file in <cite>/etc/myapp</cite> will be added like this:</p>
<div class="highlight-python"><pre>/etc/myapp/config.ini,b690274f621402dda63bf11ba5373bf2,9544</pre>
</div>
<p>プロジェクトが <cite>config.ini</cite> ファイルを <cite>/etc/myapp</cite> にインストールする場合は、以下のような行が追加される</p>
<div class="highlight-python"><pre>/etc/myapp/config.ini,b690274f621402dda63bf11ba5373bf2,9544</pre>
</div>
<p>For a windows platform, the drive letter is added for the absolute paths,
so a file that is copied in c:MyAppwill be:</p>
<div class="highlight-python"><pre>c:\etc\myapp\config.ini,b690274f621402dda63bf11ba5373bf2,9544</pre>
</div>
<p>Windows プラットフォームでは、絶対パスにドライブレターが追加される。
つまり、 c:MyAppにコピーされる場合は、以下のようになる</p>
<div class="highlight-python"><pre>c:\etc\myapp\config.ini,b690274f621402dda63bf11ba5373bf2,9544</pre>
</div>
</div>
<div class="section" id="installer">
<h2>INSTALLER<a class="headerlink" href="#installer" title="Permalink to this headline"></a></h2>
<p>The <cite>install</cite> command has a new option called <cite>installer</cite>. This option
is the name of the tool used to invoke the installation. It&#8217;s an normalized
lower-case string matching <cite>[a-z0-9_-.]</cite>.</p>
<p><cite>install</cite> コマンドは新しいオプションの <cite>installer</cite> を持つ。
このオプションはインストールに使われたツールの名前を指定する。
これは、 <cite>[a-z0-9_-.]</cite> にマッチするように正規化される。</p>
<blockquote>
$ python setup.py install &#8211;installer=pkg-system</blockquote>
<p>It defaults to <cite>distutils</cite> if not provided.</p>
<p>指定がない場合は、 <cite>distutils</cite> がデフォルト値となる。</p>
<p>When a distribution is installed, the INSTALLER file is generated in the
<cite>.dist-info</cite> directory with this value, to keep track of <strong>who</strong> installed the
distribution. The file is a single-line text file.</p>
<p>配布物がインストールされるとき、 <strong>誰が</strong> インストールしたのかを記録するために、INSTALLER ファイルが、 <cite>.dist-info</cite> ディレクトリに生成される。
このファイルは一行からなるファイルである。</p>
</div>
<div class="section" id="requested">
<h2>REQUESTED<a class="headerlink" href="#requested" title="Permalink to this headline"></a></h2>
<p>Some install tools automatically detect unfulfilled dependencies and
install them. In these cases, it is useful to track which
distributions were installed purely as a dependency, so if their
dependent distribution is later uninstalled, the user can be alerted
of the orphaned dependency.</p>
<p>ツールによっては、自動的に足りない依存性を検出して、それらをインストールする。
こういった場合、その配布物が、純粋に依存のためだけにインストールされたことを記録しておくのは非常に有益になる。
後々、その依存している配布物がアンインストールされるときに、ユーザーに依存性が破壊されることを通知できる。</p>
<p>If a distribution is installed by direct user request (the usual
case), a file REQUESTED is added to the .dist-info directory of the
installed distribution. The REQUESTED file may be empty, or may
contain a marker comment line beginning with the &#8220;#&#8221; character.</p>
<p>配布物が直接ユーザーの要求によりインストールされる場合は、 REQUESTED ファイルが 配布物の .dist-info ディレクトリに作成される。
REQUESTED ファイルは空のファイルか、 &#8220;#&#8221; で始まるコメントを含むファイルとなる。</p>
<p>If an install tool installs a distribution automatically, as a
dependency of another distribution, the REQUESTED file should not be
created.</p>
<p>インストールツールが依存性解決のために自動的にインストールする場合は、 REQUESTED ファイルは作成されるべきではない。</p>
<p>The <tt class="docutils literal"><span class="pre">install</span></tt> command of distutils by default creates the REQUESTED
file. It accepts <tt class="docutils literal"><span class="pre">--requested</span></tt> and <tt class="docutils literal"><span class="pre">--no-requested</span></tt> options to explicitly
specify whether the file is created.</p>
<p>distutils の <tt class="docutils literal"><span class="pre">install</span></tt> コマンドは、でフォルトで REQESTED ファイルを作成する。
<tt class="docutils literal"><span class="pre">--requested</span></tt><tt class="docutils literal"><span class="pre">--no-requested</span></tt> オプションは明示的に、ファイル生成するかどうかを指定する。</p>
<p>If a distribution that was already installed on the system as a dependency
is later installed by name, the distutils <tt class="docutils literal"><span class="pre">install</span></tt> command will
create the REQUESTED file in the .dist-info directory of the existing
installation.</p>
<p>配布物が依存性の結果として既にインストールされていた場合、 distutilsの <tt class="docutils literal"><span class="pre">install</span></tt> コマンドは、 REQUESTED ファイルを、インストールされて既に存在している .dist-info ディレクトリに作成する。</p>
</div>
</div>
<div class="section" id="implementation-details">
<h1>Implementation details<a class="headerlink" href="#implementation-details" title="Permalink to this headline"></a></h1>
<div class="section" id="new-functions-and-classes-in-pkgutil">
<h2>New functions and classes in pkgutil<a class="headerlink" href="#new-functions-and-classes-in-pkgutil" title="Permalink to this headline"></a></h2>
<p>To use the <cite>.dist-info</cite> directory content, we need to add in the standard
library a set of APIs. The best place to put these APIs is <cite>pkgutil</cite>.</p>
<div class="section" id="functions">
<h3>Functions<a class="headerlink" href="#functions" title="Permalink to this headline"></a></h3>
<p>The new functions added in the <tt class="docutils literal"><span class="pre">pkgutil</span></tt> module are :</p>
<ul>
<li><p class="first"><tt class="docutils literal"><span class="pre">distinfo_dirname(name,</span> <span class="pre">version)</span></tt> -&gt; directory name</p>
<blockquote>
<p><tt class="docutils literal"><span class="pre">name</span></tt> is converted to a standard distribution name by replacing any
runs of non-alphanumeric characters with a single &#8216;-&#8216;.</p>
<p><tt class="docutils literal"><span class="pre">version</span></tt> is converted to a standard version string. Spaces become
dots, and all other non-alphanumeric characters (except dots) become
dashes, with runs of multiple dashes condensed to a single dash.</p>
<p>Both attributes are then converted into their filename-escaped form,
i.e. any &#8216;-&#8216; characters are replaced with &#8216;_&#8217; other than the one in
&#8216;dist-info&#8217; and the one separating the name from the version number.</p>
</blockquote>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">get_distributions()</span></tt> -&gt; iterator of <tt class="docutils literal"><span class="pre">Distribution</span></tt> instances.</p>
<p>Provides an iterator that looks for <tt class="docutils literal"><span class="pre">.dist-info</span></tt> directories in
<tt class="docutils literal"><span class="pre">sys.path</span></tt> and returns <tt class="docutils literal"><span class="pre">Distribution</span></tt> instances for
each one of them.</p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">get_distribution(name)</span></tt> -&gt; <tt class="docutils literal"><span class="pre">Distribution</span></tt> or None.</p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">obsoletes_distribution(name,</span> <span class="pre">version=None)</span></tt> -&gt; iterator of <tt class="docutils literal"><span class="pre">Distribution</span></tt>
instances.</p>
<p>Iterates over all distributions to find which distributions <em>obsolete</em>
<tt class="docutils literal"><span class="pre">name</span></tt>. If a <tt class="docutils literal"><span class="pre">version</span></tt> is provided, it will be used to filter the results.</p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">provides_distribution(name,</span> <span class="pre">version=None)</span></tt> -&gt; iterator of <tt class="docutils literal"><span class="pre">Distribution</span></tt>
instances.</p>
<p>Iterates over all distributions to find which distributions <em>provide</em>
<tt class="docutils literal"><span class="pre">name</span></tt>. If a <tt class="docutils literal"><span class="pre">version</span></tt> is provided, it will be used to filter the results.
Scans all elements in <tt class="docutils literal"><span class="pre">sys.path</span></tt> and looks for all directories ending with
<tt class="docutils literal"><span class="pre">.dist-info</span></tt>. Returns a <tt class="docutils literal"><span class="pre">Distribution</span></tt> corresponding to the
<tt class="docutils literal"><span class="pre">.dist-info</span></tt> directory that contains a METADATA that matches <cite>name</cite>
for the <cite>name</cite> metadata.</p>
<p>This function only returns the first result founded, since no more than one
values are expected. If the directory is not found, returns None.</p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">get_file_users(path)</span></tt> -&gt; iterator of <tt class="docutils literal"><span class="pre">Distribution</span></tt> instances.</p>
<p>Iterates over all distributions to find out which distributions uses <tt class="docutils literal"><span class="pre">path</span></tt>.
<tt class="docutils literal"><span class="pre">path</span></tt> can be a local absolute path or a relative &#8216;/&#8217;-separated path.</p>
<p>A local absolute path is an absolute path in which occurrences of &#8216;/&#8217;
have been replaced by the system separator given by <tt class="docutils literal"><span class="pre">os.sep</span></tt>.</p>
</li>
</ul>
</div>
<div class="section" id="distribution-class">
<h3>Distribution class<a class="headerlink" href="#distribution-class" title="Permalink to this headline"></a></h3>
<p>A new class called <tt class="docutils literal"><span class="pre">Distribution</span></tt> is created with the path of the
<cite>.dist-info</cite> directory provided to the constructor. It reads the metadata
contained in <cite>METADATA</cite> when it is instantiated.</p>
<p><tt class="docutils literal"><span class="pre">Distribution(path)</span></tt> -&gt; instance</p>
<blockquote>
Creates a <tt class="docutils literal"><span class="pre">Distribution</span></tt> instance for the given <tt class="docutils literal"><span class="pre">path</span></tt>.</blockquote>
<p><tt class="docutils literal"><span class="pre">Distribution</span></tt> provides the following attributes:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">name</span></tt>: The name of the distribution.</li>
<li><tt class="docutils literal"><span class="pre">metadata</span></tt>: A <tt class="docutils literal"><span class="pre">DistributionMetadata</span></tt> instance loaded with the
distribution&#8217;s METADATA file.</li>
<li><tt class="docutils literal"><span class="pre">requested</span></tt>: A boolean that indicates whether the REQUESTED
metadata file is present (in other words, whether the distribution was
installed by user request).</li>
</ul>
<p>And following methods:</p>
<ul>
<li><p class="first"><tt class="docutils literal"><span class="pre">get_installed_files(local=False)</span></tt> -&gt; iterator of (path, md5, size)</p>
<p>Iterates over the <cite>RECORD</cite> entries and return a tuple <tt class="docutils literal"><span class="pre">(path,</span> <span class="pre">md5,</span> <span class="pre">size)</span></tt>
for each line. If <tt class="docutils literal"><span class="pre">local</span></tt> is <tt class="xref docutils literal"><span class="pre">True</span></tt>, the path is transformed into a
local absolute path. Otherwise the raw value from <cite>RECORD</cite> is returned.</p>
<p>A local absolute path is an absolute path in which occurrences of &#8216;/&#8217;
have been replaced by the system separator given by <tt class="docutils literal"><span class="pre">os.sep</span></tt>.</p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">uses(path)</span></tt> -&gt; Boolean</p>
<p>Returns <tt class="xref docutils literal"><span class="pre">True</span></tt> if <tt class="docutils literal"><span class="pre">path</span></tt> is listed in <cite>RECORD</cite>. <tt class="docutils literal"><span class="pre">path</span></tt>
can be a local absolute path or a relative &#8216;/&#8217;-separated path.</p>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">get_distinfo_file(path,</span> <span class="pre">binary=False)</span></tt> -&gt; file object</p>
<blockquote>
<p>Returns a file located under the <cite>.dist-info</cite> directory.</p>
<p>Returns a <tt class="docutils literal"><span class="pre">file</span></tt> instance for the file pointed by <tt class="docutils literal"><span class="pre">path</span></tt>.</p>
<p><tt class="docutils literal"><span class="pre">path</span></tt> has to be a &#8216;/&#8217;-separated path relative to the <cite>.dist-info</cite>
directory or an absolute path.</p>
<p>If <tt class="docutils literal"><span class="pre">path</span></tt> is an absolute path and doesn&#8217;t start with the <cite>.dist-info</cite>
directory path, a <tt class="docutils literal"><span class="pre">DistutilsError</span></tt> is raised.</p>
<p>If <tt class="docutils literal"><span class="pre">binary</span></tt> is <tt class="xref docutils literal"><span class="pre">True</span></tt>, opens the file in read-only binary mode (<cite>rb</cite>),
otherwise opens it in read-only mode (<cite>r</cite>).</p>
</blockquote>
</li>
<li><p class="first"><tt class="docutils literal"><span class="pre">get_distinfo_files(local=False)</span></tt> -&gt; iterator of paths</p>
<p>Iterates over the <cite>RECORD</cite> entries and returns paths for each line if the path
is pointing to a file located in the <cite>.dist-info</cite> directory or one of its
subdirectories.</p>
<p>If <tt class="docutils literal"><span class="pre">local</span></tt> is <tt class="xref docutils literal"><span class="pre">True</span></tt>, each path is transformed into a
local absolute path. Otherwise the raw value from <cite>RECORD</cite> is returned.</p>
</li>
</ul>
<p>Notice that the API is organized in five classes that work with directories
and Zip files (so it works with files included in Zip files, see PEP 273 for
more details <a class="footnote-reference" href="#pep273" id="id22">[9]</a>). These classes are described in the documentation
of the prototype implementation for interested readers <a class="footnote-reference" href="#prototype" id="id23">[13]</a>.</p>
</div>
<div class="section" id="examples">
<h3>Examples<a class="headerlink" href="#examples" title="Permalink to this headline"></a></h3>
<p>Let&#8217;s use some of the new APIs with our <cite>docutils</cite> example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pkgutil</span> <span class="kn">import</span> <span class="n">get_distribution</span><span class="p">,</span> <span class="n">get_file_users</span><span class="p">,</span> <span class="n">distinfo_dirname</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dist</span> <span class="o">=</span> <span class="n">get_distribution</span><span class="p">(</span><span class="s">&#39;docutils&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dist</span><span class="o">.</span><span class="n">name</span>
<span class="go">&#39;docutils&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">dist</span><span class="o">.</span><span class="n">metadata</span><span class="o">.</span><span class="n">version</span>
<span class="go">&#39;0.5&#39;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">distinfo_dirname</span><span class="p">(</span><span class="s">&#39;docutils&#39;</span><span class="p">,</span> <span class="s">&#39;0.5&#39;</span><span class="p">)</span>
<span class="go">&#39;docutils-0.5.dist-info&#39;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">distinfo_dirname</span><span class="p">(</span><span class="s">&#39;python-ldap&#39;</span><span class="p">,</span> <span class="s">&#39;2.5&#39;</span><span class="p">)</span>
<span class="go">&#39;python_ldap-2.5.dist-info&#39;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">distinfo_dirname</span><span class="p">(</span><span class="s">&#39;python-ldap&#39;</span><span class="p">,</span> <span class="s">&#39;2.5 a---5&#39;</span><span class="p">)</span>
<span class="go">&#39;python_ldap-2.5.a_5.dist-info&#39;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="k">for</span> <span class="n">path</span><span class="p">,</span> <span class="nb">hash</span><span class="p">,</span> <span class="n">size</span> <span class="ow">in</span> <span class="n">dist</span><span class="o">.</span><span class="n">get_installed_files</span><span class="p">()::</span>
<span class="gp">... </span>    <span class="k">print</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s"> </span><span class="si">%s</span><span class="s"> </span><span class="si">%d</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="nb">hash</span><span class="p">,</span> <span class="n">size</span><span class="p">)</span>
<span class="gp">...</span>
<span class="go">python2.6/site-packages/docutils/__init__.py,b690274f621402dda63bf11ba5373bf2,9544</span>
<span class="go">python2.6/site-packages/docutils/core.py,9c4b84aff68aa55f2e9bf70481b94333,66188</span>
<span class="go">python2.6/site-packages/roman.py,a4b84aff68aa55f2e9bf70481b943D3,234</span>
<span class="go">/usr/local/bin/rst2html.py,a4b84aff68aa55f2e9bf70481b943D3,234</span>
<span class="go">python2.6/site-packages/docutils-0.5.dist-info/METADATA,6fe57de576d749536082d8e205b77748,195</span>
<span class="go">python2.6/site-packages/docutils-0.5.dist-info/RECORD</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">dist</span><span class="o">.</span><span class="n">uses</span><span class="p">(</span><span class="s">&#39;docutils/core.py&#39;</span><span class="p">)</span>
<span class="go">True</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">dist</span><span class="o">.</span><span class="n">uses</span><span class="p">(</span><span class="s">&#39;/usr/local/bin/rst2html.py&#39;</span><span class="p">)</span>
<span class="go">True</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">dist</span><span class="o">.</span><span class="n">get_distinfo_file</span><span class="p">(</span><span class="s">&#39;METADATA&#39;</span><span class="p">)</span>
<span class="go">&lt;open file at ...&gt;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">dist</span><span class="o">.</span><span class="n">requested</span>
<span class="go">True</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="new-functions-in-distutils">
<h2>New functions in Distutils<a class="headerlink" href="#new-functions-in-distutils" title="Permalink to this headline"></a></h2>
<p>Distutils already provides a very basic way to install a distribution, which
is running the <cite>install</cite> command over the <cite>setup.py</cite> script of the
distribution.</p>
<p>Distutils2 <a class="footnote-reference" href="#pep262" id="id24">[3]</a> will provide a very basic <tt class="docutils literal"><span class="pre">uninstall</span></tt> function, that
is added in <tt class="docutils literal"><span class="pre">distutils2.util</span></tt> and takes the name of the distribution to
uninstall as its argument. <tt class="docutils literal"><span class="pre">uninstall</span></tt> uses the APIs described earlier and
remove all unique files, as long as their hash didn&#8217;t change. Then it removes
empty directories left behind.</p>
<p><tt class="docutils literal"><span class="pre">uninstall</span></tt> returns a list of uninstalled files:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">distutils2.util</span> <span class="kn">import</span> <span class="n">uninstall</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">uninstall</span><span class="p">(</span><span class="s">&#39;docutils&#39;</span><span class="p">)</span>
<span class="go">[&#39;/opt/local/lib/python2.6/site-packages/docutils/core.py&#39;,</span>
<span class="go"> ...</span>
<span class="go"> &#39;/opt/local/lib/python2.6/site-packages/docutils/__init__.py&#39;]</span>
</pre></div>
</div>
<p>If the distribution is not found, a <tt class="docutils literal"><span class="pre">DistutilsUninstallError</span></tt> is raised.</p>
<div class="section" id="filtering">
<h3>Filtering<a class="headerlink" href="#filtering" title="Permalink to this headline"></a></h3>
<p>To make it a reference API for third-party projects that wish to control
how <cite>uninstall</cite> works, a second callable argument can be used. It&#8217;s
called for each file that is removed. If the callable returns <cite>True</cite>, the
file is removed. If it returns False, it&#8217;s left alone.</p>
<p>Examples:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">_remove_and_log</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;Removing </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">path</span><span class="p">)</span>
<span class="gp">... </span>    <span class="k">return</span> <span class="bp">True</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">uninstall</span><span class="p">(</span><span class="s">&#39;docutils&#39;</span><span class="p">,</span> <span class="n">_remove_and_log</span><span class="p">)</span>

<span class="gp">&gt;&gt;&gt; </span><span class="k">def</span> <span class="nf">_dry_run</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
<span class="gp">... </span>    <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s">&#39;Removing </span><span class="si">%s</span><span class="s"> (dry run)&#39;</span> <span class="o">%</span> <span class="n">path</span><span class="p">)</span>
<span class="gp">... </span>    <span class="k">return</span> <span class="bp">False</span>
<span class="gp">...</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">uninstall</span><span class="p">(</span><span class="s">&#39;docutils&#39;</span><span class="p">,</span> <span class="n">_dry_run</span><span class="p">)</span>
</pre></div>
</div>
<p>Of course, a third-party tool can use lower-level <tt class="docutils literal"><span class="pre">pkgutil</span></tt> APIs to
implement its own uninstall feature.</p>
</div>
<div class="section" id="installer-marker">
<h3>Installer marker<a class="headerlink" href="#installer-marker" title="Permalink to this headline"></a></h3>
<p>As explained earlier in this PEP, the <cite>install</cite> command adds an <cite>INSTALLER</cite>
file in the <cite>.dist-info</cite> directory with the name of the installer.</p>
<p>To avoid removing distributions that were installed by another packaging
system, the <tt class="docutils literal"><span class="pre">uninstall</span></tt> function takes an extra argument <tt class="docutils literal"><span class="pre">installer</span></tt> which
defaults to <tt class="docutils literal"><span class="pre">distutils2</span></tt>.</p>
<p>When called, <tt class="docutils literal"><span class="pre">uninstall</span></tt> controls that the <tt class="docutils literal"><span class="pre">INSTALLER</span></tt> file matches
this argument. If not, it raises a <tt class="docutils literal"><span class="pre">DistutilsUninstallError</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">uninstall</span><span class="p">(</span><span class="s">&#39;docutils&#39;</span><span class="p">)</span>
<span class="gt">Traceback (most recent call last):</span>
<span class="c">...</span>
<span class="nc">DistutilsUninstallError</span>: <span class="n-Identifier">docutils was installed by &#39;cool-pkg-manager&#39;</span>

<span class="gp">&gt;&gt;&gt; </span><span class="n">uninstall</span><span class="p">(</span><span class="s">&#39;docutils&#39;</span><span class="p">,</span> <span class="n">installer</span><span class="o">=</span><span class="s">&#39;cool-pkg-manager&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>This allows a third-party application to use the <tt class="docutils literal"><span class="pre">uninstall</span></tt> function
and strongly suggest that no other program remove a distribution it has
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.</p>
</div>
<div class="section" id="adding-an-uninstall-script">
<h3>Adding an Uninstall script<a class="headerlink" href="#adding-an-uninstall-script" title="Permalink to this headline"></a></h3>
<p>An <cite>uninstall</cite> script is added in Distutils2. and is used like this:</p>
<div class="highlight-python"><pre>$ python -m distutils2.uninstall projectname</pre>
</div>
<p>Notice that script doesn&#8217;t control if the removal of a distribution breaks
another distribution. Although it makes sure that all the files it removes
are not used by any other distribution, by using the uninstall function.</p>
<p>Also note that this uninstall script pays no attention to the
REQUESTED metadata; that is provided only for use by external tools to
provide more advanced dependency management.</p>
</div>
</div>
</div>
<div class="section" id="backward-compatibility-and-roadmap">
<h1>Backward compatibility and roadmap<a class="headerlink" href="#backward-compatibility-and-roadmap" title="Permalink to this headline"></a></h1>
<p>These changes don&#8217;t introduce any compatibility problems since they
will be implemented in:</p>
<ul class="simple">
<li>pkgutil in new functions</li>
<li>distutils2</li>
</ul>
<p>The plan is to include the functionality outlined in this PEP in pkgutil for
Python 3.2, and in Distutils2.</p>
<p>Distutils2 will also contain a backport of the new pgkutil, and can be used for
2.4 onward.</p>
<p>Distributions installed using existing, pre-standardization formats do not have
the necessary metadata available for the new API, and thus will be
ignored. Third-party tools may of course to continue to support previous
formats in addition to the new format, in order to ease the transition.</p>
</div>
<div class="section" id="references">
<h1>References<a class="headerlink" href="#references" title="Permalink to this headline"></a></h1>
<table class="docutils footnote" frame="void" id="distutils" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[1]</td><td><a class="reference external" href="http://docs.python.org/distutils">http://docs.python.org/distutils</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="distutils2" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[2]</td><td><a class="reference external" href="http://hg.python.org/distutils2">http://hg.python.org/distutils2</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="pep262" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[3]</td><td><em>(<a class="fn-backref" href="#id2">1</a>, <a class="fn-backref" href="#id3">2</a>, <a class="fn-backref" href="#id18">3</a>, <a class="fn-backref" href="#id19">4</a>, <a class="fn-backref" href="#id24">5</a>)</em> <a class="reference external" href="http://www.python.org/dev/peps/pep-0262">http://www.python.org/dev/peps/pep-0262</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="pep314" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[4]</td><td><em>(<a class="fn-backref" href="#id6">1</a>, <a class="fn-backref" href="#id7">2</a>)</em> <a class="reference external" href="http://www.python.org/dev/peps/pep-0314">http://www.python.org/dev/peps/pep-0314</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="setuptools" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[5]</td><td><em>(<a class="fn-backref" href="#id8">1</a>, <a class="fn-backref" href="#id10">2</a>)</em> <a class="reference external" href="http://peak.telecommunity.com/DevCenter/setuptools">http://peak.telecommunity.com/DevCenter/setuptools</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="easyinstall" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[6]</td><td><em>(<a class="fn-backref" href="#id12">1</a>, <a class="fn-backref" href="#id13">2</a>)</em> <a class="reference external" href="http://peak.telecommunity.com/DevCenter/EasyInstall">http://peak.telecommunity.com/DevCenter/EasyInstall</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="pip" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id14">[7]</a></td><td><a class="reference external" href="http://pypi.python.org/pypi/pip">http://pypi.python.org/pypi/pip</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="eggformats" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[8]</td><td><em>(<a class="fn-backref" href="#id9">1</a>, <a class="fn-backref" href="#id11">2</a>)</em> <a class="reference external" href="http://peak.telecommunity.com/DevCenter/EggFormats">http://peak.telecommunity.com/DevCenter/EggFormats</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="pep273" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id22">[9]</a></td><td><a class="reference external" href="http://www.python.org/dev/peps/pep-0273">http://www.python.org/dev/peps/pep-0273</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="pep278" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label">[10]</td><td><em>(<a class="fn-backref" href="#id20">1</a>, <a class="fn-backref" href="#id21">2</a>)</em> <a class="reference external" href="http://www.python.org/dev/peps/pep-0278">http://www.python.org/dev/peps/pep-0278</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="fedora" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id15">[11]</a></td><td><a class="reference external" href="http://fedoraproject.org/wiki/Packaging/Python/Eggs#Providing_Eggs_using_Setuptools">http://fedoraproject.org/wiki/Packaging/Python/Eggs#Providing_Eggs_using_Setuptools</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="debian" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id16">[12]</a></td><td><a class="reference external" href="http://wiki.debian.org/DebianPython/NewPolicy">http://wiki.debian.org/DebianPython/NewPolicy</a></td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="prototype" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id23">[13]</a></td><td><a class="reference external" href="http://bitbucket.org/tarek/pep376/">http://bitbucket.org/tarek/pep376/</a></td></tr>
</tbody>
</table>
</div>
<div class="section" id="acknowledgements">
<h1>Acknowledgements<a class="headerlink" href="#acknowledgements" title="Permalink to this headline"></a></h1>
<p>Jim Fulton, Ian Bicking, Phillip Eby, Rafael Villar Burke, and many people at
Pycon and Distutils-SIG.</p>
</div>
<div class="section" id="copyright">
<h1>Copyright<a class="headerlink" href="#copyright" title="Permalink to this headline"></a></h1>
<p>This document has been placed in the public domain.</p>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="index.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="#">概要</a></li>
<li><a class="reference external" href="#id4">根拠</a><ul>
<li><a class="reference external" href="#id5">配布物がどのようにインストールされるのか</a></li>
<li><a class="reference external" href="#id17">アンインストールの情報</a></li>
<li><a class="reference external" href="#pep">このPEPでの提案</a></li>
</ul>
</li>
<li><a class="reference external" href="#dist-info">インストールされた配布物ごとの .dist-info ディレクトリ</a><ul>
<li><a class="reference external" href="#record">RECORD</a></li>
<li><a class="reference external" href="#installer">INSTALLER</a></li>
<li><a class="reference external" href="#requested">REQUESTED</a></li>
</ul>
</li>
<li><a class="reference external" href="#implementation-details">Implementation details</a><ul>
<li><a class="reference external" href="#new-functions-and-classes-in-pkgutil">New functions and classes in pkgutil</a><ul>
<li><a class="reference external" href="#functions">Functions</a></li>
<li><a class="reference external" href="#distribution-class">Distribution class</a></li>
<li><a class="reference external" href="#examples">Examples</a></li>
</ul>
</li>
<li><a class="reference external" href="#new-functions-in-distutils">New functions in Distutils</a><ul>
<li><a class="reference external" href="#filtering">Filtering</a></li>
<li><a class="reference external" href="#installer-marker">Installer marker</a></li>
<li><a class="reference external" href="#adding-an-uninstall-script">Adding an Uninstall script</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference external" href="#backward-compatibility-and-roadmap">Backward compatibility and roadmap</a></li>
<li><a class="reference external" href="#references">References</a></li>
<li><a class="reference external" href="#acknowledgements">Acknowledgements</a></li>
<li><a class="reference external" href="#copyright">Copyright</a></li>
</ul>

            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/pep-0376-ja.txt"
                     rel="nofollow">Show Source</a></li>
            </ul>
          <div id="searchbox" style="display: none">
            <h3>Quick search</h3>
              <form class="search" action="search.html" method="get">
                <input type="text" name="q" size="18" />
                <input type="submit" value="Go" />
                <input type="hidden" name="check_keywords" value="yes" />
                <input type="hidden" name="area" value="default" />
              </form>
              <p class="searchtip" style="font-size: 90%">
              Enter search terms or a module, class or function name.
              </p>
          </div>
          <script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li><a href="index.html">aodag documents v0.0 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2010, Atsushi Odagiri.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.4.
    </div>
  </body>
</html>