Mercurial > cpython-lru_cache-weakref
annotate Lib/distutils/command/sdist.py @ 51684:27268ef04708 legacy-trunk
#2279 added the plain path case for data_files
| author | Tarek Ziadé <ziade.tarek@gmail.com> |
|---|---|
| date | Tue, 17 Feb 2009 09:42:44 +0000 |
| parents | 982f9e2925a4 |
| children | 92e42b1b0a6e |
| 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 |
|
45468
1d84bf5f9478
Patch #2167 from calvin: Remove unused imports
Christian Heimes <christian@cheimes.de>
parents:
45411
diff
changeset
|
7 import os, string |
|
50567
7ac1f6be8ad5
Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
45680
diff
changeset
|
8 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
|
9 from types import * |
|
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 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
11 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
|
12 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
|
13 from distutils.text_file import TextFile |
|
13755
632be99cc2cb
Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents:
13753
diff
changeset
|
14 from distutils.errors import * |
|
13752
8d10757a575b
The other half of Rene Liebscher's patch to add the Template class,
Greg Ward <gward@python.net>
parents:
13724
diff
changeset
|
15 from distutils.filelist import FileList |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
16 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
|
17 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
|
18 |
|
12999
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
19 def show_formats (): |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
20 """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
|
21 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
|
22 """ |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
23 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
|
24 from distutils.archive_util import ARCHIVE_FORMATS |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
25 formats=[] |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
26 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
|
27 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
|
28 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
|
29 formats.sort() |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
30 pretty_printer = FancyGetopt(formats) |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
31 pretty_printer.print_help( |
|
7160b52ca74a
Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents:
12997
diff
changeset
|
32 "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
|
33 |
|
11813
eaeda4621f7d
Renamed all command classes so they're exactly the same as the name of the
Greg Ward <gward@python.net>
parents:
11811
diff
changeset
|
34 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
|
35 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
36 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
|
37 |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
38 user_options = [ |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
39 ('template=', 't', |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
40 "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
|
41 ('manifest=', 'm', |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
42 "name of manifest file [default: MANIFEST]"), |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
43 ('use-defaults', None, |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
44 "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
|
45 "[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
|
46 ('no-defaults', None, |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
47 "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
|
48 ('prune', None, |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
49 "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
|
50 "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
|
51 "[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
|
52 ('no-prune', None, |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
53 "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
|
54 ('manifest-only', 'o', |
| 12891 | 55 "just regenerate the manifest and then stop " |
| 56 "(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
|
57 ('force-manifest', 'f', |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
58 "forcibly regenerate the manifest and carry on as usual"), |
|
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
59 ('formats=', None, |
|
12997
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12983
diff
changeset
|
60 "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
|
61 ('keep-temp', 'k', |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
62 "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
|
63 "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
|
64 ('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
|
65 "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
|
66 "[default: dist]"), |
|
11815
03902bc0214a
Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents:
11813
diff
changeset
|
67 ] |
|
12888
b5752de0cfa4
Cosmetic tweaks to imports, the 'show_formats()' function, and the
Greg Ward <gward@python.net>
parents:
12887
diff
changeset
|
68 |
|
14829
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14656
diff
changeset
|
69 boolean_options = ['use-defaults', 'prune', |
|
b1f220f636ed
Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents:
14656
diff
changeset
|
70 'manifest-only', 'force-manifest', |
|
14830
07288d2db596
Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
71 'keep-temp'] |
|
12888
b5752de0cfa4
Cosmetic tweaks to imports, the 'show_formats()' function, and the
Greg Ward <gward@python.net>
parents:
12887
diff
changeset
|
72 |
|
12869
88872791998a
Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents:
12851
diff
changeset
|
73 help_options = [ |
|
88872791998a
Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents:
12851
diff
changeset
|
74 ('help-formats', None, |
|
12997
27f3a18fd296
Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents:
12983
diff
changeset
|
75 "list available distribution formats", show_formats), |
| 15216 | 76 ] |
|
12869
88872791998a
Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents:
12851
diff
changeset
|
77 |
|
13111
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
78 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
|
79 '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
|
80 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
81 default_format = { 'posix': 'gztar', |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
82 'nt': 'zip' } |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
83 |
|
11817
476eaa38e2d6
Renamed 'set_default_options()' to 'initialize_options()', and
Greg Ward <gward@python.net>
parents:
11815
diff
changeset
|
84 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
|
85 # '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
|
86 # 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
|
87 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
|
88 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
|
89 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
90 # '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
|
91 # 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
|
92 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
|
93 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
|
94 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
95 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
|
96 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
|
97 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
98 self.formats = None |
|
14830
07288d2db596
Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
99 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
|
100 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
|
101 |
|
12812
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
102 self.archive_files = None |
|
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
103 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
104 |
|
11817
476eaa38e2d6
Renamed 'set_default_options()' to 'initialize_options()', and
Greg Ward <gward@python.net>
parents:
11815
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 |
|
12851
e787f6641afb
Use 'ensure_string_list()' for 'formats' option, so that it can be
Greg Ward <gward@python.net>
parents:
12812
diff
changeset
|
111 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
|
112 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
|
113 try: |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
114 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
|
115 except KeyError: |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
116 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
|
117 "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
|
118 "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
|
119 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
120 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
|
121 if bad_format: |
|
33ba0626ef72
Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents:
12447
diff
changeset
|
122 raise DistutilsOptionError, \ |
|
33ba0626ef72
Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents:
12447
diff
changeset
|
123 "unknown archive format '%s'" % bad_format |
|
33ba0626ef72
Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents:
12447
diff
changeset
|
124 |
|
13347
384835ea0a5a
Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents:
13111
diff
changeset
|
125 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
|
126 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
|
127 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
128 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
129 def run (self): |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
130 |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
131 # '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
|
132 # manifest |
|
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
133 self.filelist = FileList() |
| 21268 | 134 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
135 # Ensure that all required meta-data is given; warn if not (but |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
136 # don't die, it's not *that* serious!) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
137 self.check_metadata() |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
138 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
139 # 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
|
140 # (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
|
141 # whatever). File list is accumulated in 'self.filelist'. |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
142 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
|
143 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
144 # 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
|
145 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
|
146 return |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
147 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
148 # 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
|
149 # or zipfile, or whatever. |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
150 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
|
151 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
152 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
153 def check_metadata (self): |
| 12891 | 154 """Ensure that all required elements of meta-data (name, version, |
| 155 URL, (author and author_email) or (maintainer and | |
| 156 maintainer_email)) are supplied by the Distribution object; warn if | |
| 157 any are missing. | |
| 158 """ | |
|
12433
8161334942d4
Fix 'check_metadata()' so it grovels through the distribution's metadata
Greg Ward <gward@python.net>
parents:
12431
diff
changeset
|
159 metadata = self.distribution.metadata |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
160 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
161 missing = [] |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
162 for attr in ('name', 'version', 'url'): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
163 if not (hasattr(metadata, attr) and getattr(metadata, attr)): |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
164 missing.append(attr) |
|
11811
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 if missing: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
167 self.warn("missing required meta-data: " + |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
168 string.join(missing, ", ")) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
169 |
|
12433
8161334942d4
Fix 'check_metadata()' so it grovels through the distribution's metadata
Greg Ward <gward@python.net>
parents:
12431
diff
changeset
|
170 if metadata.author: |
|
8161334942d4
Fix 'check_metadata()' so it grovels through the distribution's metadata
Greg Ward <gward@python.net>
parents:
12431
diff
changeset
|
171 if not metadata.author_email: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
172 self.warn("missing meta-data: if 'author' supplied, " + |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
173 "'author_email' must be supplied too") |
|
12433
8161334942d4
Fix 'check_metadata()' so it grovels through the distribution's metadata
Greg Ward <gward@python.net>
parents:
12431
diff
changeset
|
174 elif metadata.maintainer: |
|
8161334942d4
Fix 'check_metadata()' so it grovels through the distribution's metadata
Greg Ward <gward@python.net>
parents:
12431
diff
changeset
|
175 if not metadata.maintainer_email: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
176 self.warn("missing meta-data: if 'maintainer' supplied, " + |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
177 "'maintainer_email' must be supplied too") |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
178 else: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
179 self.warn("missing meta-data: either (author and author_email) " + |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
180 "or (maintainer and maintainer_email) " + |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
181 "must be supplied") |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
182 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
183 # check_metadata () |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
184 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
185 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
186 def get_file_list (self): |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
187 """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
|
188 distribution, and put it in 'self.filelist'. This might involve |
|
12889
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
189 reading the manifest template (and writing the manifest), or just |
|
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
190 reading the manifest, or just using the default file set -- it all |
|
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
191 depends on the user's options and the state of the filesystem. |
|
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
192 """ |
|
12983
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
193 |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
194 # If we have a manifest template, see if it's newer than the |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
195 # manifest; if so, we'll regenerate the manifest. |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
196 template_exists = os.path.isfile(self.template) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
197 if template_exists: |
|
13871
8307446bc6aa
Fixed imports from '*util' modules to not just import everything from util.
Greg Ward <gward@python.net>
parents:
13755
diff
changeset
|
198 template_newer = dep_util.newer(self.template, 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
|
199 |
|
12983
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
200 # The contents of the manifest file almost certainly depend on the |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
201 # setup script as well as the manifest template -- so if the setup |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
202 # script is newer than the manifest, we'll regenerate the manifest |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
203 # from the template. (Well, not quite: if we already have a |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
204 # manifest, but there's no template -- which will happen if the |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
205 # developer elects to generate a manifest some other way -- then we |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
206 # can't regenerate the manifest, so we don't.) |
|
14237
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
14115
diff
changeset
|
207 self.debug_print("checking if %s newer than %s" % |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
14115
diff
changeset
|
208 (self.distribution.script_name, self.manifest)) |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
14115
diff
changeset
|
209 setup_newer = dep_util.newer(self.distribution.script_name, |
|
d9643e9c90eb
Added 'script_name' and 'script_args' instance attributes to Distribution.
Greg Ward <gward@python.net>
parents:
14115
diff
changeset
|
210 self.manifest) |
|
12983
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
211 |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
212 # cases: |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
213 # 1) no manifest, template exists: generate manifest |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
214 # (covered by 2a: no manifest == template newer) |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
215 # 2) manifest & template exist: |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
216 # 2a) template or setup script newer than manifest: |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
217 # regenerate manifest |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
218 # 2b) manifest newer than both: |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
219 # do nothing (unless --force or --manifest-only) |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
220 # 3) manifest exists, no template: |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
221 # do nothing (unless --force or --manifest-only) |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
222 # 4) no manifest, no template: generate w/ warning ("defaults only") |
|
b544299e68c5
Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents:
12894
diff
changeset
|
223 |
|
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
|
224 manifest_outofdate = (template_exists and |
|
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
|
225 (template_newer or setup_newer)) |
|
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
|
226 force_regen = self.force_manifest or self.manifest_only |
|
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
|
227 manifest_exists = os.path.isfile(self.manifest) |
|
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
|
228 neither_exists = (not template_exists and not manifest_exists) |
|
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
|
229 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
230 # Regenerate the manifest if necessary (or if explicitly told to) |
|
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
|
231 if manifest_outofdate or neither_exists or force_regen: |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
232 if not template_exists: |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
233 self.warn(("manifest template '%s' does not exist " + |
|
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
234 "(using default file list)") % |
|
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
235 self.template) |
|
13755
632be99cc2cb
Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents:
13753
diff
changeset
|
236 self.filelist.findall() |
|
632be99cc2cb
Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents:
13753
diff
changeset
|
237 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
238 if self.use_defaults: |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
239 self.add_defaults() |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
240 if template_exists: |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
241 self.read_template() |
|
13111
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
242 if self.prune: |
|
52d5fb471e17
Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents:
12999
diff
changeset
|
243 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
|
244 |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
245 self.filelist.sort() |
|
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
246 self.filelist.remove_duplicates() |
|
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
247 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
|
248 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
249 # Don't regenerate the manifest, just read it in. |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
250 else: |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
251 self.read_manifest() |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
252 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
253 # get_file_list () |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
254 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
255 |
|
12892
0c2cdd7cf7dc
Renamed 'find_defaults()' to 'add_defaults()'.
Greg Ward <gward@python.net>
parents:
12891
diff
changeset
|
256 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
|
257 """Add all the default files to self.filelist: |
| 12891 | 258 - README or README.txt |
| 259 - setup.py | |
| 260 - test/test*.py | |
| 261 - 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
|
262 - 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
|
263 - 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
|
264 - all files defined as scripts. |
| 12891 | 265 - all C sources listed as part of extensions or C libraries |
| 266 in the setup script (doesn't catch C headers!) | |
| 267 Warns if (README or README.txt) or setup.py are missing; everything | |
| 268 else is optional. | |
| 269 """ | |
|
12894
61f6acc4aa74
Include setup.cfg in the list of default files to distribute.
Greg Ward <gward@python.net>
parents:
12893
diff
changeset
|
270 |
|
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
|
271 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
|
272 for fn in standards: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
273 if type(fn) is TupleType: |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
274 alts = fn |
|
11844
253ec95f391e
Fix from est@hyperreal.org: missing initialize in 'find_defaults()'.
Greg Ward <gward@python.net>
parents:
11817
diff
changeset
|
275 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
|
276 for fn in alts: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
277 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
|
278 got_it = 1 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
279 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
|
280 break |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
281 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
282 if not got_it: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
283 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
|
284 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
|
285 else: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
286 if os.path.exists(fn): |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
287 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
|
288 else: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
289 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
|
290 |
|
12894
61f6acc4aa74
Include setup.cfg in the list of default files to distribute.
Greg Ward <gward@python.net>
parents:
12893
diff
changeset
|
291 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
|
292 for pattern in optional: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
293 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
|
294 if files: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
295 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
|
296 |
|
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
|
297 # 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
|
298 # - 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
|
299 # - 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
|
300 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
|
301 |
|
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
|
302 # 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
|
303 if self.distribution.has_pure_modules(): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
304 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
|
305 |
|
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
|
306 # 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
|
307 # (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
|
308 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
|
309 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
|
310 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
|
311 |
|
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
|
312 # 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
|
313 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
|
314 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
|
315 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
|
316 item = convert_path(item) |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
317 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
|
318 self.filelist.append(item) |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
319 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
|
320 dirname, filenames = item |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
321 for f in filenames: |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
322 f = convert_path(os.path.join(dirname, f)) |
|
27268ef04708
#2279 added the plain path case for data_files
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51667
diff
changeset
|
323 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
|
324 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
|
325 |
|
12152
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
326 if self.distribution.has_ext_modules(): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
327 build_ext = self.get_finalized_command('build_ext') |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
328 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
|
329 |
|
12298
d640e7d4aec4
Ditched the unused 'list_only' option.
Greg Ward <gward@python.net>
parents:
12152
diff
changeset
|
330 if self.distribution.has_c_libraries(): |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
331 build_clib = self.get_finalized_command('build_clib') |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
332 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
|
333 |
|
31852
2cfe14275a04
backport fix for SF bug #796042: sdist ignores scripts argument in setup
Fred Drake <fdrake@acm.org>
parents:
26285
diff
changeset
|
334 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
|
335 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
|
336 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
|
337 |
|
12892
0c2cdd7cf7dc
Renamed 'find_defaults()' to 'add_defaults()'.
Greg Ward <gward@python.net>
parents:
12891
diff
changeset
|
338 # add_defaults () |
| 21268 | 339 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
340 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
341 def read_template (self): |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
342 """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
|
343 |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
344 (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
|
345 'self.filelist', which updates itself accordingly. |
|
12889
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
346 """ |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
347 log.info("reading manifest template '%s'", self.template) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
348 template = TextFile(self.template, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
349 strip_comments=1, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
350 skip_blanks=1, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
351 join_lines=1, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
352 lstrip_ws=1, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
353 rstrip_ws=1, |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
354 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
|
355 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
356 while 1: |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
357 line = template.readline() |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
358 if line is None: # end of file |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
359 break |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
360 |
|
13755
632be99cc2cb
Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents:
13753
diff
changeset
|
361 try: |
|
632be99cc2cb
Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents:
13753
diff
changeset
|
362 self.filelist.process_template_line(line) |
|
632be99cc2cb
Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents:
13753
diff
changeset
|
363 except DistutilsTemplateError, msg: |
|
632be99cc2cb
Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents:
13753
diff
changeset
|
364 self.warn("%s, line %d: %s" % (template.filename, |
|
632be99cc2cb
Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents:
13753
diff
changeset
|
365 template.current_line, |
|
632be99cc2cb
Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents:
13753
diff
changeset
|
366 msg)) |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
367 |
|
12893
fd5881e17427
Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents:
12892
diff
changeset
|
368 # read_template () |
|
fd5881e17427
Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents:
12892
diff
changeset
|
369 |
|
12781
936efdc01d52
Patch from Andrew Kuchling: prune out the build and source distribution
Greg Ward <gward@python.net>
parents:
12743
diff
changeset
|
370 |
|
12893
fd5881e17427
Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents:
12892
diff
changeset
|
371 def prune_file_list (self): |
|
fd5881e17427
Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents:
12892
diff
changeset
|
372 """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
|
373 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
|
374 * 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
|
375 * 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
|
376 previously with --keep-temp, or it aborted) |
|
45680
ef893390487b
#1725737: ignore other VC directories other than CVS and SVN's too.
Georg Brandl <georg@python.org>
parents:
45468
diff
changeset
|
377 * 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
|
378 """ |
|
fd5881e17427
Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents:
12892
diff
changeset
|
379 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
|
380 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
|
381 |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
382 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
|
383 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
|
384 |
|
50567
7ac1f6be8ad5
Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
45680
diff
changeset
|
385 # pruning out vcs directories |
|
7ac1f6be8ad5
Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
45680
diff
changeset
|
386 # both separators are used under win32 |
|
50582
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
387 if sys.platform == 'win32': |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
388 seps = r'/|\\' |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
389 else: |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
390 seps = '/' |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
391 |
|
057cb46ddaad
Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
50567
diff
changeset
|
392 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
|
393 '_darcs'] |
|
50567
7ac1f6be8ad5
Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
45680
diff
changeset
|
394 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
|
395 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
|
396 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
397 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
|
398 """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
|
399 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
|
400 named by 'self.manifest'. |
|
12889
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
401 """ |
|
13871
8307446bc6aa
Fixed imports from '*util' modules to not just import everything from util.
Greg Ward <gward@python.net>
parents:
13755
diff
changeset
|
402 self.execute(file_util.write_file, |
|
13753
84f8579a079c
Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents:
13752
diff
changeset
|
403 (self.manifest, self.filelist.files), |
|
12887
11d10e9b508d
Made all debug output go through the 'debug_print()' method instead of
Greg Ward <gward@python.net>
parents:
12869
diff
changeset
|
404 "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
|
405 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
406 # write_manifest () |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
407 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
408 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
409 def read_manifest (self): |
|
12889
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
410 """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
|
411 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
|
412 distribution. |
|
f54c3677bae7
Docstring reformatting binge.
Greg Ward <gward@python.net>
parents:
12888
diff
changeset
|
413 """ |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
414 log.info("reading manifest file '%s'", self.manifest) |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
415 manifest = open(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
|
416 while 1: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
417 line = manifest.readline() |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
418 if line == '': # end of file |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
419 break |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
420 if line[-1] == '\n': |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
421 line = line[0:-1] |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
422 self.filelist.append(line) |
| 45411 | 423 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
|
424 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
425 # read_manifest () |
| 21268 | 426 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
427 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
428 def make_release_tree (self, base_dir, files): |
| 12891 | 429 """Create the directory tree that will become the source |
| 430 distribution archive. All directories implied by the filenames in | |
| 431 'files' are created under 'base_dir', and then we hard link or copy | |
| 432 (if hard linking is unavailable) those files into place. | |
| 433 Essentially, this duplicates the developer's source tree, but in a | |
| 434 directory named after the distribution, containing only the files | |
| 435 to be distributed. | |
| 436 """ | |
|
12152
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
437 # 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
|
438 # 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
|
439 # if the manifest happens to be empty. |
|
c0509989405e
Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents:
14435
diff
changeset
|
440 self.mkpath(base_dir) |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
441 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
|
442 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
443 # 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
|
444 # 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
|
445 # 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
|
446 # 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
|
447 # 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
|
448 # we're done making the distribution archives.) |
| 21268 | 449 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
450 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
|
451 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
|
452 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
|
453 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
|
454 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
|
455 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
|
456 |
|
14436
c0509989405e
Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents:
14435
diff
changeset
|
457 if not files: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
458 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
|
459 else: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
460 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
|
461 for file in files: |
|
14436
c0509989405e
Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents:
14435
diff
changeset
|
462 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
|
463 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
|
464 else: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
465 dest = os.path.join(base_dir, file) |
|
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
466 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
|
467 |
|
17128
1146070f47ec
Call the write_pkg_info method
Andrew M. Kuchling <amk@amk.ca>
parents:
15216
diff
changeset
|
468 self.distribution.metadata.write_pkg_info(base_dir) |
| 21268 | 469 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
470 # make_release_tree () |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
471 |
|
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
472 def make_distribution (self): |
| 12891 | 473 """Create the source distribution(s). First, we create the release |
| 474 tree with 'make_release_tree()'; then, we create all required | |
| 475 archive files (according to 'self.formats') from the release tree. | |
| 476 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
|
477 'self.keep_temp' is true). The list of archive files created is |
| 12891 | 478 stored so it can be retrieved later by 'get_archive_files()'. |
| 479 """ | |
|
12152
21a9bbb572d7
Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents:
12101
diff
changeset
|
480 # 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
|
481 # 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
|
482 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
|
483 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
|
484 |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
485 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
|
486 archive_files = [] # remember names of files we create |
|
51054
21fb1014294c
Fixed #1885: --formats=tar,gztar was not working properly in the sdist command
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
487 # tar archive must be created last to avoid overwrite and remove |
|
21fb1014294c
Fixed #1885: --formats=tar,gztar was not working properly in the sdist command
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
488 if 'tar' in self.formats: |
|
21fb1014294c
Fixed #1885: --formats=tar,gztar was not working properly in the sdist command
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
489 self.formats.append(self.formats.pop(self.formats.index('tar'))) |
|
21fb1014294c
Fixed #1885: --formats=tar,gztar was not working properly in the sdist command
Tarek Ziadé <ziade.tarek@gmail.com>
parents:
51047
diff
changeset
|
490 |
|
11811
20ca7230ae3f
The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff
changeset
|
491 for fmt in self.formats: |
|
14948
7acb8bbc215b
Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents:
14830
diff
changeset
|
492 file = self.make_archive(base_name, fmt, base_dir=base_dir) |
|
12812
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
493 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
|
494 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
|
495 |
|
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
496 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
|
497 |
|
14830
07288d2db596
Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents:
14829
diff
changeset
|
498 if not self.keep_temp: |
|
23668
ca87119255eb
Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21268
diff
changeset
|
499 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
|
500 |
|
12812
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
501 def get_archive_files (self): |
|
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
502 """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
|
503 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
|
504 """ |
|
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
505 return self.archive_files |
|
0c217e5f055b
Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents:
12804
diff
changeset
|
506 |
|
12743
e878a647e06e
Normalized all the end-of-class lines.
Greg Ward <gward@python.net>
parents:
12495
diff
changeset
|
507 # class sdist |
