annotate Lib/distutils/command/sdist.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents d42374d0aa58
children d12b65a79824
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
33965
893d46576737 Update compatibility comments to 2.1, corresponding to PEP 291 1.13.
Martin v. Löwis <martin@v.loewis.de>
parents: 32166
diff changeset
5 # This module should be kept compatible with Python 2.1.
26285
42bfc98d295b Add comment to Distutil files about requiring 1.5.2 compatibility, as
Andrew M. Kuchling <amk@amk.ca>
parents: 26210
diff changeset
6
11897
017e592c0fd2 Changed '__rcsid__' to '__revision__'.
Greg Ward <gward@python.net>
parents: 11844
diff changeset
7 __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
8
45468
1d84bf5f9478 Patch #2167 from calvin: Remove unused imports
Christian Heimes <christian@cheimes.de>
parents: 45411
diff changeset
9 import os, string
50567
7ac1f6be8ad5 Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 45680
diff changeset
10 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
11 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
12 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
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
13755
632be99cc2cb Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents: 13753
diff changeset
16 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
17 from distutils.filelist import FileList
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
18 from distutils import log
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
19
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
20
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
21 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
22 """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
23 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
24 """
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
25 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
26 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
27 formats=[]
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
28 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
29 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
30 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
31 formats.sort()
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
32 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
33 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
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
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
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
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
40 user_options = [
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
41 ('template=', 't',
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
42 "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
43 ('manifest=', 'm',
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
44 "name of manifest file [default: MANIFEST]"),
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
45 ('use-defaults', None,
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
46 "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
47 "[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
48 ('no-defaults', None,
52d5fb471e17 Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents: 12999
diff changeset
49 "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
50 ('prune', None,
52d5fb471e17 Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents: 12999
diff changeset
51 "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
52 "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
53 "[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
54 ('no-prune', None,
52d5fb471e17 Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents: 12999
diff changeset
55 "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
56 ('manifest-only', 'o',
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
57 "just regenerate the manifest and then stop "
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
58 "(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
59 ('force-manifest', 'f',
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
60 "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
61 ('formats=', None,
12997
27f3a18fd296 Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents: 12983
diff changeset
62 "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
63 ('keep-temp', 'k',
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
64 "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
65 "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
66 ('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
67 "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
68 "[default: dist]"),
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
69 ]
12888
b5752de0cfa4 Cosmetic tweaks to imports, the 'show_formats()' function, and the
Greg Ward <gward@python.net>
parents: 12887
diff changeset
70
14829
b1f220f636ed Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents: 14656
diff changeset
71 boolean_options = ['use-defaults', 'prune',
b1f220f636ed Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents: 14656
diff changeset
72 'manifest-only', 'force-manifest',
14830
07288d2db596 Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents: 14829
diff changeset
73 'keep-temp']
12888
b5752de0cfa4 Cosmetic tweaks to imports, the 'show_formats()' function, and the
Greg Ward <gward@python.net>
parents: 12887
diff changeset
74
12869
88872791998a Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents: 12851
diff changeset
75 help_options = [
88872791998a Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents: 12851
diff changeset
76 ('help-formats', None,
12997
27f3a18fd296 Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents: 12983
diff changeset
77 "list available distribution formats", show_formats),
15216
a3975d2811f0 Untabified.
Greg Ward <gward@python.net>
parents: 14948
diff changeset
78 ]
12869
88872791998a Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents: 12851
diff changeset
79
13111
52d5fb471e17 Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents: 12999
diff changeset
80 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
81 '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
82
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
83 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
84 'nt': 'zip' }
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
85
11817
476eaa38e2d6 Renamed 'set_default_options()' to 'initialize_options()', and
Greg Ward <gward@python.net>
parents: 11815
diff changeset
86 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
87 # '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
88 # 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
89 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
90 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
91
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
92 # '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
93 # 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
94 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
95 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
96
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
97 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
98 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
99
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
100 self.formats = None
14830
07288d2db596 Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents: 14829
diff changeset
101 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
102 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
103
12812
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
104 self.archive_files = None
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
105
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
106
11817
476eaa38e2d6 Renamed 'set_default_options()' to 'initialize_options()', and
Greg Ward <gward@python.net>
parents: 11815
diff changeset
107 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
108 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
109 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
110 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
111 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
112
12851
e787f6641afb Use 'ensure_string_list()' for 'formats' option, so that it can be
Greg Ward <gward@python.net>
parents: 12812
diff changeset
113 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
114 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
115 try:
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 = [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
117 except KeyError:
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
118 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
119 "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
120 "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
121
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
122 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
123 if bad_format:
33ba0626ef72 Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents: 12447
diff changeset
124 raise DistutilsOptionError, \
33ba0626ef72 Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents: 12447
diff changeset
125 "unknown archive format '%s'" % bad_format
33ba0626ef72 Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents: 12447
diff changeset
126
13347
384835ea0a5a Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents: 13111
diff changeset
127 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
128 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
129
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
130
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
131 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
132
13753
84f8579a079c Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents: 13752
diff changeset
133 # '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
134 # manifest
84f8579a079c Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents: 13752
diff changeset
135 self.filelist = FileList()
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 17128
diff changeset
136
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
137 # 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
138 # don't die, it's not *that* serious!)
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
139 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
140
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
141 # 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
142 # (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
143 # whatever). File list is accumulated in 'self.filelist'.
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
144 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
145
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
146 # 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
147 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
148 return
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
149
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
150 # 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
151 # or zipfile, or whatever.
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
152 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
153
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
154
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
155 def check_metadata (self):
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
156 """Ensure that all required elements of meta-data (name, version,
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
157 URL, (author and author_email) or (maintainer and
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
158 maintainer_email)) are supplied by the Distribution object; warn if
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
159 any are missing.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
160 """
12433
8161334942d4 Fix 'check_metadata()' so it grovels through the distribution's metadata
Greg Ward <gward@python.net>
parents: 12431
diff changeset
161 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
162
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
163 missing = []
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
164 for attr in ('name', 'version', 'url'):
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
165 if not (hasattr(metadata, attr) and getattr(metadata, attr)):
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
166 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
167
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
168 if missing:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
169 self.warn("missing required meta-data: " +
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
170 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
171
12433
8161334942d4 Fix 'check_metadata()' so it grovels through the distribution's metadata
Greg Ward <gward@python.net>
parents: 12431
diff changeset
172 if metadata.author:
8161334942d4 Fix 'check_metadata()' so it grovels through the distribution's metadata
Greg Ward <gward@python.net>
parents: 12431
diff changeset
173 if not metadata.author_email:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
174 self.warn("missing meta-data: if 'author' supplied, " +
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
175 "'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
176 elif metadata.maintainer:
8161334942d4 Fix 'check_metadata()' so it grovels through the distribution's metadata
Greg Ward <gward@python.net>
parents: 12431
diff changeset
177 if not metadata.maintainer_email:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
178 self.warn("missing meta-data: if 'maintainer' supplied, " +
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
179 "'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
180 else:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
181 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
182 "or (maintainer and maintainer_email) " +
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
183 "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
184
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
185 # check_metadata ()
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
186
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
187
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
188 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
189 """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
190 distribution, and put it in 'self.filelist'. This might involve
12889
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
191 reading the manifest template (and writing the manifest), or just
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
192 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
193 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
194 """
12983
b544299e68c5 Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents: 12894
diff changeset
195
b544299e68c5 Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents: 12894
diff changeset
196 # 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
197 # 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
198 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
199 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
200 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
201
12983
b544299e68c5 Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents: 12894
diff changeset
202 # 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
203 # 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
204 # 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
205 # 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
206 # 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
207 # 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
208 # 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
209 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
210 (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
211 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
212 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
213
b544299e68c5 Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents: 12894
diff changeset
214 # cases:
b544299e68c5 Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents: 12894
diff changeset
215 # 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
216 # (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
217 # 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
218 # 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
219 # regenerate manifest
b544299e68c5 Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents: 12894
diff changeset
220 # 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
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 # 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
223 # 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
224 # 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
225
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
226 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
227 (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
228 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
229 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
230 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
231
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
232 # 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
233 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
234 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
235 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
236 "(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
237 self.template)
13755
632be99cc2cb Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents: 13753
diff changeset
238 self.filelist.findall()
632be99cc2cb Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents: 13753
diff changeset
239
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 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
241 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
242 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
243 self.read_template()
13111
52d5fb471e17 Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents: 12999
diff changeset
244 if self.prune:
52d5fb471e17 Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents: 12999
diff changeset
245 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
246
13753
84f8579a079c Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents: 13752
diff changeset
247 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
248 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
249 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
250
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
251 # 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
252 else:
13753
84f8579a079c Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents: 13752
diff changeset
253 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
254
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
255 # 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
256
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
257
12892
0c2cdd7cf7dc Renamed 'find_defaults()' to 'add_defaults()'.
Greg Ward <gward@python.net>
parents: 12891
diff changeset
258 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
259 """Add all the default files to self.filelist:
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
260 - README or README.txt
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
261 - setup.py
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
262 - test/test*.py
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
263 - all pure Python modules mentioned in setup script
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
264 - all C sources listed as part of extensions or C libraries
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
265 in the setup script (doesn't catch C headers!)
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
266 Warns if (README or README.txt) or setup.py are missing; everything
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
267 else is optional.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
268 """
12894
61f6acc4aa74 Include setup.cfg in the list of default files to distribute.
Greg Ward <gward@python.net>
parents: 12893
diff changeset
269
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
270 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
271 for fn in standards:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
272 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
273 alts = fn
11844
253ec95f391e Fix from est@hyperreal.org: missing initialize in 'find_defaults()'.
Greg Ward <gward@python.net>
parents: 11817
diff changeset
274 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
275 for fn in alts:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
276 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
277 got_it = 1
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
278 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
279 break
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
280
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
281 if not got_it:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
282 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
283 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
284 else:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
285 if os.path.exists(fn):
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
286 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
287 else:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
288 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
289
12894
61f6acc4aa74 Include setup.cfg in the list of default files to distribute.
Greg Ward <gward@python.net>
parents: 12893
diff changeset
290 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
291 for pattern in optional:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
292 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
293 if files:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
294 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
295
12152
21a9bbb572d7 Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents: 12101
diff changeset
296 if self.distribution.has_pure_modules():
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
297 build_py = self.get_finalized_command('build_py')
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
298 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
299
12152
21a9bbb572d7 Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents: 12101
diff changeset
300 if self.distribution.has_ext_modules():
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
301 build_ext = self.get_finalized_command('build_ext')
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
302 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
303
12298
d640e7d4aec4 Ditched the unused 'list_only' option.
Greg Ward <gward@python.net>
parents: 12152
diff changeset
304 if self.distribution.has_c_libraries():
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
305 build_clib = self.get_finalized_command('build_clib')
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
306 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
307
31852
2cfe14275a04 backport fix for SF bug #796042: sdist ignores scripts argument in setup
Fred Drake <fdrake@acm.org>
parents: 26285
diff changeset
308 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
309 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
310 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
311
12892
0c2cdd7cf7dc Renamed 'find_defaults()' to 'add_defaults()'.
Greg Ward <gward@python.net>
parents: 12891
diff changeset
312 # add_defaults ()
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 17128
diff changeset
313
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
314
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
315 def read_template (self):
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
316 """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
317
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
318 (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
319 'self.filelist', which updates itself accordingly.
12889
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
320 """
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
321 log.info("reading manifest template '%s'", self.template)
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
322 template = TextFile(self.template,
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
323 strip_comments=1,
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
324 skip_blanks=1,
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
325 join_lines=1,
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
326 lstrip_ws=1,
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
327 rstrip_ws=1,
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
328 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
329
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
330 while 1:
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
331 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
332 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
333 break
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
334
13755
632be99cc2cb Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents: 13753
diff changeset
335 try:
632be99cc2cb Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents: 13753
diff changeset
336 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
337 except DistutilsTemplateError, msg:
632be99cc2cb Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents: 13753
diff changeset
338 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
339 template.current_line,
632be99cc2cb Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents: 13753
diff changeset
340 msg))
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
341
12893
fd5881e17427 Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents: 12892
diff changeset
342 # read_template ()
fd5881e17427 Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents: 12892
diff changeset
343
12781
936efdc01d52 Patch from Andrew Kuchling: prune out the build and source distribution
Greg Ward <gward@python.net>
parents: 12743
diff changeset
344
12893
fd5881e17427 Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents: 12892
diff changeset
345 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
346 """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
347 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
348 * 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
349 * 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
350 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
351 * 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
352 """
fd5881e17427 Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents: 12892
diff changeset
353 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
354 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
355
13753
84f8579a079c Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents: 13752
diff changeset
356 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
357 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
358
50567
7ac1f6be8ad5 Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 45680
diff changeset
359 # pruning out vcs directories
7ac1f6be8ad5 Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 45680
diff changeset
360 # both separators are used under win32
50582
057cb46ddaad Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50567
diff changeset
361 if sys.platform == 'win32':
057cb46ddaad Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50567
diff changeset
362 seps = r'/|\\'
057cb46ddaad Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50567
diff changeset
363 else:
057cb46ddaad Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50567
diff changeset
364 seps = '/'
057cb46ddaad Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50567
diff changeset
365
057cb46ddaad Merged revisions 68293 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50567
diff changeset
366 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
367 '_darcs']
50567
7ac1f6be8ad5 Merged revisions 68276 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 45680
diff changeset
368 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
369 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
370
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
371 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
372 """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
373 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
374 named by 'self.manifest'.
12889
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
375 """
13871
8307446bc6aa Fixed imports from '*util' modules to not just import everything from util.
Greg Ward <gward@python.net>
parents: 13755
diff changeset
376 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
377 (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
378 "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
379
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
380 # write_manifest ()
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
381
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
382
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
383 def read_manifest (self):
12889
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
384 """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
385 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
386 distribution.
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
387 """
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
388 log.info("reading manifest file '%s'", self.manifest)
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
389 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
390 while 1:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
391 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
392 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
393 break
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
394 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
395 line = line[0:-1]
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
396 self.filelist.append(line)
45411
80ecf67347e9 Close manifest file.
Andrew M. Kuchling <amk@amk.ca>
parents: 34805
diff changeset
397 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
398
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
399 # read_manifest ()
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 17128
diff changeset
400
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
401
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
402 def make_release_tree (self, base_dir, files):
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
403 """Create the directory tree that will become the source
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
404 distribution archive. All directories implied by the filenames in
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
405 'files' are created under 'base_dir', and then we hard link or copy
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
406 (if hard linking is unavailable) those files into place.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
407 Essentially, this duplicates the developer's source tree, but in a
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
408 directory named after the distribution, containing only the files
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
409 to be distributed.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
410 """
12152
21a9bbb572d7 Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents: 12101
diff changeset
411 # 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
412 # 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
413 # if the manifest happens to be empty.
c0509989405e Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents: 14435
diff changeset
414 self.mkpath(base_dir)
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
415 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
416
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
417 # 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
418 # 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
419 # 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
420 # 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
421 # 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
422 # we're done making the distribution archives.)
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 17128
diff changeset
423
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
424 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
425 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
426 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
427 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
428 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
429 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
430
14436
c0509989405e Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents: 14435
diff changeset
431 if not files:
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
432 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
433 else:
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
434 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
435 for file in files:
14436
c0509989405e Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents: 14435
diff changeset
436 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
437 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
438 else:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
439 dest = os.path.join(base_dir, file)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
440 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
441
17128
1146070f47ec Call the write_pkg_info method
Andrew M. Kuchling <amk@amk.ca>
parents: 15216
diff changeset
442 self.distribution.metadata.write_pkg_info(base_dir)
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 17128
diff changeset
443
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
444 # 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
445
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
446 def make_distribution (self):
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
447 """Create the source distribution(s). First, we create the release
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
448 tree with 'make_release_tree()'; then, we create all required
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
449 archive files (according to 'self.formats') from the release tree.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
450 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
451 'self.keep_temp' is true). The list of archive files created is
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
452 stored so it can be retrieved later by 'get_archive_files()'.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
453 """
12152
21a9bbb572d7 Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents: 12101
diff changeset
454 # 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
455 # 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
456 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
457 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
458
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
459 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
460 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
461 # 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
462 if 'tar' in self.formats:
d42374d0aa58 Merged revisions 68951 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50582
diff changeset
463 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
464
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
465 for fmt in self.formats:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
466 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
467 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
468 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
469
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
470 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
471
14830
07288d2db596 Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents: 14829
diff changeset
472 if not self.keep_temp:
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
473 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
474
12812
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
475 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
476 """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
477 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
478 """
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
479 return self.archive_files
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
480
12743
e878a647e06e Normalized all the end-of-class lines.
Greg Ward <gward@python.net>
parents: 12495
diff changeset
481 # class sdist