annotate Lib/distutils/command/sdist.py @ 79691:05c8928362ee

Merge __next__ method link fixes with 3.3.
author Ezio Melotti <ezio.melotti@gmail.com>
date Fri, 12 Oct 2012 13:46:37 +0300
parents 6cd8c1582dff
children 9e4685d703d4
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
50660
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
5 import os
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
6 import string
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
7 import sys
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
8 from types import *
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 glob import glob
54112
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
10 from warnings import warn
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
11
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
12 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
13 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
14 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
15 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
16 from distutils.filelist import FileList
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
17 from distutils import log
51686
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
18 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
19
54055
7814be6967b8 Merged revisions 72618 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51698
diff changeset
20 def show_formats():
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
21 """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
22 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
23 """
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.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
25 from distutils.archive_util import ARCHIVE_FORMATS
54055
7814be6967b8 Merged revisions 72618 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51698
diff changeset
26 formats = []
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
27 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
28 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
29 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
30 formats.sort()
54055
7814be6967b8 Merged revisions 72618 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51698
diff changeset
31 FancyGetopt(formats).print_help(
12999
7160b52ca74a Changed so all the help-generating functions are defined, at module-level,
Greg Ward <gward@python.net>
parents: 12997
diff changeset
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
54061
391db80d1af4 Merged revisions 72624 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54055
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
54112
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
38 def checking_metadata(self):
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
39 """Callable used for the check sub-command.
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
40
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
41 Placed here so user_options can view it"""
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
42 return self.metadata_check
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
43
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
44 user_options = [
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
45 ('template=', 't',
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
46 "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
47 ('manifest=', 'm',
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
48 "name of manifest file [default: MANIFEST]"),
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
49 ('use-defaults', None,
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
50 "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
51 "[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
52 ('no-defaults', None,
52d5fb471e17 Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents: 12999
diff changeset
53 "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
54 ('prune', None,
52d5fb471e17 Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents: 12999
diff changeset
55 "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
56 "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
57 "[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
58 ('no-prune', None,
52d5fb471e17 Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents: 12999
diff changeset
59 "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
60 ('manifest-only', 'o',
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
61 "just regenerate the manifest and then stop "
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
62 "(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
63 ('force-manifest', 'f',
61666
ff4a968ca7bb Merged revisions 81263 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 61662
diff changeset
64 "forcibly regenerate the manifest and carry on as usual. "
ff4a968ca7bb Merged revisions 81263 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 61662
diff changeset
65 "Deprecated: now the manifest is always regenerated."),
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
66 ('formats=', None,
12997
27f3a18fd296 Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents: 12983
diff changeset
67 "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
68 ('keep-temp', 'k',
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
69 "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
70 "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
71 ('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
72 "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
73 "[default: dist]"),
64648
00425209c46e Merged revisions 84711 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 63967
diff changeset
74 ('metadata-check', None,
54112
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
75 "Ensure that all required elements of meta-data "
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
76 "are supplied. Warn if any missing. [default]"),
11815
03902bc0214a Renamed all 'options' class attributes to 'user_options'.
Greg Ward <gward@python.net>
parents: 11813
diff changeset
77 ]
12888
b5752de0cfa4 Cosmetic tweaks to imports, the 'show_formats()' function, and the
Greg Ward <gward@python.net>
parents: 12887
diff changeset
78
14829
b1f220f636ed Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents: 14656
diff changeset
79 boolean_options = ['use-defaults', 'prune',
b1f220f636ed Added 'boolean_options' list to support config file parsing.
Greg Ward <gward@python.net>
parents: 14656
diff changeset
80 'manifest-only', 'force-manifest',
54112
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
81 'keep-temp', 'metadata-check']
12888
b5752de0cfa4 Cosmetic tweaks to imports, the 'show_formats()' function, and the
Greg Ward <gward@python.net>
parents: 12887
diff changeset
82
12869
88872791998a Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents: 12851
diff changeset
83 help_options = [
88872791998a Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents: 12851
diff changeset
84 ('help-formats', None,
12997
27f3a18fd296 Stylistic/formatting changes to Rene Liebscher's '--help-xxx' patch.
Greg Ward <gward@python.net>
parents: 12983
diff changeset
85 "list available distribution formats", show_formats),
15216
a3975d2811f0 Untabified.
Greg Ward <gward@python.net>
parents: 14948
diff changeset
86 ]
12869
88872791998a Patch from Rene Liebscher: this adds "--help-foo" options to list the
Greg Ward <gward@python.net>
parents: 12851
diff changeset
87
13111
52d5fb471e17 Fixed 'findall()' so it only returns regular files -- no directories.
Greg Ward <gward@python.net>
parents: 12999
diff changeset
88 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
89 '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
90
54061
391db80d1af4 Merged revisions 72624 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54055
diff changeset
91 default_format = {'posix': 'gztar',
391db80d1af4 Merged revisions 72624 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54055
diff changeset
92 'nt': 'zip' }
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
93
54112
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
94 sub_commands = [('check', checking_metadata)]
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
95
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
96 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
97 # '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
98 # 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
99 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
100 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
101
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
102 # '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
103 # 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
104 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
105 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
106
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_only = 0
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
108 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
109
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
110 self.formats = None
14830
07288d2db596 Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents: 14829
diff changeset
111 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
112 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
113
12812
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
114 self.archive_files = None
54112
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
115 self.metadata_check = 1
12812
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
116
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
117 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
118 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
119 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
120 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
121 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
122
12851
e787f6641afb Use 'ensure_string_list()' for 'formats' option, so that it can be
Greg Ward <gward@python.net>
parents: 12812
diff changeset
123 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
124 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
125 try:
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
126 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
127 except KeyError:
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
128 raise DistutilsPlatformError(
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
129 "don't know how to create source distributions "
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
130 "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
131
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
132 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
133 if bad_format:
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
134 raise DistutilsOptionError(
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
135 "unknown archive format '%s'" % bad_format)
12451
33ba0626ef72 Check that 'self.formats' is good early on.
Greg Ward <gward@python.net>
parents: 12447
diff changeset
136
13347
384835ea0a5a Added the --dist-dir option to control where the archive(s) are put;
Greg Ward <gward@python.net>
parents: 13111
diff changeset
137 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
138 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
139
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
140 def run(self):
13753
84f8579a079c Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents: 13752
diff changeset
141 # '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
142 # manifest
84f8579a079c Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents: 13752
diff changeset
143 self.filelist = FileList()
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 17128
diff changeset
144
54112
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
145 # Run sub commands
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
146 for cmd_name in self.get_sub_commands():
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
147 self.run_command(cmd_name)
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
148
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
149 # 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
150 # (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
151 # whatever). File list is accumulated in 'self.filelist'.
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
152 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
153
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
154 # 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
155 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
156 return
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
157
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
158 # 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
159 # or zipfile, or whatever.
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
160 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
161
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
162 def check_metadata(self):
54112
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
163 """Deprecated API."""
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
164 warn("distutils.command.sdist.check_metadata is deprecated, \
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
165 use the check command instead", PendingDeprecationWarning)
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
166 check = self.distribution.get_command_obj('check')
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
167 check.ensure_finalized()
ac660ea35f52 Merged revisions 72681 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54061
diff changeset
168 check.run()
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
169
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
170 def get_file_list(self):
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
171 """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
172 distribution, and put it in 'self.filelist'. This might involve
12889
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
173 reading the manifest template (and writing the manifest), or just
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
174 reading the manifest, or just using the default file set -- it all
61662
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
175 depends on the user's options.
12889
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
176 """
71664
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
177 # new behavior when using a template:
61662
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
178 # the file list is recalculated everytime because
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
179 # even if MANIFEST.in or setup.py are not changed
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
180 # the user might have added some files in the tree that
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
181 # need to be included.
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
182 #
71664
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
183 # This makes --force the default and only behavior with templates.
13753
84f8579a079c Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents: 13752
diff changeset
184 template_exists = os.path.isfile(self.template)
71664
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
185 if not template_exists and self._manifest_is_not_generated():
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
186 self.read_manifest()
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
187 self.filelist.sort()
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
188 self.filelist.remove_duplicates()
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
189 return
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
190
61662
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
191 if not template_exists:
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
192 self.warn(("manifest template '%s' does not exist " +
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
193 "(using default file list)") %
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
194 self.template)
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
195 self.filelist.findall()
12983
b544299e68c5 Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents: 12894
diff changeset
196
61662
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
197 if self.use_defaults:
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
198 self.add_defaults()
12983
b544299e68c5 Fix inspired by Rene Liebscher: if setup script is newer than the
Greg Ward <gward@python.net>
parents: 12894
diff changeset
199
61662
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
200 if template_exists:
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
201 self.read_template()
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
202
61662
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
203 if self.prune:
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
204 self.prune_file_list()
13755
632be99cc2cb Catch syntax errors from processing template lines and turn them into
Greg Ward <gward@python.net>
parents: 13753
diff changeset
205
61662
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
206 self.filelist.sort()
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
207 self.filelist.remove_duplicates()
76643c286b9f Merged revisions 81258 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54112
diff changeset
208 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
209
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
210 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
211 """Add all the default files to self.filelist:
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
212 - README or README.txt
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
213 - setup.py
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
214 - test/test*.py
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
215 - all pure Python modules mentioned in setup script
51671
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
216 - all files pointed by package_data (build_py)
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
217 - all files defined in data_files.
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
218 - all files defined as scripts.
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
219 - all C sources listed as part of extensions or C libraries
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
220 in the setup script (doesn't catch C headers!)
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
221 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
222 else is optional.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
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 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
225 for fn in standards:
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
226 if isinstance(fn, tuple):
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
227 alts = fn
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
228 got_it = False
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
229 for fn in alts:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
230 if os.path.exists(fn):
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
231 got_it = True
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
232 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
233 break
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
234
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
235 if not got_it:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
236 self.warn("standard file not found: should have one of " +
41480
99027c2b3fd2 Remove functions in string module that are also string methods. Also remove:
Neal Norwitz <nnorwitz@gmail.com>
parents: 40587
diff changeset
237 ', '.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
238 else:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
239 if os.path.exists(fn):
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
240 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
241 else:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
242 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
243
12894
61f6acc4aa74 Include setup.cfg in the list of default files to distribute.
Greg Ward <gward@python.net>
parents: 12893
diff changeset
244 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
245 for pattern in optional:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
246 files = filter(os.path.isfile, glob(pattern))
63443
93b3ae63d2f3 Merged revisions 83371,83390 via svnmerge from
Georg Brandl <georg@python.org>
parents: 61666
diff changeset
247 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
248
51671
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
249 # build_py is used to get:
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
250 # - python modules
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
251 # - files defined in package_data
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
252 build_py = self.get_finalized_command('build_py')
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
253
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
254 # 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
255 if self.distribution.has_pure_modules():
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
256 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
257
51671
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
258 # getting package_data files
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
259 # (computed in build_py.data_files by build_py.finalize_options)
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
260 for pkg, src_dir, build_dir, filenames in build_py.data_files:
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
261 for filename in filenames:
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
262 self.filelist.append(os.path.join(src_dir, filename))
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
263
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
264 # getting distribution.data_files
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
265 if self.distribution.has_data_files():
51686
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
266 for item in self.distribution.data_files:
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
267 if isinstance(item, str): # plain file
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
268 item = convert_path(item)
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
269 if os.path.isfile(item):
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
270 self.filelist.append(item)
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
271 else: # a (dirname, filenames) tuple
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
272 dirname, filenames = item
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
273 for f in filenames:
51698
605ffc052b41 Merged revisions 69724 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51686
diff changeset
274 f = convert_path(f)
51686
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
275 if os.path.isfile(f):
257c98fa55d7 Merged revisions 69710 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51671
diff changeset
276 self.filelist.append(f)
51671
54cf68fc7312 Merged revisions 69692 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 51072
diff changeset
277
12152
21a9bbb572d7 Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents: 12101
diff changeset
278 if self.distribution.has_ext_modules():
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
279 build_ext = self.get_finalized_command('build_ext')
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
280 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
281
12298
d640e7d4aec4 Ditched the unused 'list_only' option.
Greg Ward <gward@python.net>
parents: 12152
diff changeset
282 if self.distribution.has_c_libraries():
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
283 build_clib = self.get_finalized_command('build_clib')
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
284 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
285
31852
2cfe14275a04 backport fix for SF bug #796042: sdist ignores scripts argument in setup
Fred Drake <fdrake@acm.org>
parents: 26285
diff changeset
286 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
287 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
288 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
289
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
290 def read_template(self):
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
291 """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
292
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
293 (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
294 'self.filelist', which updates itself accordingly.
12889
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
295 """
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
296 log.info("reading manifest template '%s'", self.template)
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
297 template = TextFile(self.template, strip_comments=1, skip_blanks=1,
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
298 join_lines=1, lstrip_ws=1, rstrip_ws=1,
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
299 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
300
69600
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
301 try:
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
302 while True:
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
303 line = template.readline()
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
304 if line is None: # end of file
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
305 break
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
306
69600
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
307 try:
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
308 self.filelist.process_template_line(line)
72276
6cd8c1582dff Warn instead of crashing because of invalid path in MANIFEST.in (#8286).
Éric Araujo <merwok@netwok.org>
parents: 71664
diff changeset
309 # the call above can raise a DistutilsTemplateError for
6cd8c1582dff Warn instead of crashing because of invalid path in MANIFEST.in (#8286).
Éric Araujo <merwok@netwok.org>
parents: 71664
diff changeset
310 # malformed lines, or a ValueError from the lower-level
6cd8c1582dff Warn instead of crashing because of invalid path in MANIFEST.in (#8286).
Éric Araujo <merwok@netwok.org>
parents: 71664
diff changeset
311 # convert_path function
6cd8c1582dff Warn instead of crashing because of invalid path in MANIFEST.in (#8286).
Éric Araujo <merwok@netwok.org>
parents: 71664
diff changeset
312 except (DistutilsTemplateError, ValueError) as msg:
69600
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
313 self.warn("%s, line %d: %s" % (template.filename,
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
314 template.current_line,
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
315 msg))
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
316 finally:
316d792bf75b Fix resource warning found manually
Éric Araujo <merwok@netwok.org>
parents: 64648
diff changeset
317 template.close()
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
318
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
319 def prune_file_list(self):
12893
fd5881e17427 Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents: 12892
diff changeset
320 """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
321 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
322 * 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
323 * 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
324 previously with --keep-temp, or it aborted)
45773
832c820e9d14 Merged revisions 61239-61249,61252-61257,61260-61264,61269-61275,61278-61279,61285-61286,61288-61290,61298,61303-61305,61312-61314,61317,61329,61332,61344,61350-61351,61363-61376,61378-61379,61382-61383,61387-61388,61392,61395-61396,61402-61403 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45435
diff changeset
325 * 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
326 """
fd5881e17427 Moved the code that prunes the file list after reading the manifest
Greg Ward <gward@python.net>
parents: 12892
diff changeset
327 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
328 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
329
13753
84f8579a079c Replaced 'self.files' with 'self.filelist': now we carry around a FileList
Greg Ward <gward@python.net>
parents: 13752
diff changeset
330 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
331 self.filelist.exclude_pattern(None, prefix=base_dir)
50660
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
332
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
333 if sys.platform == 'win32':
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
334 seps = r'/|\\'
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
335 else:
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
336 seps = '/'
12887
11d10e9b508d Made all debug output go through the 'debug_print()' method instead of
Greg Ward <gward@python.net>
parents: 12869
diff changeset
337
50660
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
338 vcs_dirs = ['RCS', 'CVS', r'\.svn', r'\.hg', r'\.git', r'\.bzr',
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
339 '_darcs']
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
340 vcs_ptrn = r'(^|%s)(%s)(%s).*' % (seps, '|'.join(vcs_dirs), seps)
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
341 self.filelist.exclude_pattern(vcs_ptrn, is_regex=1)
9d093ef89c56 Merged revisions 68440 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 45773
diff changeset
342
54061
391db80d1af4 Merged revisions 72624 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 54055
diff changeset
343 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
344 """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
345 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
346 named by 'self.manifest'.
12889
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
347 """
71664
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
348 if self._manifest_is_not_generated():
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
349 log.info("not writing to manually maintained "
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
350 "manifest file '%s'" % self.manifest)
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
351 return
63967
d54da9248ed9 Merged revisions 83993 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 63443
diff changeset
352
d54da9248ed9 Merged revisions 83993 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 63443
diff changeset
353 content = self.filelist.files[:]
d54da9248ed9 Merged revisions 83993 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 63443
diff changeset
354 content.insert(0, '# file GENERATED by distutils, do NOT edit')
d54da9248ed9 Merged revisions 83993 via svnmerge from
Éric Araujo <merwok@netwok.org>
parents: 63443
diff changeset
355 self.execute(file_util.write_file, (self.manifest, content),
12887
11d10e9b508d Made all debug output go through the 'debug_print()' method instead of
Greg Ward <gward@python.net>
parents: 12869
diff changeset
356 "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
357
71664
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
358 def _manifest_is_not_generated(self):
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
359 # check for special comment used in 3.1.3 and higher
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
360 if not os.path.isfile(self.manifest):
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
361 return False
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
362
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
363 fp = open(self.manifest)
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
364 try:
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
365 first_line = fp.readline()
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
366 finally:
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
367 fp.close()
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
368 return first_line != '# file GENERATED by distutils, do NOT edit\n'
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
369
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
370 def read_manifest(self):
12889
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
371 """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
372 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
373 distribution.
f54c3677bae7 Docstring reformatting binge.
Greg Ward <gward@python.net>
parents: 12888
diff changeset
374 """
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
375 log.info("reading manifest file '%s'", self.manifest)
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
376 manifest = open(self.manifest)
71664
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
377 for line in manifest:
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
378 # ignore comments and blank lines
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
379 line = line.strip()
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
380 if line.startswith('#') or not line:
5d3e22d69d4f Fix regression with distutils MANIFEST handing (#11104, #8688).
Éric Araujo <merwok@netwok.org>
parents: 71540
diff changeset
381 continue
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
382 self.filelist.append(line)
45435
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 43026
diff changeset
383 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
384
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
385 def make_release_tree(self, base_dir, files):
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
386 """Create the directory tree that will become the source
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
387 distribution archive. All directories implied by the filenames in
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
388 '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
389 (if hard linking is unavailable) those files into place.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
390 Essentially, this duplicates the developer's source tree, but in a
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
391 directory named after the distribution, containing only the files
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
392 to be distributed.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
393 """
12152
21a9bbb572d7 Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents: 12101
diff changeset
394 # 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
395 # 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
396 # if the manifest happens to be empty.
c0509989405e Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents: 14435
diff changeset
397 self.mkpath(base_dir)
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
398 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
399
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
400 # 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
401 # 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
402 # 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
403 # 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
404 # 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
405 # we're done making the distribution archives.)
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 17128
diff changeset
406
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
407 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
408 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
409 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
410 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
411 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
412 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
413
14436
c0509989405e Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents: 14435
diff changeset
414 if not files:
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
415 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
416 else:
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
417 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
418 for file in files:
14436
c0509989405e Bullet-proofing of 'make_release_tree()':
Greg Ward <gward@python.net>
parents: 14435
diff changeset
419 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
420 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
421 else:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
422 dest = os.path.join(base_dir, file)
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
423 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
424
17128
1146070f47ec Call the write_pkg_info method
Andrew M. Kuchling <amk@amk.ca>
parents: 15216
diff changeset
425 self.distribution.metadata.write_pkg_info(base_dir)
21268
d296e6bb17e5 Whitespace normalization.
Fred Drake <fdrake@acm.org>
parents: 17128
diff changeset
426
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
427 def make_distribution(self):
12891
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
428 """Create the source distribution(s). First, we create the release
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
429 tree with 'make_release_tree()'; then, we create all required
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
430 archive files (according to 'self.formats') from the release tree.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
431 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
432 '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
433 stored so it can be retrieved later by 'get_archive_files()'.
0c8b9f96b26a Docstring addition binge.
Greg Ward <gward@python.net>
parents: 12889
diff changeset
434 """
12152
21a9bbb572d7 Changed to use the new 'has_pure_modules()' and 'has_ext_modules()' methods
Greg Ward <gward@python.net>
parents: 12101
diff changeset
435 # 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
436 # 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
437 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
438 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
439
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
440 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
441 archive_files = [] # remember names of files we create
51072
b04896caa29b Merged revisions 68969 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50660
diff changeset
442 # tar archive must be created last to avoid overwrite and remove
b04896caa29b Merged revisions 68969 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50660
diff changeset
443 if 'tar' in self.formats:
b04896caa29b Merged revisions 68969 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50660
diff changeset
444 self.formats.append(self.formats.pop(self.formats.index('tar')))
b04896caa29b Merged revisions 68969 via svnmerge from
Tarek Ziadé <ziade.tarek@gmail.com>
parents: 50660
diff changeset
445
11811
20ca7230ae3f The 'sdist' command to create a source distribution. This is derived from the
Greg Ward <gward@python.net>
parents:
diff changeset
446 for fmt in self.formats:
14948
7acb8bbc215b Standardized whitespace around function calls.
Greg Ward <gward@python.net>
parents: 14830
diff changeset
447 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
448 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
449 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
450
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
451 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
452
14830
07288d2db596 Renamed '--keep-tree' option to '--keep-temp', for consistency
Greg Ward <gward@python.net>
parents: 14829
diff changeset
453 if not self.keep_temp:
23668
ca87119255eb Make setup.py less chatty by default.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 21268
diff changeset
454 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
455
43026
a6d3930b5613 General cleanup, raise normalization in Lib/distutils.
Collin Winter <collinw@gmail.com>
parents: 41480
diff changeset
456 def get_archive_files(self):
12812
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
457 """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
458 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
459 """
0c217e5f055b Remember the list of archive files created in 'make_distribution()'.
Greg Ward <gward@python.net>
parents: 12804
diff changeset
460 return self.archive_files