Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/command/sdist.py @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | 9cdc845d5f2e |
| children | 5295ed192ffd |
| rev | line source |
|---|---|
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
1 """distutils.command.sdist |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
2 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
3 Implements the Distutils 'sdist' command (create a source distribution).""" |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
4 |
|
11897
017e592c0fd2
Changed '__rcsid__' to '__revision__'.
Greg Ward <gward@python.net>
parents:
11844
diff
changeset
|
5 __revision__ = "$Id$" |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
6 |
|
57847
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56335
diff
changeset
|
7 import os |
|
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56335
diff
changeset
|
8 import string |
|
50567
7ac1f6be8ad5
Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
45680
diff
changeset
|
9 import sys |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
10 from glob import glob |
|
54110
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
11 from warnings import warn |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
12 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
13 from distutils.core import Command |
|
13871
8307446bc6aa
Fixed imports from '*util' modules to not just import everything from util.
Greg Ward <gward@python.net>
parents:
13755
diff
changeset
|
14 from distutils import dir_util, dep_util, file_util, archive_util |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
15 from distutils.text_file import TextFile |
|
57847
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56335
diff
changeset
|
16 from distutils.errors import (DistutilsPlatformError, DistutilsOptionError, |
|
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56335
diff
changeset
|
17 DistutilsTemplateError) |
|
13752
8d10757a575b
The other half of Rene Liebscher's patch to add the Template class,
Greg Ward <gward@python.net>
parents:
13724
diff
changeset
|
18 from distutils.filelist import FileList |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
19 from distutils import log |
|
51684
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
20 from distutils.util import convert_path |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
21 |
|
54053
bf699026458e
more test coverage for distutils sdist command
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51696
diff
changeset
|
22 def show_formats(): |
|
12999
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
23 """Print all possible values for the 'formats' option (used by |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
24 the "--help-formats" command-line option). |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
25 """ |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
26 from distutils.fancy_getopt import FancyGetopt |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
27 from distutils.archive_util import ARCHIVE_FORMATS |
|
54053
bf699026458e
more test coverage for distutils sdist command
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51696
diff
changeset
|
28 formats = [] |
|
12999
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
29 for format in ARCHIVE_FORMATS.keys(): |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
30 formats.append(("formats=" + format, None, |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
31 ARCHIVE_FORMATS[format][2])) |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
32 formats.sort() |
|
54053
bf699026458e
more test coverage for distutils sdist command
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51696
diff
changeset
|
33 FancyGetopt(formats).print_help( |
|
12999
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
34 "List of available source distribution formats:") |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
35 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
36 class sdist(Command): |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
37 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
38 description = "create a source distribution (tarball, zip file, etc.)" |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
39 |
|
54110
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
40 def checking_metadata(self): |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
41 """Callable used for the check sub-command. |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
42 |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
43 Placed here so user_options can view it""" |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
44 return self.metadata_check |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
45 |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
46 user_options = [ |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
47 ('template=', 't', |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
48 "name of manifest template file [default: MANIFEST.in]"), |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
49 ('manifest=', 'm', |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
50 "name of manifest file [default: MANIFEST]"), |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
51 ('use-defaults', None, |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
52 "include the default file set in the manifest " |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
53 "[default; disable with --no-defaults]"), |
|
13111
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
54 ('no-defaults', None, |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
55 "don't include the default file set"), |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
56 ('prune', None, |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
57 "specifically exclude files/directories that should not be " |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
58 "distributed (build tree, RCS/CVS dirs, etc.) " |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
59 "[default; disable with --no-prune]"), |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
60 ('no-prune', None, |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
61 "don't automatically exclude anything"), |
|
12495
bef24d48afc8
Supply short form for --manifest-only (-o) and --force-manifest (-f)
Greg Ward <gward@python.net>
parents:
12494
diff
changeset
|
62 ('manifest-only', 'o', |
| 12891 | 63 "just regenerate the manifest and then stop " |
| 64 "(implies --force-manifest)"), | |
|
12495
bef24d48afc8
Supply short form for --manifest-only (-o) and --force-manifest (-f)
Greg Ward <gward@python.net>
parents:
12494
diff
changeset
|
65 ('force-manifest', 'f', |
|
61663
b5f2c4421a31
upgraded distutils docs w.r.t. the manifest regeneration
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
61657
diff
changeset
|
66 "forcibly regenerate the manifest and carry on as usual. " |
|
b5f2c4421a31
upgraded distutils docs w.r.t. the manifest regeneration
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
61657
diff
changeset
|
67 "Deprecated: now the manifest is always regenerated."), |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
68 ('formats=', None, |
|
12997
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12983
diff
changeset
|
69 "formats for source distribution (comma-separated list)"), |
|
14830
07288d2db596
Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
70 ('keep-temp', 'k', |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
71 "keep the distribution tree around after creating " + |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
72 "archive file(s)"), |
|
13347
384835ea0a5a
Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents:
13111
diff
changeset
|
73 ('dist-dir=', 'd', |
|
384835ea0a5a
Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents:
13111
diff
changeset
|
74 "directory to put the source distribution archive(s) in " |
|
384835ea0a5a
Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents:
13111
diff
changeset
|
75 "[default: dist]"), |
|
64649
6eb4afbe77e8
Merged revisions 84711 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
63969
diff
changeset
|
76 ('metadata-check', None, |
|
54110
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
77 "Ensure that all required elements of meta-data " |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
78 "are supplied. Warn if any missing. [default]"), |
|
56335
c2c90d1f3c33
#6516 added owner/group support for tarfiles in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54110
diff
changeset
|
79 ('owner=', 'u', |
|
c2c90d1f3c33
#6516 added owner/group support for tarfiles in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54110
diff
changeset
|
80 "Owner name used when creating a tar file [default: current user]"), |
|
c2c90d1f3c33
#6516 added owner/group support for tarfiles in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54110
diff
changeset
|
81 ('group=', 'g', |
|
c2c90d1f3c33
#6516 added owner/group support for tarfiles in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54110
diff
changeset
|
82 "Group name used when creating a tar file [default: current group]"), |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
83 ] |
|
12888
b5752de0cfa4
Cosmetic tweaks to imports, the 'show_formats()' function, and the
Greg Ward <gward@python.net>
parents:
12887
diff
changeset
|
84 |
|
14829
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14656
diff
changeset
|
85 boolean_options = ['use-defaults', 'prune', |
|
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14656
diff
changeset
|
86 'manifest-only', 'force-manifest', |
|
54110
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
87 'keep-temp', 'metadata-check'] |
|
12888
b5752de0cfa4
Cosmetic tweaks to imports, the 'show_formats()' function, and the
Greg Ward <gward@python.net>
parents:
12887
diff
changeset
|
88 |
|
12869
88872791998a
Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents:
12851
diff
changeset
|
89 help_options = [ |
|
88872791998a
Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents:
12851
diff
changeset
|
90 ('help-formats', None, |
|
12997
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12983
diff
changeset
|
91 "list available distribution formats", show_formats), |
| 15216 | 92 ] |
|
12869
88872791998a
Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents:
12851
diff
changeset
|
93 |
|
13111
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
94 negative_opt = {'no-defaults': 'use-defaults', |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
95 'no-prune': 'prune' } |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
96 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
97 default_format = {'posix': 'gztar', |
|
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
98 'nt': 'zip' } |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
99 |
|
54110
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
100 sub_commands = [('check', checking_metadata)] |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
101 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
102 def initialize_options(self): |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
103 # 'template' and 'manifest' are, respectively, the names of |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
104 # the manifest template and manifest file. |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
105 self.template = None |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
106 self.manifest = None |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
107 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
108 # 'use_defaults': if true, we will include the default file set |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
109 # in the manifest |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
110 self.use_defaults = 1 |
|
13111
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
111 self.prune = 1 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
112 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
113 self.manifest_only = 0 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
114 self.force_manifest = 0 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
115 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
116 self.formats = None |
|
14830
07288d2db596
Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
117 self.keep_temp = 0 |
|
13347
384835ea0a5a
Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents:
13111
diff
changeset
|
118 self.dist_dir = None |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
119 |
|
12812
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
120 self.archive_files = None |
|
54110
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
121 self.metadata_check = 1 |
|
56335
c2c90d1f3c33
#6516 added owner/group support for tarfiles in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54110
diff
changeset
|
122 self.owner = None |
|
c2c90d1f3c33
#6516 added owner/group support for tarfiles in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54110
diff
changeset
|
123 self.group = None |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
124 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
125 def finalize_options(self): |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
126 if self.manifest is None: |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
127 self.manifest = "MANIFEST" |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
128 if self.template is None: |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
129 self.template = "MANIFEST.in" |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
130 |
|
12851
e787f6641afb
Use 'ensure_string_list()' for 'formats' option, so that it can be
Greg Ward <gward@python.net>
parents:
12812
diff
changeset
|
131 self.ensure_string_list('formats') |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
132 if self.formats is None: |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
133 try: |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
134 self.formats = [self.default_format[os.name]] |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
135 except KeyError: |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
136 raise DistutilsPlatformError, \ |
|
12152
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
137 "don't know how to create source distributions " + \ |
|
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
138 "on platform %s" % os.name |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
139 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
140 bad_format = archive_util.check_archive_formats(self.formats) |
|
12451
33ba0626ef72
Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents:
12447
diff
changeset
|
141 if bad_format: |
|
33ba0626ef72
Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents:
12447
diff
changeset
|
142 raise DistutilsOptionError, \ |
|
33ba0626ef72
Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents:
12447
diff
changeset
|
143 "unknown archive format '%s'" % bad_format |
|
33ba0626ef72
Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents:
12447
diff
changeset
|
144 |
|
13347
384835ea0a5a
Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents:
13111
diff
changeset
|
145 if self.dist_dir is None: |
|
384835ea0a5a
Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents:
13111
diff
changeset
|
146 self.dist_dir = "dist" |
|
384835ea0a5a
Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents:
13111
diff
changeset
|
147 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
148 def run(self): |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
149 # 'filelist' contains the list of files that will make up the |
|
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
150 # manifest |
|
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
151 self.filelist = FileList() |
| 21268 | 152 |
|
54110
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
153 # Run sub commands |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
154 for cmd_name in self.get_sub_commands(): |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
155 self.run_command(cmd_name) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
156 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
157 # Do whatever it takes to get the list of files to process |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
158 # (process the manifest template, read an existing manifest, |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
159 # whatever). File list is accumulated in 'self.filelist'. |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
160 self.get_file_list() |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
161 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
162 # If user just wanted us to regenerate the manifest, stop now. |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
163 if self.manifest_only: |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
164 return |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
165 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
166 # Otherwise, go ahead and create the source distribution tarball, |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
167 # or zipfile, or whatever. |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
168 self.make_distribution() |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
169 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
170 def check_metadata(self): |
|
54110
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
171 """Deprecated API.""" |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
172 warn("distutils.command.sdist.check_metadata is deprecated, \ |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
173 use the check command instead", PendingDeprecationWarning) |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
174 check = self.distribution.get_command_obj('check') |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
175 check.ensure_finalized() |
|
d514a8b7ae78
#6041: sdist and register now use the check command. No more duplicate code for metadata checking
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54059
diff
changeset
|
176 check.run() |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
177 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
178 def get_file_list(self): |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
179 """Figure out the list of files to include in the source |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
180 distribution, and put it in 'self.filelist'. This might involve |
|
12889
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
181 reading the manifest template (and writing the manifest), or just |
|
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
182 reading the manifest, or just using the default file set -- it all |
|
61657
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
183 depends on the user's options. |
|
12889
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
184 """ |
|
71673
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
185 # new behavior when using a template: |
|
61657
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
186 # the file list is recalculated everytime because |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
187 # even if MANIFEST.in or setup.py are not changed |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
188 # the user might have added some files in the tree that |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
189 # need to be included. |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
190 # |
|
71673
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
191 # This makes --force the default and only behavior with templates. |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
192 template_exists = os.path.isfile(self.template) |
|
71673
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
193 if not template_exists and self._manifest_is_not_generated(): |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
194 self.read_manifest() |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
195 self.filelist.sort() |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
196 self.filelist.remove_duplicates() |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
197 return |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
198 |
|
61657
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
199 if not template_exists: |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
200 self.warn(("manifest template '%s' does not exist " + |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
201 "(using default file list)") % |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
202 self.template) |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
203 self.filelist.findall() |
|
12983
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
204 |
|
61657
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
205 if self.use_defaults: |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
206 self.add_defaults() |
|
14435
9fa3c571daff
Reorganized logic in 'get_file_list()' so it's easier to read, and fixed a
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
207 |
|
61657
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
208 if template_exists: |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
209 self.read_template() |
|
13755
632be99cc2cb
Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents:
13753
diff
changeset
|
210 |
|
61657
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
211 if self.prune: |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
212 self.prune_file_list() |
|
12893
fd5881e17427
Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents:
12892
diff
changeset
|
213 |
|
61657
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
214 self.filelist.sort() |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
215 self.filelist.remove_duplicates() |
|
d29399100973
Fixed #8688: Distutils now recalculates MANIFEST everytime.
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
57847
diff
changeset
|
216 self.write_manifest() |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
217 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
218 def add_defaults(self): |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
219 """Add all the default files to self.filelist: |
| 12891 | 220 - README or README.txt |
| 221 - setup.py | |
| 222 - test/test*.py | |
| 223 - all pure Python modules mentioned in setup script | |
|
51667
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
224 - all files pointed by package_data (build_py) |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
225 - all files defined in data_files. |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
226 - all files defined as scripts. |
| 12891 | 227 - all C sources listed as part of extensions or C libraries |
| 228 in the setup script (doesn't catch C headers!) | |
| 229 Warns if (README or README.txt) or setup.py are missing; everything | |
| 230 else is optional. | |
| 231 """ | |
|
12894
61f6acc4aa74
Include setup.cfg in the list of default files to distribute.
Greg Ward <gward@python.net>
parents:
12893
diff
changeset
|
232 |
|
14435
9fa3c571daff
Reorganized logic in 'get_file_list()' so it's easier to read, and fixed a
Greg Ward <gward@python.net>
parents:
14237
diff
changeset
|
233 standards = [('README', 'README.txt'), self.distribution.script_name] |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
234 for fn in standards: |
|
57847
3e2b7965ada9
massive import cleaning in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
56335
diff
changeset
|
235 if isinstance(fn, tuple): |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
236 alts = fn |
|
11844
253ec95f391e
Fix from est@hyperreal.org: missing initialize in 'find_defaults()'.
Greg Ward <gward@python.net>
parents:
11817
diff
changeset
|
237 got_it = 0 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
238 for fn in alts: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
239 if os.path.exists(fn): |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
240 got_it = 1 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
241 self.filelist.append(fn) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
242 break |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
243 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
244 if not got_it: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
245 self.warn("standard file not found: should have one of " + |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
246 string.join(alts, ', ')) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
247 else: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
248 if os.path.exists(fn): |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
249 self.filelist.append(fn) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
250 else: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
251 self.warn("standard file '%s' not found" % fn) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
252 |
|
12894
61f6acc4aa74
Include setup.cfg in the list of default files to distribute.
Greg Ward <gward@python.net>
parents:
12893
diff
changeset
|
253 optional = ['test/test*.py', 'setup.cfg'] |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
254 for pattern in optional: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
255 files = filter(os.path.isfile, glob(pattern)) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
256 if files: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
257 self.filelist.extend(files) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
258 |
|
51667
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
259 # build_py is used to get: |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
260 # - python modules |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
261 # - files defined in package_data |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
262 build_py = self.get_finalized_command('build_py') |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
263 |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
264 # getting python files |
|
12152
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
265 if self.distribution.has_pure_modules(): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
266 self.filelist.extend(build_py.get_source_files()) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
267 |
|
51667
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
268 # getting package_data files |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
269 # (computed in build_py.data_files by build_py.finalize_options) |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
270 for pkg, src_dir, build_dir, filenames in build_py.data_files: |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
271 for filename in filenames: |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
272 self.filelist.append(os.path.join(src_dir, filename)) |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
273 |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
274 # getting distribution.data_files |
|
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
275 if self.distribution.has_data_files(): |
|
51684
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
276 for item in self.distribution.data_files: |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
277 if isinstance(item, str): # plain file |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
278 item = convert_path(item) |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
279 if os.path.isfile(item): |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
280 self.filelist.append(item) |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
281 else: # a (dirname, filenames) tuple |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
282 dirname, filenames = item |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
283 for f in filenames: |
|
51696
92e42b1b0a6e
fixed the data_files inclusion behavior
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51684
diff
changeset
|
284 f = convert_path(f) |
|
51684
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
285 if os.path.isfile(f): |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
286 self.filelist.append(f) |
|
51667
982f9e2925a4
Fixed #2279: distutils.sdist.add_defaults now add files listed in package_data and data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51054
diff
changeset
|
287 |
|
12152
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
288 if self.distribution.has_ext_modules(): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
289 build_ext = self.get_finalized_command('build_ext') |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
290 self.filelist.extend(build_ext.get_source_files()) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
291 |
|
12298
d640e7d4aec4
Ditched the unused 'list_only' option.
Greg Ward <gward@python.net>
parents:
12152
diff
changeset
|
292 if self.distribution.has_c_libraries(): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
293 build_clib = self.get_finalized_command('build_clib') |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
294 self.filelist.extend(build_clib.get_source_files()) |
|
12298
d640e7d4aec4
Ditched the unused 'list_only' option.
Greg Ward <gward@python.net>
parents:
12152
diff
changeset
|
295 |
|
31852
2cfe14275a04
backport fix for SF bug #796042: sdist ignores scripts argument in setup
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
296 if self.distribution.has_scripts(): |
|
2cfe14275a04
backport fix for SF bug #796042: sdist ignores scripts argument in setup
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
297 build_scripts = self.get_finalized_command('build_scripts') |
|
2cfe14275a04
backport fix for SF bug #796042: sdist ignores scripts argument in setup
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
298 self.filelist.extend(build_scripts.get_source_files()) |
|
2cfe14275a04
backport fix for SF bug #796042: sdist ignores scripts argument in setup
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
299 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
300 def read_template(self): |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
301 """Read and parse manifest template file named by self.template. |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
302 |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
303 (usually "MANIFEST.in") The parsing and processing is done by |
|
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
304 'self.filelist', which updates itself accordingly. |
|
12889
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
305 """ |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
306 log.info("reading manifest template '%s'", self.template) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
307 template = TextFile(self.template, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
308 strip_comments=1, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
309 skip_blanks=1, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
310 join_lines=1, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
311 lstrip_ws=1, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
312 rstrip_ws=1, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
313 collapse_join=1) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
314 |
| 69769 | 315 try: |
| 316 while 1: | |
| 317 line = template.readline() | |
| 318 if line is None: # end of file | |
| 319 break | |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
320 |
| 69769 | 321 try: |
| 322 self.filelist.process_template_line(line) | |
|
72285
9cdc845d5f2e
Warn instead of crashing because of invalid path in MANIFEST.in (#8286).
Éric Araujo <merwok@netwok.org>
parents:
71673
diff
changeset
|
323 # the call above can raise a DistutilsTemplateError for |
|
9cdc845d5f2e
Warn instead of crashing because of invalid path in MANIFEST.in (#8286).
Éric Araujo <merwok@netwok.org>
parents:
71673
diff
changeset
|
324 # malformed lines, or a ValueError from the lower-level |
|
9cdc845d5f2e
Warn instead of crashing because of invalid path in MANIFEST.in (#8286).
Éric Araujo <merwok@netwok.org>
parents:
71673
diff
changeset
|
325 # convert_path function |
|
9cdc845d5f2e
Warn instead of crashing because of invalid path in MANIFEST.in (#8286).
Éric Araujo <merwok@netwok.org>
parents:
71673
diff
changeset
|
326 except (DistutilsTemplateError, ValueError) as msg: |
| 69769 | 327 self.warn("%s, line %d: %s" % (template.filename, |
| 328 template.current_line, | |
| 329 msg)) | |
| 330 finally: | |
| 331 template.close() | |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
332 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
333 def prune_file_list(self): |
|
12893
fd5881e17427
Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents:
12892
diff
changeset
|
334 """Prune off branches that might slip into the file list as created |
|
13111
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
335 by 'read_template()', but really don't belong there: |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
336 * the build tree (typically "build") |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
337 * the release tree itself (only an issue if we ran "sdist" |
|
14830
07288d2db596
Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
338 previously with --keep-temp, or it aborted) |
| 45685 | 339 * any RCS, CVS, .svn, .hg, .git, .bzr, _darcs directories |
|
12893
fd5881e17427
Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents:
12892
diff
changeset
|
340 """ |
|
fd5881e17427
Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents:
12892
diff
changeset
|
341 build = self.get_finalized_command('build') |
|
12781
936efdc01d52
Patch from Andrew Kuchling: prune out the build and source distribution
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
342 base_dir = self.distribution.get_fullname() |
|
936efdc01d52
Patch from Andrew Kuchling: prune out the build and source distribution
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
343 |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
344 self.filelist.exclude_pattern(None, prefix=build.build_base) |
|
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
345 self.filelist.exclude_pattern(None, prefix=base_dir) |
|
12887
11d10e9b508d
Made all debug output go through the 'debug_print()' method instead of
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
346 |
|
50567
7ac1f6be8ad5
Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
45680
diff
changeset
|
347 # pruning out vcs directories |
|
7ac1f6be8ad5
Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
45680
diff
changeset
|
348 # both separators are used under win32 |
|
50582
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
349 if sys.platform == 'win32': |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
350 seps = r'/|\\' |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
351 else: |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
352 seps = '/' |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
353 |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
354 vcs_dirs = ['RCS', 'CVS', r'\.svn', r'\.hg', r'\.git', r'\.bzr', |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
355 '_darcs'] |
|
50567
7ac1f6be8ad5
Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
45680
diff
changeset
|
356 vcs_ptrn = r'(^|%s)(%s)(%s).*' % (seps, '|'.join(vcs_dirs), seps) |
|
7ac1f6be8ad5
Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
45680
diff
changeset
|
357 self.filelist.exclude_pattern(vcs_ptrn, is_regex=1) |
|
12887
11d10e9b508d
Made all debug output go through the 'debug_print()' method instead of
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
358 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
359 def write_manifest(self): |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
360 """Write the file list in 'self.filelist' (presumably as filled in |
|
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
361 by 'add_defaults()' and 'read_template()') to the manifest file |
|
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
362 named by 'self.manifest'. |
|
12889
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
363 """ |
|
71673
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
364 if self._manifest_is_not_generated(): |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
365 log.info("not writing to manually maintained " |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
366 "manifest file '%s'" % self.manifest) |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
367 return |
|
63969
f7639dcdffc3
Merged revisions 83993 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
61663
diff
changeset
|
368 |
|
f7639dcdffc3
Merged revisions 83993 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
61663
diff
changeset
|
369 content = self.filelist.files[:] |
|
f7639dcdffc3
Merged revisions 83993 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
61663
diff
changeset
|
370 content.insert(0, '# file GENERATED by distutils, do NOT edit') |
|
f7639dcdffc3
Merged revisions 83993 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents:
61663
diff
changeset
|
371 self.execute(file_util.write_file, (self.manifest, content), |
|
12887
11d10e9b508d
Made all debug output go through the 'debug_print()' method instead of
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
372 "writing manifest file '%s'" % self.manifest) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
373 |
|
71673
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
374 def _manifest_is_not_generated(self): |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
375 # check for special comment used in 2.7.1 and higher |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
376 if not os.path.isfile(self.manifest): |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
377 return False |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
378 |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
379 fp = open(self.manifest, 'rU') |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
380 try: |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
381 first_line = fp.readline() |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
382 finally: |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
383 fp.close() |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
384 return first_line != '# file GENERATED by distutils, do NOT edit\n' |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
385 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
386 def read_manifest(self): |
|
12889
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
387 """Read the manifest file (named by 'self.manifest') and use it to |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
388 fill in 'self.filelist', the list of files to include in the source |
|
12889
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
389 distribution. |
|
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
390 """ |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
391 log.info("reading manifest file '%s'", self.manifest) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
392 manifest = open(self.manifest) |
|
71673
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
393 for line in manifest: |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
394 # ignore comments and blank lines |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
395 line = line.strip() |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
396 if line.startswith('#') or not line: |
|
21feea7f35e5
Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents:
69769
diff
changeset
|
397 continue |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
398 self.filelist.append(line) |
| 45411 | 399 manifest.close() |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
400 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
401 def make_release_tree(self, base_dir, files): |
| 12891 | 402 """Create the directory tree that will become the source |
| 403 distribution archive. All directories implied by the filenames in | |
| 404 'files' are created under 'base_dir', and then we hard link or copy | |
| 405 (if hard linking is unavailable) those files into place. | |
| 406 Essentially, this duplicates the developer's source tree, but in a | |
| 407 directory named after the distribution, containing only the files | |
| 408 to be distributed. | |
| 409 """ | |
|
12152
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
410 # Create all the directories under 'base_dir' necessary to |
|
14436
c0509989405e
Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents:
14435
diff
changeset
|
411 # put 'files' there; the 'mkpath()' is just so we don't die |
|
c0509989405e
Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents:
14435
diff
changeset
|
412 # if the manifest happens to be empty. |
|
c0509989405e
Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents:
14435
diff
changeset
|
413 self.mkpath(base_dir) |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
414 dir_util.create_tree(base_dir, files, dry_run=self.dry_run) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
415 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
416 # And walk over the list of files, either making a hard link (if |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
417 # os.link exists) to each one that doesn't already exist in its |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
418 # corresponding location under 'base_dir', or copying each file |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
419 # that's out-of-date in 'base_dir'. (Usually, all files will be |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
420 # out-of-date, because by default we blow away 'base_dir' when |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
421 # we're done making the distribution archives.) |
| 21268 | 422 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
423 if hasattr(os, 'link'): # can make hard links on this system |
|
12152
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
424 link = 'hard' |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
425 msg = "making hard links in %s..." % base_dir |
|
12152
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
426 else: # nope, have to copy |
|
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
427 link = None |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
428 msg = "copying files to %s..." % base_dir |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
429 |
|
14436
c0509989405e
Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents:
14435
diff
changeset
|
430 if not files: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
431 log.warn("no files to distribute -- empty manifest?") |
|
14436
c0509989405e
Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents:
14435
diff
changeset
|
432 else: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
433 log.info(msg) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
434 for file in files: |
|
14436
c0509989405e
Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents:
14435
diff
changeset
|
435 if not os.path.isfile(file): |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
436 log.warn("'%s' not a regular file -- skipping" % file) |
|
14436
c0509989405e
Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents:
14435
diff
changeset
|
437 else: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
438 dest = os.path.join(base_dir, file) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
439 self.copy_file(file, dest, link=link) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
440 |
|
17128
1146070f47ec
Call the write_pkg_info method
Andrew M. Kuchling <amk@amk.ca>
parents:
15216
diff
changeset
|
441 self.distribution.metadata.write_pkg_info(base_dir) |
| 21268 | 442 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
443 def make_distribution(self): |
| 12891 | 444 """Create the source distribution(s). First, we create the release |
| 445 tree with 'make_release_tree()'; then, we create all required | |
| 446 archive files (according to 'self.formats') from the release tree. | |
| 447 Finally, we clean up by blowing away the release tree (unless | |
|
14830
07288d2db596
Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
448 'self.keep_temp' is true). The list of archive files created is |
| 12891 | 449 stored so it can be retrieved later by 'get_archive_files()'. |
| 450 """ | |
|
12152
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
451 # Don't warn about missing meta-data here -- should be (and is!) |
|
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
452 # done elsewhere. |
|
12447
951d84e1d54b
Changed to call 'get_fullname()', not 'get_full_name()', on Distribution object.
Greg Ward <gward@python.net>
parents:
12433
diff
changeset
|
453 base_dir = self.distribution.get_fullname() |
|
13347
384835ea0a5a
Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents:
13111
diff
changeset
|
454 base_name = os.path.join(self.dist_dir, base_dir) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
455 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
456 self.make_release_tree(base_dir, self.filelist.files) |
|
12812
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
457 archive_files = [] # remember names of files we create |
|
51070
d42374d0aa58
Merged revisions 68951 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50582
diff
changeset
|
458 # tar archive must be created last to avoid overwrite and remove |
|
d42374d0aa58
Merged revisions 68951 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50582
diff
changeset
|
459 if 'tar' in self.formats: |
|
d42374d0aa58
Merged revisions 68951 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50582
diff
changeset
|
460 self.formats.append(self.formats.pop(self.formats.index('tar'))) |
|
d42374d0aa58
Merged revisions 68951 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50582
diff
changeset
|
461 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
462 for fmt in self.formats: |
|
56335
c2c90d1f3c33
#6516 added owner/group support for tarfiles in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54110
diff
changeset
|
463 file = self.make_archive(base_name, fmt, base_dir=base_dir, |
|
c2c90d1f3c33
#6516 added owner/group support for tarfiles in Distutils
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54110
diff
changeset
|
464 owner=self.owner, group=self.group) |
|
12812
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
465 archive_files.append(file) |
|
34805
b8ff9bc023e6
Make dist_files a triple, with the Python target version included,
Martin v. Löwis <martin@v.loewis.de>
parents:
34793
diff
changeset
|
466 self.distribution.dist_files.append(('sdist', '', file)) |
|
12812
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
467 |
|
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
468 self.archive_files = archive_files |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
469 |
|
14830
07288d2db596
Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
470 if not self.keep_temp: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
471 dir_util.remove_tree(base_dir, dry_run=self.dry_run) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
472 |
|
54059
67baf2c17369
pep8-fied distutils.command.sdist + more tests
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
54053
diff
changeset
|
473 def get_archive_files(self): |
|
12812
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
474 """Return the list of archive files created when the command |
|
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
475 was run, or None if the command hasn't run yet. |
|
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
476 """ |
|
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
477 return self.archive_files |
