Skip to content

Commit f3694a0

Browse files
author
PJ Eby
committed
The sdist command no longer uses the traditional MANIFEST file to
create source distributions. ``MANIFEST.in`` is still read and processed, as are the standard defaults and pruning. But the manifest is built inside the project's ``.egg-info`` directory as ``SOURCES.txt``, and it is rebuilt every time the ``egg_info`` command is run. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041472
1 parent 873ebe9 commit f3694a0

File tree

3 files changed

+84
-21
lines changed

3 files changed

+84
-21
lines changed

setuptools.txt

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,16 +1040,29 @@ revision control, don't create a a ``MANIFEST.in`` file for your project.
10401040
(And, if you already have one, you might consider deleting it the next time
10411041
you would otherwise have to change it.)
10421042

1043-
Unlike the distutils, ``setuptools`` regenerates the source distribution
1044-
``MANIFEST`` file every time you build a source distribution, as long as you
1045-
*don't* have a ``MANIFEST.in`` file. If you do have a ``MANIFEST.in`` (e.g.
1046-
because you aren't using CVS or Subversion), then you'll have to follow the
1047-
normal distutils procedures for managing what files get included in a source
1048-
distribution, and setuptools' enhanced algorithms will *not* be used.
1049-
1050-
(Note, by the way, that if you're using some other revision control system, you
1051-
might consider submitting a patch to the ``setuptools.command.sdist`` module
1052-
so we can include support for it, too.)
1043+
If you need to include automatically generated files, or files that are kept in
1044+
an unsupported revision control system, you'll need to create a ``MANIFEST.in``
1045+
file to specify any files that the default file location algorithm doesn't
1046+
catch. See the distutils documentation for more information on the format of
1047+
the ``MANIFEST.in`` file.
1048+
1049+
But, be sure to ignore any part of the distutils documentation that deals with
1050+
``MANIFEST`` or how it's generated from ``MANIFEST.in``; setuptools shields you
1051+
from these issues and doesn't work the same way in any case. Unlike the
1052+
distutils, setuptools regenerates the source distribution manifest file
1053+
every time you build a source distribution, and it builds it inside the
1054+
project's ``.egg-info`` directory, out of the way of your main project
1055+
directory. You therefore need not worry about whether it is up-to-date or not.
1056+
1057+
Indeed, because setuptools' approach to determining the contents of a source
1058+
distribution is so much simpler, its ``sdist`` command omits nearly all of
1059+
the options that the distutils' more complex ``sdist`` process requires. For
1060+
all practical purposes, you'll probably use only the ``--formats`` option, if
1061+
you use any option at all.
1062+
1063+
(By the way, if you're using some other revision control system, you might
1064+
consider submitting a patch to the ``setuptools.command.sdist`` module,
1065+
so we can include support for your system.)
10531066

10541067

10551068
Making your package available for EasyInstall
@@ -1465,7 +1478,9 @@ commands), and it allows you to temporarily change a project's version string,
14651478
to support "daily builds" or "snapshot" releases. It is run automatically by
14661479
the ``sdist``, ``bdist_egg``, ``develop``, and ``test`` commands in order to
14671480
update the project's metadata, but you can also specify it explicitly in order
1468-
to temporarily change the project's version string.
1481+
to temporarily change the project's version string. (It also generates the
1482+
``.egg-info/SOURCES.txt`` manifest file, which is used when you are building
1483+
source distributions.)
14691484

14701485
The following options can be used to modify the project's version string for
14711486
all remaining commands on the setup command line. The options are processed
@@ -1960,6 +1975,13 @@ XXX
19601975
Release Notes/Change History
19611976
----------------------------
19621977

1978+
0.6a9
1979+
* The ``sdist`` command no longer uses the traditional ``MANIFEST`` file to
1980+
create source distributions. ``MANIFEST.in`` is still read and processed,
1981+
as are the standard defaults and pruning. But the manifest is built inside
1982+
the project's ``.egg-info`` directory as ``SOURCES.txt``, and it is rebuilt
1983+
every time the ``egg_info`` command is run.
1984+
19631985
0.6a8
19641986
* Fixed some problems building extensions when Pyrex was installed, especially
19651987
with Python 2.4 and/or packages using SWIG.

setuptools/command/egg_info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ def write_manifest (self):
246246

247247
def add_defaults(self):
248248
sdist.add_defaults(self)
249-
self.filelist.extend([self.template,self.manifest])
249+
self.filelist.append(self.template)
250+
self.filelist.append(self.manifest)
250251
rcfiles = list(walk_revctrl())
251252
if rcfiles:
252253
self.filelist.extend(rcfiles)
@@ -282,7 +283,6 @@ def prune_file_list (self):
282283

283284

284285

285-
286286

287287

288288
def write_pkg_info(cmd, basename, filename):

setuptools/command/sdist.py

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,67 @@ def externals_finder(dirname, filename):
9393
]
9494

9595

96+
97+
98+
99+
100+
101+
102+
103+
104+
105+
106+
107+
108+
109+
110+
111+
112+
113+
114+
115+
116+
117+
118+
119+
120+
121+
122+
123+
96124
class sdist(_sdist):
97125
"""Smart sdist that finds anything supported by revision control"""
98126

127+
user_options = [
128+
('formats=', None,
129+
"formats for source distribution (comma-separated list)"),
130+
('keep-temp', 'k',
131+
"keep the distribution tree around after creating " +
132+
"archive file(s)"),
133+
('dist-dir=', 'd',
134+
"directory to put the source distribution archive(s) in "
135+
"[default: dist]"),
136+
]
137+
138+
negative_opt = {}
139+
99140
def run(self):
100141
self.run_command('egg_info')
101-
_sdist.run(self)
142+
ei_cmd = self.get_finalized_command('egg_info')
143+
self.filelist = ei_cmd.filelist
144+
self.filelist.append(os.path.join(ei_cmd.egg_info,'SOURCES.txt'))
145+
146+
self.check_metadata()
147+
self.make_distribution()
148+
102149
dist_files = getattr(self.distribution,'dist_files',[])
103150
for file in self.archive_files:
104151
data = ('sdist', '', file)
105152
if data not in dist_files:
106153
dist_files.append(data)
107154

108-
def finalize_options(self):
109-
_sdist.finalize_options(self)
110-
if not os.path.isfile(self.template):
111-
self.force_manifest = 1 # always regen if no template
112155

113-
def add_defaults(self):
114-
_sdist.add_defaults(self)
115-
self.filelist.extend(walk_revctrl())
156+
116157

117158

118159

0 commit comments

Comments
 (0)