From d3add44007ad72fc795297dd208d9a37ac4b54a3 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Thu, 7 Jul 2005 02:03:25 +0000 Subject: Beefed up the "sdist" command so that if you don't have a MANIFEST.in, it will include all files under revision control (CVS or Subversion) in the current directory, and it will regenerate the list every time you create a source distribution, not just when you tell it to. This should make the default "do what you mean" more often than the distutils' default behavior did, while still retaining the old behavior in the presence of MANIFEST.in. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041087 --- setuptools/command/sdist.py | 82 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 setuptools/command/sdist.py (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py new file mode 100755 index 00000000..b39df36f --- /dev/null +++ b/setuptools/command/sdist.py @@ -0,0 +1,82 @@ +from distutils.command.sdist import sdist as _sdist +from distutils.util import convert_path +import os,re + +entities = [ + ("<","<"), (">", ">"), (""", '"'), ("'", "'"), + ("&", "&") +] +def unescape(data): + for old,new in entities: + data = data.replace(old,new) + return data + +patterns = [ + (convert_path('CVS/Entries'), re.compile(r"^\w?/([^/]+)/", re.M), None), + (convert_path('.svn/entries'), re.compile(r'name="([^"]+)"'), unescape), +] + +def joinpath(prefix,suffix): + if not prefix: + return suffix + return os.path.join(prefix,suffix) + + + + + + + + + + + + + + + + + + + +def walk_revctrl(dirname='', memo=None): + """Find all files under revision control""" + if memo is None: + memo = {} + if dirname in memo: + # Don't rescan a scanned directory + return + for path, pattern, postproc in patterns: + path = joinpath(dirname,path) + if os.path.isfile(path): + f = open(path,'rU') + data = f.read() + f.close() + for match in pattern.finditer(data): + path = match.group(1) + if postproc: + path = postproc(path) + path = joinpath(dirname,path) + if os.path.isfile(path): + yield path + elif os.path.isdir(path): + for item in walk_revctrl(path, memo): + yield item + +class sdist(_sdist): + """Smart sdist that finds anything supported by revision control""" + def finalize_options(self): + _sdist.finalize_options(self) + if not os.path.isfile(self.template): + self.force_manifest = 1 # always regen if no template + + def add_defaults(self): + _sdist.add_defaults(self) + self.filelist.extend(walk_revctrl()) + + + + + + + -- cgit v1.2.1 From c1112aa5fb7da9996e5a0ebe8689e5cf9ca72cee Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Thu, 7 Jul 2005 16:28:43 +0000 Subject: Add upload support to setuptools, and make default downloads of setuptools come from PyPI/python.org rather than from telecommunity.com. Bump to version 0.5a7. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041090 --- setuptools/command/sdist.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index b39df36f..3891526d 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -63,8 +63,34 @@ def walk_revctrl(dirname='', memo=None): for item in walk_revctrl(path, memo): yield item + + + + + + + + + + + + + + + + + class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" + + def run(self): + _sdist.run(self) + dist_files = getattr(self.distribution,'dist_files',[]) + for file in self.archive_files: + data = ('sdist', '', file) + if data not in dist_files: + dist_files.append(data) + def finalize_options(self): _sdist.finalize_options(self) if not os.path.isfile(self.template): @@ -78,5 +104,20 @@ class sdist(_sdist): + + + + + + + + + + + + + + + -- cgit v1.2.1 From 6050f5361738831a12debd373b9016a077e930df Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 8 Jul 2005 05:09:23 +0000 Subject: Added support for defining command aliases in distutils configuration files, under the "[aliases]" section. To prevent recursion and to allow aliases to call the command of the same name, a given alias can be expanded only once per command-line invocation. You can define new aliases with the "alias" command, either for the local, global, or per-user configuration. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041094 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 3891526d..673255bb 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -84,6 +84,7 @@ class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" def run(self): + self.run_command('egg_info') _sdist.run(self) dist_files = getattr(self.distribution,'dist_files',[]) for file in self.archive_files: @@ -118,6 +119,5 @@ class sdist(_sdist): - -- cgit v1.2.1 From 72de8511ab1a6d622fc2bf8ee2c38440ba140ac3 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 9 Jul 2005 04:21:22 +0000 Subject: Include ``svn:externals`` directories in source distributions as well as normal subversion-controlled files and directories. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041101 --- setuptools/command/sdist.py | 84 ++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 673255bb..425ed8ba 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -6,15 +6,23 @@ entities = [ ("<","<"), (">", ">"), (""", '"'), ("'", "'"), ("&", "&") ] + def unescape(data): for old,new in entities: data = data.replace(old,new) return data -patterns = [ - (convert_path('CVS/Entries'), re.compile(r"^\w?/([^/]+)/", re.M), None), - (convert_path('.svn/entries'), re.compile(r'name="([^"]+)"'), unescape), -] +def re_finder(pattern, postproc=None): + def find(dirname, filename): + f = open(filename,'rU') + data = f.read() + f.close() + for match in pattern.finditer(data): + path = match.group(1) + if postproc: + path = postproc(path) + yield joinpath(dirname,path) + return find def joinpath(prefix,suffix): if not prefix: @@ -31,14 +39,6 @@ def joinpath(prefix,suffix): - - - - - - - - def walk_revctrl(dirname='', memo=None): """Find all files under revision control""" if memo is None: @@ -46,38 +46,47 @@ def walk_revctrl(dirname='', memo=None): if dirname in memo: # Don't rescan a scanned directory return - for path, pattern, postproc in patterns: + for path, finder in finders: path = joinpath(dirname,path) if os.path.isfile(path): - f = open(path,'rU') - data = f.read() - f.close() - for match in pattern.finditer(data): - path = match.group(1) - if postproc: - path = postproc(path) - path = joinpath(dirname,path) + for path in finder(dirname,path): if os.path.isfile(path): yield path elif os.path.isdir(path): for item in walk_revctrl(path, memo): yield item +def externals_finder(dirname, filename): + """Find any 'svn:externals' directories""" + found = False + f = open(filename,'rb') + for line in iter(f.readline, ''): # can't use direct iter! + parts = line.split() + if len(parts)==2: + kind,length = parts + data = f.read(int(length)) + if kind=='K' and data=='svn:externals': + found = True + elif kind=='V' and found: + f.close() + break + else: + f.close() + return + for line in data.splitlines(): + parts = line.split() + if parts: + yield joinpath(dirname, parts[0]) - - - - - - - - - - - - +finders = [ + (convert_path('CVS/Entries'), + re_finder(re.compile(r"^\w?/([^/]+)/", re.M))), + (convert_path('.svn/entries'), + re_finder(re.compile(r'name="([^"]+)"'), unescape)), + (convert_path('.svn/dir-props'), externals_finder), +] class sdist(_sdist): @@ -111,13 +120,4 @@ class sdist(_sdist): - - - - - - - - - -- cgit v1.2.1 From 01972d44570029e8b54ce3719a83a5f2d81f2d8b Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 6 Aug 2005 16:26:44 +0000 Subject: Fix wrongly including files that Subversion has marked deleted. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041177 --- setuptools/command/sdist.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 425ed8ba..cdbc5248 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -84,7 +84,11 @@ finders = [ (convert_path('CVS/Entries'), re_finder(re.compile(r"^\w?/([^/]+)/", re.M))), (convert_path('.svn/entries'), - re_finder(re.compile(r'name="([^"]+)"'), unescape)), + re_finder( + re.compile(r'name="([^"]+)"(?![^>]+deleted="true")', re.I), + unescape + ) + ), (convert_path('.svn/dir-props'), externals_finder), ] @@ -117,7 +121,3 @@ class sdist(_sdist): - - - - -- cgit v1.2.1 From f3694a0388e4e15d9cbdd84e4c8ca7817c87a52c Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 18 Nov 2005 03:45:16 +0000 Subject: 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 --- setuptools/command/sdist.py | 57 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 8 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index cdbc5248..41798b60 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -93,26 +93,67 @@ finders = [ ] + + + + + + + + + + + + + + + + + + + + + + + + + + + + class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" + user_options = [ + ('formats=', None, + "formats for source distribution (comma-separated list)"), + ('keep-temp', 'k', + "keep the distribution tree around after creating " + + "archive file(s)"), + ('dist-dir=', 'd', + "directory to put the source distribution archive(s) in " + "[default: dist]"), + ] + + negative_opt = {} + def run(self): self.run_command('egg_info') - _sdist.run(self) + ei_cmd = self.get_finalized_command('egg_info') + self.filelist = ei_cmd.filelist + self.filelist.append(os.path.join(ei_cmd.egg_info,'SOURCES.txt')) + + self.check_metadata() + self.make_distribution() + dist_files = getattr(self.distribution,'dist_files',[]) for file in self.archive_files: data = ('sdist', '', file) if data not in dist_files: dist_files.append(data) - def finalize_options(self): - _sdist.finalize_options(self) - if not os.path.isfile(self.template): - self.force_manifest = 1 # always regen if no template - def add_defaults(self): - _sdist.add_defaults(self) - self.filelist.extend(walk_revctrl()) + -- cgit v1.2.1 From 7c9b80ed90ea760e026d634c5ad1fbc6eb62cb0d Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Tue, 21 Feb 2006 22:44:58 +0000 Subject: Prevent failed attempts at removing MANIFEST.in from masking errors that occur while reading it. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4042548 --- setuptools/command/sdist.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 41798b60..9a0ea032 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -1,6 +1,6 @@ from distutils.command.sdist import sdist as _sdist from distutils.util import convert_path -import os,re +import os, re, sys entities = [ ("<","<"), (">", ">"), (""", '"'), ("'", "'"), @@ -152,13 +152,13 @@ class sdist(_sdist): if data not in dist_files: dist_files.append(data) - - - - - - - - - + def read_template(self): + try: + _sdist.read_template(self) + except: + # grody hack to close the template file (MANIFEST.in) + # this prevents easy_install's attempt at deleting the file from + # dying and thus masking the real error + sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() + raise -- cgit v1.2.1 From 97d43ce576112fdda6d2fa1cecf4b46cc85b04c2 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 29 Mar 2006 22:23:38 +0000 Subject: Added ``setuptools.file_finders`` entry point group to allow implementing revision control plugins. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4043428 --- setuptools/command/sdist.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 9a0ea032..6026a7c2 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -1,6 +1,6 @@ from distutils.command.sdist import sdist as _sdist from distutils.util import convert_path -import os, re, sys +import os, re, sys, pkg_resources entities = [ ("<","<"), (">", ">"), (""", '"'), ("'", "'"), @@ -39,13 +39,13 @@ def joinpath(prefix,suffix): -def walk_revctrl(dirname='', memo=None): +def walk_revctrl(dirname=''): """Find all files under revision control""" - if memo is None: - memo = {} - if dirname in memo: - # Don't rescan a scanned directory - return + for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): + for item in ep.load()(dirname): + yield item + +def _default_revctrl(dirname=''): for path, finder in finders: path = joinpath(dirname,path) if os.path.isfile(path): @@ -53,7 +53,7 @@ def walk_revctrl(dirname='', memo=None): if os.path.isfile(path): yield path elif os.path.isdir(path): - for item in walk_revctrl(path, memo): + for item in _default_revctrl(path): yield item def externals_finder(dirname, filename): -- cgit v1.2.1 From ece23fd51b6eb14ea4a5853ad1a7f315d76ddcf5 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Mon, 10 Jul 2006 21:17:16 +0000 Subject: Fixed redundant warnings about missing ``README`` file(s); it should now appear only if you are actually a source distribution. (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4050544 --- setuptools/command/sdist.py | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 6026a7c2..0292efe2 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -142,9 +142,9 @@ class sdist(_sdist): ei_cmd = self.get_finalized_command('egg_info') self.filelist = ei_cmd.filelist self.filelist.append(os.path.join(ei_cmd.egg_info,'SOURCES.txt')) - + self.check_readme() self.check_metadata() - self.make_distribution() + self.make_distribution() dist_files = getattr(self.distribution,'dist_files',[]) for file in self.archive_files: @@ -162,3 +162,44 @@ class sdist(_sdist): sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() raise + def check_readme(self): + alts = ("README", "README.txt") + for f in alts: + if os.path.exists(f): + return + else: + self.warn( + "standard file not found: should have one of " +', '.join(alts) + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +# -- cgit v1.2.1 From 3536c85d4ef8a3e879a4c6e2ae87fff8c3bfec12 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Tue, 18 Jul 2006 16:55:23 +0000 Subject: Source distributions now always include a ``setup.cfg`` file that explicitly sets ``egg_info`` options such that they produce an identical version number to the source distribution's version number. (Previously, the default version number could be different due to the use of ``--tag-date``, or if the version was overridden on the command line that built the source distribution.) (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4050703 --- setuptools/command/sdist.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 0292efe2..4cc0ae1f 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -173,18 +173,18 @@ class sdist(_sdist): ) - - - - - - - - - - - - + def make_release_tree(self, base_dir, files): + _sdist.make_release_tree(self, base_dir, files) + + # Save any egg_info command line options used to create this sdist + dest = os.path.join(base_dir, 'setup.cfg') + if hasattr(os,'link') and os.path.exists(dest): + # unlink and re-copy, since it might be hard-linked, and + # we don't want to change the source version + os.unlink(dest) + self.copy_file('setup.cfg', dest) + + self.get_finalized_command('egg_info').save_version_info(dest) -- cgit v1.2.1 From 7231e48929b6f4026bb14307185a5837bda115fa Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sun, 17 Sep 2006 16:20:47 +0000 Subject: Support svn 1.4 working copy format (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4051900 --- setuptools/command/sdist.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 4cc0ae1f..fc5bdfb2 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -80,16 +80,31 @@ def externals_finder(dirname, filename): yield joinpath(dirname, parts[0]) +entries_pattern = re.compile(r'name="([^"]+)"(?![^>]+deleted="true")', re.I) + +def entries_finder(dirname, filename): + f = open(filename,'rU') + data = f.read() + f.close() + if data.startswith('8'): # subversion 1.4 + for record in map(str.splitlines, data.split('\n\x0c\n')[1:]): + if not record or len(record)>=6 and record[5]=="delete": + continue # skip deleted + yield joinpath(dirname, record[0]) + elif data.startswith(']+deleted="true")', re.I), - unescape - ) - ), + (convert_path('.svn/entries'), entries_finder), (convert_path('.svn/dir-props'), externals_finder), + (convert_path('.svn/dir-prop-base'), externals_finder), # svn 1.4 ] @@ -100,21 +115,6 @@ finders = [ - - - - - - - - - - - - - - - -- cgit v1.2.1 From 1286031284718b85ce85465a583724b53373cd04 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Tue, 26 Sep 2006 20:19:21 +0000 Subject: Should've used distutils.log.warn instead of warnings.warn (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4052009 --- setuptools/command/sdist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index fc5bdfb2..2b1d117e 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -95,8 +95,7 @@ def entries_finder(dirname, filename): for match in entries_pattern.finditer(data): yield joinpath(dirname,unescape(match.group(1))) else: - from warnings import warn - warn("unrecognized .svn/entries format in "+dirname) + log.warn("unrecognized .svn/entries format in %s", dirname) finders = [ @@ -121,6 +120,7 @@ finders = [ + class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" -- cgit v1.2.1 From 601add2805c394928b7dd9d2156d24508a9bddb6 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 15 Feb 2008 23:53:18 +0000 Subject: Fix ``resource_listdir('')`` always returning an empty list for zipped eggs. Fix missing import in sdist command when encountering unrecognized SVN entries format. (backports from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4060849 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 2b1d117e..40c5a7c4 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -1,5 +1,6 @@ from distutils.command.sdist import sdist as _sdist from distutils.util import convert_path +from distutils import log import os, re, sys, pkg_resources entities = [ @@ -38,7 +39,6 @@ def joinpath(prefix,suffix): - def walk_revctrl(dirname=''): """Find all files under revision control""" for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): -- cgit v1.2.1 From 5f352d4b975db613a285083ef34ebba48ebe2f8a Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 16 Jul 2008 13:58:49 +0000 Subject: Support subversion 1.5 (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4065015 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 40c5a7c4..5bd5ebd4 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -86,7 +86,7 @@ def entries_finder(dirname, filename): f = open(filename,'rU') data = f.read() f.close() - if data.startswith('8'): # subversion 1.4 + if data.startswith('9') or data.startswith('8'): # subversion 1.5/1.4 for record in map(str.splitlines, data.split('\n\x0c\n')[1:]): if not record or len(record)>=6 and record[5]=="delete": continue # skip deleted -- cgit v1.2.1 From ea777e738fc4b9bfb1e019ff606cd0941c28d531 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarek=20Ziad=C3=A9?= Date: Thu, 16 Jul 2009 11:04:39 +0200 Subject: #1 Added compatibility with Subversion 1.6. --HG-- branch : distribute extra : rebase_source : 40579bb8174f21d24968ce698711c66f624c0839 --- setuptools/command/sdist.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 5bd5ebd4..9f692493 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -86,8 +86,9 @@ def entries_finder(dirname, filename): f = open(filename,'rU') data = f.read() f.close() - if data.startswith('9') or data.startswith('8'): # subversion 1.5/1.4 + if data.startswith('10') or data.startswith('9') or data.startswith('8'): for record in map(str.splitlines, data.split('\n\x0c\n')[1:]): + # subversion 1.6/1.5/1.4 if not record or len(record)>=6 and record[5]=="delete": continue # skip deleted yield joinpath(dirname, record[0]) -- cgit v1.2.1 From 8757d946ddef2c53c9da39f207d79024d6f4d968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tarek=20Ziad=C3=A9?= Date: Thu, 16 Jul 2009 11:14:01 +0200 Subject: #2 fixed setuptools for 2.7 (current trunk) --HG-- branch : distribute extra : rebase_source : c0d03d39e1e5cdfc10d64fe2902ba583b93ef0ba --- setuptools/command/sdist.py | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 9f692493..50c4c009 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -2,6 +2,7 @@ from distutils.command.sdist import sdist as _sdist from distutils.util import convert_path from distutils import log import os, re, sys, pkg_resources +from glob import glob entities = [ ("<","<"), (">", ">"), (""", '"'), ("'", "'"), @@ -153,6 +154,51 @@ class sdist(_sdist): if data not in dist_files: dist_files.append(data) + def add_defaults(self): + standards = [('README', 'README.txt'), + self.distribution.script_name] + for fn in standards: + if isinstance(fn, tuple): + alts = fn + got_it = 0 + for fn in alts: + if os.path.exists(fn): + got_it = 1 + self.filelist.append(fn) + break + + if not got_it: + self.warn("standard file not found: should have one of " + + ', '.join(alts)) + else: + if os.path.exists(fn): + self.filelist.append(fn) + else: + self.warn("standard file '%s' not found" % fn) + + optional = ['test/test*.py', 'setup.cfg'] + for pattern in optional: + files = filter(os.path.isfile, glob(pattern)) + if files: + self.filelist.extend(files) + + # getting python files + if self.distribution.has_pure_modules(): + build_py = self.get_finalized_command('build_py') + self.filelist.extend(build_py.get_source_files()) + + if self.distribution.has_ext_modules(): + build_ext = self.get_finalized_command('build_ext') + self.filelist.extend(build_ext.get_source_files()) + + if self.distribution.has_c_libraries(): + build_clib = self.get_finalized_command('build_clib') + self.filelist.extend(build_clib.get_source_files()) + + if self.distribution.has_scripts(): + build_scripts = self.get_finalized_command('build_scripts') + self.filelist.extend(build_scripts.get_source_files()) + def read_template(self): try: _sdist.read_template(self) -- cgit v1.2.1 From 99ab2076b4e84718f9b034ab4e1394fd06d468f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sun, 13 Sep 2009 00:08:20 +0200 Subject: Open svn externals file in text mode. --HG-- branch : distribute extra : rebase_source : 0eec0f04099a978136350d3546c579bbd61ea6ec --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 50c4c009..3442fe4b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -60,7 +60,7 @@ def _default_revctrl(dirname=''): def externals_finder(dirname, filename): """Find any 'svn:externals' directories""" found = False - f = open(filename,'rb') + f = open(filename,'rt') for line in iter(f.readline, ''): # can't use direct iter! parts = line.split() if len(parts)==2: -- cgit v1.2.1 From 58a658b26d1c95b31d02050dcccd648d2e4ce27b Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Mon, 20 Jun 2011 22:55:16 +0100 Subject: Changes to support 2.x and 3.x in the same codebase. --HG-- branch : distribute extra : rebase_source : 7d3608edee54a43789f0574d702fb839628b5071 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 3442fe4b..499a3fb9 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -178,7 +178,7 @@ class sdist(_sdist): optional = ['test/test*.py', 'setup.cfg'] for pattern in optional: - files = filter(os.path.isfile, glob(pattern)) + files = list(filter(os.path.isfile, glob(pattern))) if files: self.filelist.extend(files) -- cgit v1.2.1 From 5e53787185059a78874e2f730c431ec611b0b8e7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 20 Jan 2012 14:11:03 -0500 Subject: Remove grody hack for later versions of Python where it is no longer necessary. Fixes #269. --HG-- branch : distribute extra : rebase_source : c4f18c8760303a2228baf5b88ec1f59a865999a5 --- setuptools/command/sdist.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 3442fe4b..c49839cd 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -199,15 +199,25 @@ class sdist(_sdist): build_scripts = self.get_finalized_command('build_scripts') self.filelist.extend(build_scripts.get_source_files()) - def read_template(self): + def __read_template_hack(self): + # This grody hack closes the template file (MANIFEST.in) if an + # exception occurs during read_template. + # Doing so prevents an error when easy_install attempts to delete the + # file. try: _sdist.read_template(self) except: - # grody hack to close the template file (MANIFEST.in) - # this prevents easy_install's attempt at deleting the file from - # dying and thus masking the real error sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() raise + # Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle + # has been fixed, so only override the method if we're using an earlier + # Python. + if ( + sys.version_info < (2,7,2) + or (3,0) <= sys.version_info < (3,1,4) + or (3,2) <= sys.version_info < (3,2,1) + ): + read_template = __read_template_hack def check_readme(self): alts = ("README", "README.txt") -- cgit v1.2.1 From f6cb3d29d919ff6b9313b8a3281c66cfb368c29b Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Mon, 13 Feb 2012 16:22:33 -0500 Subject: This allows the sdist command to ensure that any files listed in package_data are included in the dist, regardless of whether it's under version control, as is the case with distutil's sdist. Setting include_package_data=True disables this functionality. --HG-- branch : distribute extra : rebase_source : 2cae1675c638dc12fd556368074c6b5c691c6f58 --- setuptools/command/sdist.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index c49839cd..484f8276 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -186,6 +186,14 @@ class sdist(_sdist): if self.distribution.has_pure_modules(): build_py = self.get_finalized_command('build_py') self.filelist.extend(build_py.get_source_files()) + # This functionality is incompatible with include_package_data, and + # will in fact create an infinite recursion if include_package_data + # is True. Use of include_package_data will imply that + # distutils-style automatic handling of package_data is disabled + if not self.distribution.include_package_data: + for _, src_dir, _, filenames in build_py.data_files: + self.filelist.extend([os.path.join(src_dir, filename) + for filename in filenames]) if self.distribution.has_ext_modules(): build_ext = self.get_finalized_command('build_ext') -- cgit v1.2.1 From 76f2440a4dad4038f4d3aadcd64e33e9ef22ad6e Mon Sep 17 00:00:00 2001 From: Alex Clark Date: Sun, 22 Apr 2012 21:41:29 -0400 Subject: README.rst is now a standard --HG-- branch : distribute extra : rebase_source : 261a30d0a7ec63b1ff4918d7906476a19945b288 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index c49839cd..1f88e93b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -155,7 +155,7 @@ class sdist(_sdist): dist_files.append(data) def add_defaults(self): - standards = [('README', 'README.txt'), + standards = [('README', 'README.rst', 'README.txt'), self.distribution.script_name] for fn in standards: if isinstance(fn, tuple): -- cgit v1.2.1 From a3b6b2bba70b44b62865e6474e5a007400d62884 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 14:14:07 +0200 Subject: Issue #307: Prints the full path when .svn/entries is broken. --HG-- branch : distribute extra : rebase_source : 1836125ab8204364c8fb197d7c20c296a25f89c0 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 1f88e93b..edb3b7f3 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -97,7 +97,7 @@ def entries_finder(dirname, filename): for match in entries_pattern.finditer(data): yield joinpath(dirname,unescape(match.group(1))) else: - log.warn("unrecognized .svn/entries format in %s", dirname) + log.warn("unrecognized .svn/entries format in %s", os.path.abspath(dirname)) finders = [ -- cgit v1.2.1 From cafaa3bd07185df0c17a19edee8820494d34267c Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 14:25:48 +0200 Subject: Merged the two lists of acceptable names of README.txt --HG-- branch : distribute extra : rebase_source : 604b23f6559c4688d1b43bc102601e0a0ed914a9 --- setuptools/command/sdist.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index edb3b7f3..16d3c37b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,6 +4,8 @@ from distutils import log import os, re, sys, pkg_resources from glob import glob +READMES = ('README', 'README.rst', 'README.txt') + entities = [ ("<","<"), (">", ">"), (""", '"'), ("'", "'"), ("&", "&") @@ -155,7 +157,7 @@ class sdist(_sdist): dist_files.append(data) def add_defaults(self): - standards = [('README', 'README.rst', 'README.txt'), + standards = [READMES, self.distribution.script_name] for fn in standards: if isinstance(fn, tuple): @@ -220,13 +222,12 @@ class sdist(_sdist): read_template = __read_template_hack def check_readme(self): - alts = ("README", "README.txt") - for f in alts: + for f in READMES: if os.path.exists(f): return else: self.warn( - "standard file not found: should have one of " +', '.join(alts) + "standard file not found: should have one of " +', '.join(READMES) ) -- cgit v1.2.1 From ec0ed85656b96812402439fa23c877fd27b99de5 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 16:36:29 +0200 Subject: Issue #313: Support for sdist subcommands (Python 2.7) --HG-- branch : distribute extra : rebase_source : 5461cca20f4c91fec21b69128f76f6e6a0df205c --- setuptools/command/sdist.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 16d3c37b..91c4fd1b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -147,7 +147,17 @@ class sdist(_sdist): self.filelist = ei_cmd.filelist self.filelist.append(os.path.join(ei_cmd.egg_info,'SOURCES.txt')) self.check_readme() - self.check_metadata() + + # Run sub commands + for cmd_name in self.get_sub_commands(): + self.run_command(cmd_name) + + # Call check_metadata only if no 'check' command + # (distutils <= 2.6) + import distutils.command + if 'check' not in distutils.command.__all__: + self.check_metadata() + self.make_distribution() dist_files = getattr(self.distribution,'dist_files',[]) -- cgit v1.2.1 From d76ec4bfdf2fe9a2bced5ca2a3610831020453c6 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 19:52:32 +0200 Subject: Read and write manifest in UTF-8 under Python 3. Fixes #303. --HG-- branch : distribute extra : rebase_source : 609c654effd2711aa803f6a0e84013294026608f --- setuptools/command/sdist.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index a176f635..d5259c2b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -262,7 +262,34 @@ class sdist(_sdist): self.get_finalized_command('egg_info').save_version_info(dest) + def _manifest_is_not_generated(self): + # check for special comment used in 2.7.1 and higher + if not os.path.isfile(self.manifest): + return False + fp = open(self.manifest, 'rbU') + try: + first_line = fp.readline() + finally: + fp.close() + return first_line != '# file GENERATED by distutils, do NOT edit\n'.encode() + + def read_manifest(self): + """Read the manifest file (named by 'self.manifest') and use it to + fill in 'self.filelist', the list of files to include in the source + distribution. + """ + log.info("reading manifest file '%s'", self.manifest) + manifest = open(self.manifest, 'rbU') + for line in manifest: + if sys.version_info >= (3,): + line = line.decode('UTF-8') + # ignore comments and blank lines + line = line.strip() + if line.startswith('#') or not line: + continue + self.filelist.append(line) + manifest.close() -- cgit v1.2.1 From 9d66fb61d9579516c5333d51eb85dc3495e6032f Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Wed, 17 Oct 2012 10:54:39 +0200 Subject: Use surrogateescape error handler when reading and writing the manifest. Refs #303. --HG-- branch : distribute extra : rebase_source : f0231cf87e2478f988f798dfe579f28e7561aeff --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index d5259c2b..42558143 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -283,7 +283,7 @@ class sdist(_sdist): manifest = open(self.manifest, 'rbU') for line in manifest: if sys.version_info >= (3,): - line = line.decode('UTF-8') + line = line.decode('UTF-8', 'surrogateescape') # ignore comments and blank lines line = line.strip() if line.startswith('#') or not line: -- cgit v1.2.1 From 3b26424a5a614cbed17f17591f91ec453be9d038 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Thu, 25 Oct 2012 23:45:25 +0200 Subject: When writing the manifest under Python 3, skip filenames that cannot be encoded to UTF-8. --HG-- branch : distribute extra : rebase_source : f1b439267fce37754aac49af15a9e26346950a26 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 42558143..d5259c2b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -283,7 +283,7 @@ class sdist(_sdist): manifest = open(self.manifest, 'rbU') for line in manifest: if sys.version_info >= (3,): - line = line.decode('UTF-8', 'surrogateescape') + line = line.decode('UTF-8') # ignore comments and blank lines line = line.strip() if line.startswith('#') or not line: -- cgit v1.2.1 From e485c19015d4fced68b25c09ca66a1743d3ab27c Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Fri, 26 Oct 2012 12:46:41 +0200 Subject: Keep 'surrogateescape' when reading the manifest, to avoid breaking on bad input. --HG-- branch : distribute extra : rebase_source : 6f894cd508e73fae0ad02860654df5181055ba4d --- setuptools/command/sdist.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index d5259c2b..79eed214 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -283,7 +283,8 @@ class sdist(_sdist): manifest = open(self.manifest, 'rbU') for line in manifest: if sys.version_info >= (3,): - line = line.decode('UTF-8') + # Don't break if surrogates have crept into the manifest + line = line.decode('UTF-8', 'surrogateescape') # ignore comments and blank lines line = line.strip() if line.startswith('#') or not line: -- cgit v1.2.1 From f266bc3745169122fcfcacb781e7e3c70fc58bfb Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Thu, 1 Nov 2012 11:47:24 +0100 Subject: Skip undecodable filenames in read_manifest as well. --HG-- branch : distribute extra : rebase_source : 2dda494b1a4758e84dde81cc61170acd0e55d2f2 --- setuptools/command/sdist.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 79eed214..7a6d2b7d 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -283,8 +283,11 @@ class sdist(_sdist): manifest = open(self.manifest, 'rbU') for line in manifest: if sys.version_info >= (3,): - # Don't break if surrogates have crept into the manifest - line = line.decode('UTF-8', 'surrogateescape') + try: + line = line.decode('UTF-8') + except UnicodeDecodeError: + log.warn("%r not UTF-8 decodable -- skipping" % line) + continue # ignore comments and blank lines line = line.strip() if line.startswith('#') or not line: -- cgit v1.2.1 From 91379d9c17d2ac432f64e1952e2b3d47c83eedcc Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Sat, 10 Nov 2012 18:45:20 +0100 Subject: Add comments. --HG-- branch : distribute extra : rebase_source : 2d4ac9964b247122715c8296158c97d1f11adf89 --- setuptools/command/sdist.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 7a6d2b7d..2fa3771a 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -282,6 +282,7 @@ class sdist(_sdist): log.info("reading manifest file '%s'", self.manifest) manifest = open(self.manifest, 'rbU') for line in manifest: + # The manifest must contain UTF-8. See #303. if sys.version_info >= (3,): try: line = line.decode('UTF-8') -- cgit v1.2.1 From 59cf01356e2611dd921d4cece2176fc9ea7cce59 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 3 May 2013 23:55:42 -0400 Subject: Move where add_defaults is defined to align with setuptools --HG-- branch : Setuptools-Distribute merge extra : source : 6728b2be550b4ed4015d5cdc88bc49141bc40878 --- setuptools/command/sdist.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 2fa3771a..b8c8495e 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -157,7 +157,7 @@ class sdist(_sdist): import distutils.command if 'check' not in distutils.command.__all__: self.check_metadata() - + self.make_distribution() dist_files = getattr(self.distribution,'dist_files',[]) @@ -166,6 +166,26 @@ class sdist(_sdist): if data not in dist_files: dist_files.append(data) + def __read_template_hack(self): + # This grody hack closes the template file (MANIFEST.in) if an + # exception occurs during read_template. + # Doing so prevents an error when easy_install attempts to delete the + # file. + try: + _sdist.read_template(self) + except: + sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() + raise + # Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle + # has been fixed, so only override the method if we're using an earlier + # Python. + if ( + sys.version_info < (2,7,2) + or (3,0) <= sys.version_info < (3,1,4) + or (3,2) <= sys.version_info < (3,2,1) + ): + read_template = __read_template_hack + def add_defaults(self): standards = [READMES, self.distribution.script_name] @@ -219,26 +239,6 @@ class sdist(_sdist): build_scripts = self.get_finalized_command('build_scripts') self.filelist.extend(build_scripts.get_source_files()) - def __read_template_hack(self): - # This grody hack closes the template file (MANIFEST.in) if an - # exception occurs during read_template. - # Doing so prevents an error when easy_install attempts to delete the - # file. - try: - _sdist.read_template(self) - except: - sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() - raise - # Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle - # has been fixed, so only override the method if we're using an earlier - # Python. - if ( - sys.version_info < (2,7,2) - or (3,0) <= sys.version_info < (3,1,4) - or (3,2) <= sys.version_info < (3,2,1) - ): - read_template = __read_template_hack - def check_readme(self): for f in READMES: if os.path.exists(f): -- cgit v1.2.1 From ff75a6cbdbcde8d9e3b979c30c3d6e64a1bc5374 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 3 May 2013 23:09:46 -0400 Subject: Copy changes from 1aae1efe5733 for setuptools/command/* (except easy_install.py --HG-- branch : Setuptools-Distribute merge extra : source : 0c89fbb19c269ce1cb3bc3e9ece9864127768169 --- setuptools/command/sdist.py | 83 +++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 21 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 5bd5ebd4..d84afdb8 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -1,6 +1,7 @@ from distutils.command.sdist import sdist as _sdist from distutils.util import convert_path from distutils import log +from glob import glob import os, re, sys, pkg_resources entities = [ @@ -38,7 +39,6 @@ def joinpath(prefix,suffix): - def walk_revctrl(dirname=''): """Find all files under revision control""" for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): @@ -86,17 +86,21 @@ def entries_finder(dirname, filename): f = open(filename,'rU') data = f.read() f.close() - if data.startswith('9') or data.startswith('8'): # subversion 1.5/1.4 + if data.startswith('=6 and record[5]=="delete": continue # skip deleted yield joinpath(dirname, record[0]) - elif data.startswith(' Date: Sun, 30 Jun 2013 13:13:33 -0500 Subject: Added SVNTextEntries for the moment as a fallback for no SVN/Rev8-10 Added Externals processing for all formats Will use dir-prop[-base] as a fallback otherwise CMD. --HG-- extra : rebase_source : dc27f779f22d5f9795c425b92d34db29d62b495d --- setuptools/command/sdist.py | 45 +++++---------------------------------------- 1 file changed, 5 insertions(+), 40 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 39cd6043..e0c4b7e5 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,6 +4,7 @@ from distutils import log from glob import glob import os, re, sys, pkg_resources from glob import glob +from setuptools.svn_util import SVNEntries READMES = ('README', 'README.rst', 'README.txt') @@ -61,49 +62,13 @@ def _default_revctrl(dirname=''): def externals_finder(dirname, filename): """Find any 'svn:externals' directories""" - found = False - f = open(filename,'rt') - for line in iter(f.readline, ''): # can't use direct iter! - parts = line.split() - if len(parts)==2: - kind,length = parts - data = f.read(int(length)) - if kind=='K' and data=='svn:externals': - found = True - elif kind=='V' and found: - f.close() - break - else: - f.close() - return - - for line in data.splitlines(): - parts = line.split() - if parts: - yield joinpath(dirname, parts[0]) - + for name in SVNEntries.load(dirname).get_external_dirs(filename): + yield joinpath(dirname, name) -entries_pattern = re.compile(r'name="([^"]+)"(?![^>]+deleted="true")', re.I) def entries_finder(dirname, filename): - f = open(filename,'rU') - data = f.read() - f.close() - if data.startswith('=6 and record[5]=="delete": - continue # skip deleted - yield joinpath(dirname, record[0]) + for record in SVNEntries.load(dirname).get_undeleted_records(): + yield joinpath(dirname, record) finders = [ -- cgit v1.2.1 From 0fd60933763224ddc0fe96b1c94831dd091da25b Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Sun, 30 Jun 2013 19:04:15 -0500 Subject: minor naming issues sdist --HG-- extra : rebase_source : e7def1d2445a55291163753761d52922d1252dcb --- setuptools/command/sdist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index e0c4b7e5..3614da5e 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,7 +4,7 @@ from distutils import log from glob import glob import os, re, sys, pkg_resources from glob import glob -from setuptools.svn_util import SVNEntries +from setuptools.svn_utils import SVNEntries READMES = ('README', 'README.rst', 'README.txt') @@ -62,7 +62,7 @@ def _default_revctrl(dirname=''): def externals_finder(dirname, filename): """Find any 'svn:externals' directories""" - for name in SVNEntries.load(dirname).get_external_dirs(filename): + for name in SVNEnteries.load(dirname).get_external_dirs(filename): yield joinpath(dirname, name) -- cgit v1.2.1 From dda57f982edf3a5f6758bfcc0016f66ec138c510 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Thu, 4 Jul 2013 11:27:45 -0500 Subject: get_svn_method now direectly called svn_utils.parse_revision --HG-- extra : rebase_source : c902dd83f2c3df73f3a6f84e08bd8a77b201cc21 --- setuptools/command/sdist.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 3614da5e..2a37c308 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -5,6 +5,7 @@ from glob import glob import os, re, sys, pkg_resources from glob import glob from setuptools.svn_utils import SVNEntries +from setuptools import svn_utils READMES = ('README', 'README.rst', 'README.txt') @@ -69,7 +70,7 @@ def externals_finder(dirname, filename): def entries_finder(dirname, filename): for record in SVNEntries.load(dirname).get_undeleted_records(): yield joinpath(dirname, record) - + finders = [ (convert_path('CVS/Entries'), -- cgit v1.2.1 From 44989bd50e225241c1dfc7e60c5a973586a4fc13 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Thu, 4 Jul 2013 12:24:21 -0500 Subject: cannot use list since that requires repo access, initial recurse parsing --HG-- extra : rebase_source : 87deb8066a0cb067e7bccc63cc156b7fed30ea29 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 2a37c308..92f8d468 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -68,7 +68,7 @@ def externals_finder(dirname, filename): def entries_finder(dirname, filename): - for record in SVNEntries.load(dirname).get_undeleted_records(): + for record in svn_utils.parse_manifest(dirname): yield joinpath(dirname, record) -- cgit v1.2.1 From 3ca3f2d64dfcd377227cc2bbdfbc2e4c528e0098 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Thu, 4 Jul 2013 12:44:57 -0500 Subject: cannot use list since that requires repo access, initial recurse parsing --HG-- extra : rebase_source : 23fbf9ca969a6a0205247ec69e5b674452839f2e --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 92f8d468..81b92f44 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -68,7 +68,7 @@ def externals_finder(dirname, filename): def entries_finder(dirname, filename): - for record in svn_utils.parse_manifest(dirname): + for record in svn_utils.parse_dir_entries(dirname): yield joinpath(dirname, record) -- cgit v1.2.1 From e6a901a1f7d454f64fb6f1b13d8f777f3a836abd Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Thu, 4 Jul 2013 12:49:15 -0500 Subject: got some global version done, SVN 1.3.x or later now required --HG-- extra : rebase_source : def9ab923ee6455791c92334ee79c09d9164c43e --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 81b92f44..70ab2c84 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -63,7 +63,7 @@ def _default_revctrl(dirname=''): def externals_finder(dirname, filename): """Find any 'svn:externals' directories""" - for name in SVNEnteries.load(dirname).get_external_dirs(filename): + for name in svn_utils.parse_externals(dirname): yield joinpath(dirname, name) -- cgit v1.2.1 From 0fb7894e8fca0cbd3454fbff2afc45f51cfdd156 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Thu, 4 Jul 2013 12:53:02 -0500 Subject: removed the objects --HG-- extra : rebase_source : 19c8be226a698813103dc2393b3b154060d90669 --- setuptools/command/sdist.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 70ab2c84..081d3c98 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,7 +4,6 @@ from distutils import log from glob import glob import os, re, sys, pkg_resources from glob import glob -from setuptools.svn_utils import SVNEntries from setuptools import svn_utils READMES = ('README', 'README.rst', 'README.txt') -- cgit v1.2.1 From adb810246108bfe67f4ac92ab0f644d250cce515 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Thu, 4 Jul 2013 13:10:35 -0500 Subject: consolidated externals and enteries because enteries need to file to interate over and both get called by the same callback. pep8 on svn_utils --HG-- extra : rebase_source : fa65ebfc167041b5c2e1b2bd901e9354cfaea57e --- setuptools/command/sdist.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 081d3c98..5cc2139b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -60,23 +60,21 @@ def _default_revctrl(dirname=''): for item in _default_revctrl(path): yield item -def externals_finder(dirname, filename): - """Find any 'svn:externals' directories""" - for name in svn_utils.parse_externals(dirname): - yield joinpath(dirname, name) - -def entries_finder(dirname, filename): +def entries_externals_finder(dirname, filename): for record in svn_utils.parse_dir_entries(dirname): yield joinpath(dirname, record) + for name in svn_utils.parse_externals(dirname): + yield joinpath(dirname, name) + finders = [ (convert_path('CVS/Entries'), re_finder(re.compile(r"^\w?/([^/]+)/", re.M))), - (convert_path('.svn/entries'), entries_finder), - (convert_path('.svn/dir-props'), externals_finder), - (convert_path('.svn/dir-prop-base'), externals_finder), # svn 1.4 + #combined externals due to common interface + #combined externals and enteries due to lack of dir_props in 1.7 + (convert_path('.svn/entries'), entries_externals_finder), ] -- cgit v1.2.1 From b4ba33898f4d67af70319a0bb64edca72fc3ecee Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Sat, 20 Jul 2013 17:45:04 -0500 Subject: Additional Tests, Various fixes, and encoding dealings --HG-- extra : rebase_source : 2734e79e08e194923eab8c70f92cb77bce7daccf --- setuptools/command/sdist.py | 84 +++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 49 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 5cc2139b..e1112ff9 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -8,73 +8,58 @@ from setuptools import svn_utils READMES = ('README', 'README.rst', 'README.txt') -entities = [ - ("<","<"), (">", ">"), (""", '"'), ("'", "'"), - ("&", "&") -] -def unescape(data): - for old,new in entities: - data = data.replace(old,new) - return data +def walk_revctrl(dirname=''): + """Find all files under revision control""" + for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): + for item in ep.load()(dirname): + yield item + + +#TODO will need test case +class re_finder(object): -def re_finder(pattern, postproc=None): - def find(dirname, filename): + def __init__(self, path, pattern, postproc=None): + self.pattern = pattern + self.postproc = postproc + self.path = convert_path(path) + + def _finder(self, dirname, filename): f = open(filename,'rU') - data = f.read() - f.close() - for match in pattern.finditer(data): + try: + data = f.read() + finally: + f.close() + for match in self.pattern.finditer(data): path = match.group(1) if postproc: + #postproc used to be used when the svn finder + #was an re_finder for calling unescape path = postproc(path) - yield joinpath(dirname,path) - return find - -def joinpath(prefix,suffix): - if not prefix: - return suffix - return os.path.join(prefix,suffix) - - - + yield svn_utils.joinpath(dirname,path) + def __call__(self, dirname=''): + path = svn_utils.joinpath(dirname, self.path) - - - - -def walk_revctrl(dirname=''): - """Find all files under revision control""" - for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): - for item in ep.load()(dirname): - yield item - -def _default_revctrl(dirname=''): - for path, finder in finders: - path = joinpath(dirname,path) if os.path.isfile(path): - for path in finder(dirname,path): + for path in self._finder(dirname,path): if os.path.isfile(path): yield path elif os.path.isdir(path): - for item in _default_revctrl(path): + for item in self.find(path): yield item -def entries_externals_finder(dirname, filename): - for record in svn_utils.parse_dir_entries(dirname): - yield joinpath(dirname, record) - - for name in svn_utils.parse_externals(dirname): - yield joinpath(dirname, name) +def _default_revctrl(dirname=''): + 'Primary svn_cvs entry point' + for finder in finders: + for item in finder(dirname): + yield item finders = [ - (convert_path('CVS/Entries'), - re_finder(re.compile(r"^\w?/([^/]+)/", re.M))), - #combined externals due to common interface - #combined externals and enteries due to lack of dir_props in 1.7 - (convert_path('.svn/entries'), entries_externals_finder), + re_finder('CVS/Entries', re.compile(r"^\w?/([^/]+)/", re.M)), + svn_utils.svn_finder, ] @@ -88,6 +73,7 @@ finders = [ + class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" -- cgit v1.2.1 From 61aacdd173df9aaf20698769b1715bfcc6b5e416 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 9 Sep 2013 15:19:34 -0400 Subject: Reorganize imports --- setuptools/command/sdist.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 39cd6043..a7ce7ac0 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -1,9 +1,12 @@ +import os +import re +import sys +from glob import glob + +import pkg_resources from distutils.command.sdist import sdist as _sdist from distutils.util import convert_path from distutils import log -from glob import glob -import os, re, sys, pkg_resources -from glob import glob READMES = ('README', 'README.rst', 'README.txt') @@ -98,13 +101,13 @@ def entries_finder(dirname, filename): except: pass if svnver<8: log.warn("unrecognized .svn/entries format in %s", os.path.abspath(dirname)) - return + return for record in map(str.splitlines, data.split('\n\x0c\n')[1:]): # subversion 1.6/1.5/1.4 if not record or len(record)>=6 and record[5]=="delete": continue # skip deleted yield joinpath(dirname, record[0]) - + finders = [ (convert_path('CVS/Entries'), -- cgit v1.2.1 From 2b6a00de2632bd044a260c86aec9e29083b2adf1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 9 Sep 2013 15:21:41 -0400 Subject: Remove excess whitespace. Delint one if statement. --- setuptools/command/sdist.py | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index a7ce7ac0..6d63e819 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -37,14 +37,6 @@ def joinpath(prefix,suffix): return suffix return os.path.join(prefix,suffix) - - - - - - - - def walk_revctrl(dirname=''): """Find all files under revision control""" for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): @@ -118,16 +110,6 @@ finders = [ ] - - - - - - - - - - class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" @@ -182,11 +164,12 @@ class sdist(_sdist): # Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle # has been fixed, so only override the method if we're using an earlier # Python. - if ( - sys.version_info < (2,7,2) - or (3,0) <= sys.version_info < (3,1,4) - or (3,2) <= sys.version_info < (3,2,1) - ): + has_leaky_handle = ( + sys.version_info < (2,7,2) + or (3,0) <= sys.version_info < (3,1,4) + or (3,2) <= sys.version_info < (3,2,1) + ) + if has_leaky_handle: read_template = __read_template_hack def add_defaults(self): @@ -251,7 +234,6 @@ class sdist(_sdist): "standard file not found: should have one of " +', '.join(READMES) ) - def make_release_tree(self, base_dir, files): _sdist.make_release_tree(self, base_dir, files) @@ -298,10 +280,3 @@ class sdist(_sdist): continue self.filelist.append(line) manifest.close() - - - - - - -# -- cgit v1.2.1 From caa91ca543b5f68074da8d8fd79e842bb9634cae Mon Sep 17 00:00:00 2001 From: William Grzybowski Date: Wed, 25 Dec 2013 10:34:02 +0000 Subject: Fix postproc reference --HG-- branch : postproc --- setuptools/command/sdist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 6249e75c..77a3852b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -35,10 +35,10 @@ class re_finder(object): f.close() for match in self.pattern.finditer(data): path = match.group(1) - if postproc: + if self.postproc: #postproc used to be used when the svn finder #was an re_finder for calling unescape - path = postproc(path) + path = self.postproc(path) yield svn_utils.joinpath(dirname,path) def __call__(self, dirname=''): path = svn_utils.joinpath(dirname, self.path) -- cgit v1.2.1 From 15890a34456e31755d991bcbb2970591e32c8131 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 5 Feb 2014 18:29:43 -0500 Subject: Normalize whitespace --HG-- extra : source : e4abff0dc46f1c089d8a61bac2406a57df406dcc --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 77a3852b..aa6f47f0 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -40,6 +40,7 @@ class re_finder(object): #was an re_finder for calling unescape path = self.postproc(path) yield svn_utils.joinpath(dirname,path) + def __call__(self, dirname=''): path = svn_utils.joinpath(dirname, self.path) @@ -65,7 +66,6 @@ finders = [ ] - class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" -- cgit v1.2.1 From a61674f1324778f8b231c569325eab60e0e78482 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 5 Feb 2014 18:33:57 -0500 Subject: Use a default that generates to the default behavior; no need to employ None as a sentry value. --HG-- extra : source : 2c7c7486ddc40ee4272b23e1fafd51ab1611dc28 --- setuptools/command/sdist.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index aa6f47f0..b59cc390 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -22,7 +22,7 @@ def walk_revctrl(dirname=''): #TODO will need test case class re_finder(object): - def __init__(self, path, pattern, postproc=None): + def __init__(self, path, pattern, postproc=lambda x: x): self.pattern = pattern self.postproc = postproc self.path = convert_path(path) @@ -35,10 +35,9 @@ class re_finder(object): f.close() for match in self.pattern.finditer(data): path = match.group(1) - if self.postproc: - #postproc used to be used when the svn finder - #was an re_finder for calling unescape - path = self.postproc(path) + # postproc was formerly used when the svn finder + # was an re_finder for calling unescape + path = self.postproc(path) yield svn_utils.joinpath(dirname,path) def __call__(self, dirname=''): -- cgit v1.2.1 From d505855a1a59213b8a02d50870305c62c52d8399 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 5 Feb 2014 18:57:02 -0500 Subject: Implement self.find. Fixes #139. --HG-- extra : amend_source : 98be824b4f846eb5fa8a8b046c3ef52a9fc2af4d --- setuptools/command/sdist.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index e1112ff9..1bd07e65 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -38,7 +38,7 @@ class re_finder(object): path = postproc(path) yield svn_utils.joinpath(dirname,path) - def __call__(self, dirname=''): + def find(self, dirname=''): path = svn_utils.joinpath(dirname, self.path) if os.path.isfile(path): @@ -48,6 +48,7 @@ class re_finder(object): elif os.path.isdir(path): for item in self.find(path): yield item + __call__ = find def _default_revctrl(dirname=''): -- cgit v1.2.1 From dbdef26b5b1968b49b49966da045799b8553ebe1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 5 Feb 2014 19:04:23 -0500 Subject: Rename the path attribute to entries_path for clarity. Added a docstring. Refactored 'find' method for flatness. --HG-- extra : source : 686317ef97be5076001b23e61f552dc1e85e29c8 --- setuptools/command/sdist.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 04cbccdf..76e1c5f1 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -21,11 +21,15 @@ def walk_revctrl(dirname=''): #TODO will need test case class re_finder(object): + """ + Finder that locates files based on entries in a file matched by a + regular expression. + """ def __init__(self, path, pattern, postproc=lambda x: x): self.pattern = pattern self.postproc = postproc - self.path = convert_path(path) + self.entries_path = convert_path(path) def _finder(self, dirname, filename): f = open(filename,'rU') @@ -38,18 +42,20 @@ class re_finder(object): # postproc was formerly used when the svn finder # was an re_finder for calling unescape path = self.postproc(path) - yield svn_utils.joinpath(dirname,path) + yield svn_utils.joinpath(dirname, path) def find(self, dirname=''): - path = svn_utils.joinpath(dirname, self.path) - - if os.path.isfile(path): - for path in self._finder(dirname,path): - if os.path.isfile(path): - yield path - elif os.path.isdir(path): - for item in self.find(path): - yield item + path = svn_utils.joinpath(dirname, self.entries_path) + + if not os.path.isfile(path): + # entries file doesn't exist + return + for path in self._finder(dirname,path): + if os.path.isfile(path): + yield path + elif os.path.isdir(path): + for item in self.find(path): + yield item __call__ = find -- cgit v1.2.1 From 573c2c86d4d4f506a87a1fc16060f32c1386ad38 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 30 Apr 2014 17:38:29 -0400 Subject: Correct indentation and clarify meaning by using namespacing --HG-- extra : amend_source : 20ab7547c8478eb084767fe701e627bdd462ba16 --- setuptools/command/sdist.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 76e1c5f1..948d27fa 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,7 +4,7 @@ import sys from glob import glob import pkg_resources -from distutils.command.sdist import sdist as _sdist +import distutils.command.sdist as orig from distutils.util import convert_path from distutils import log from setuptools import svn_utils @@ -72,7 +72,7 @@ finders = [ ] -class sdist(_sdist): +class sdist(orig.sdist): """Smart sdist that finds anything supported by revision control""" user_options = [ @@ -119,7 +119,7 @@ class sdist(_sdist): # Doing so prevents an error when easy_install attempts to delete the # file. try: - _sdist.read_template(self) + orig.sdist.read_template(self) except: sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() raise @@ -197,7 +197,7 @@ class sdist(_sdist): ) def make_release_tree(self, base_dir, files): - _sdist.make_release_tree(self, base_dir, files) + orig.sdist.make_release_tree(self, base_dir, files) # Save any egg_info command line options used to create this sdist dest = os.path.join(base_dir, 'setup.cfg') -- cgit v1.2.1 From 8567ca65adbf927a0af5c9b7314688dfbc46ab66 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 17 May 2014 12:25:31 -0400 Subject: Use PY3 and PY2 throughout --- setuptools/command/sdist.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 948d27fa..f9a5b7b9 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -8,6 +8,7 @@ import distutils.command.sdist as orig from distutils.util import convert_path from distutils import log from setuptools import svn_utils +from setuptools.compat import PY3 READMES = ('README', 'README.rst', 'README.txt') @@ -230,7 +231,7 @@ class sdist(orig.sdist): manifest = open(self.manifest, 'rbU') for line in manifest: # The manifest must contain UTF-8. See #303. - if sys.version_info >= (3,): + if PY3: try: line = line.decode('UTF-8') except UnicodeDecodeError: -- cgit v1.2.1 From 8e3f9d3253d1d0fb820dad4249d5110d017595c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Wed, 18 Jun 2014 20:31:05 +0300 Subject: Fixed PEP 8 compliancy of the setuptools.command package --- setuptools/command/sdist.py | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index f9a5b7b9..2aa1ee20 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -1,14 +1,14 @@ +from glob import glob +from distutils.util import convert_path +from distutils import log +import distutils.command.sdist as orig import os import re import sys -from glob import glob -import pkg_resources -import distutils.command.sdist as orig -from distutils.util import convert_path -from distutils import log from setuptools import svn_utils from setuptools.compat import PY3 +import pkg_resources READMES = ('README', 'README.rst', 'README.txt') @@ -20,7 +20,7 @@ def walk_revctrl(dirname=''): yield item -#TODO will need test case +# TODO will need test case class re_finder(object): """ Finder that locates files based on entries in a file matched by a @@ -33,7 +33,7 @@ class re_finder(object): self.entries_path = convert_path(path) def _finder(self, dirname, filename): - f = open(filename,'rU') + f = open(filename, 'rU') try: data = f.read() finally: @@ -51,12 +51,13 @@ class re_finder(object): if not os.path.isfile(path): # entries file doesn't exist return - for path in self._finder(dirname,path): + for path in self._finder(dirname, path): if os.path.isfile(path): yield path elif os.path.isdir(path): for item in self.find(path): yield item + __call__ = find @@ -85,7 +86,7 @@ class sdist(orig.sdist): ('dist-dir=', 'd', "directory to put the source distribution archive(s) in " "[default: dist]"), - ] + ] negative_opt = {} @@ -93,7 +94,7 @@ class sdist(orig.sdist): self.run_command('egg_info') ei_cmd = self.get_finalized_command('egg_info') self.filelist = ei_cmd.filelist - self.filelist.append(os.path.join(ei_cmd.egg_info,'SOURCES.txt')) + self.filelist.append(os.path.join(ei_cmd.egg_info, 'SOURCES.txt')) self.check_readme() # Run sub commands @@ -103,12 +104,13 @@ class sdist(orig.sdist): # Call check_metadata only if no 'check' command # (distutils <= 2.6) import distutils.command + if 'check' not in distutils.command.__all__: self.check_metadata() self.make_distribution() - dist_files = getattr(self.distribution,'dist_files',[]) + dist_files = getattr(self.distribution, 'dist_files', []) for file in self.archive_files: data = ('sdist', '', file) if data not in dist_files: @@ -124,13 +126,14 @@ class sdist(orig.sdist): except: sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() raise + # Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle # has been fixed, so only override the method if we're using an earlier # Python. has_leaky_handle = ( - sys.version_info < (2,7,2) - or (3,0) <= sys.version_info < (3,1,4) - or (3,2) <= sys.version_info < (3,2,1) + sys.version_info < (2, 7, 2) + or (3, 0) <= sys.version_info < (3, 1, 4) + or (3, 2) <= sys.version_info < (3, 2, 1) ) if has_leaky_handle: read_template = __read_template_hack @@ -194,7 +197,8 @@ class sdist(orig.sdist): return else: self.warn( - "standard file not found: should have one of " +', '.join(READMES) + "standard file not found: should have one of " + + ', '.join(READMES) ) def make_release_tree(self, base_dir, files): @@ -202,7 +206,7 @@ class sdist(orig.sdist): # Save any egg_info command line options used to create this sdist dest = os.path.join(base_dir, 'setup.cfg') - if hasattr(os,'link') and os.path.exists(dest): + if hasattr(os, 'link') and os.path.exists(dest): # unlink and re-copy, since it might be hard-linked, and # we don't want to change the source version os.unlink(dest) @@ -220,7 +224,8 @@ class sdist(orig.sdist): first_line = fp.readline() finally: fp.close() - return first_line != '# file GENERATED by distutils, do NOT edit\n'.encode() + return (first_line != + '# file GENERATED by distutils, do NOT edit\n'.encode()) def read_manifest(self): """Read the manifest file (named by 'self.manifest') and use it to -- cgit v1.2.1 From b49435397a5094f94678adf3549cc8941aa469b7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 5 Jul 2014 15:06:51 -0400 Subject: Use six for Python 2 compatibility --HG-- branch : feature/issue-229 extra : source : 7b1997ececc5772798ce33a0f8e77387cb55a977 --- setuptools/command/sdist.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 2aa1ee20..c99ad9b1 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -6,8 +6,9 @@ import os import re import sys +import six + from setuptools import svn_utils -from setuptools.compat import PY3 import pkg_resources READMES = ('README', 'README.rst', 'README.txt') @@ -236,7 +237,7 @@ class sdist(orig.sdist): manifest = open(self.manifest, 'rbU') for line in manifest: # The manifest must contain UTF-8. See #303. - if PY3: + if six.PY3: try: line = line.decode('UTF-8') except UnicodeDecodeError: -- cgit v1.2.1 From 4e5c7d0657a9719d2fa961c852daf0926de91ae3 Mon Sep 17 00:00:00 2001 From: Randy Syring Date: Sat, 20 Sep 2014 16:29:41 -0400 Subject: sdist command: fix case insensitivity when adding some files to filelist This should fix the problem in Bitbucket issue #100. It gives the same behavior for inclusion of default files (README*, etc.) on Windows as Linux. BACKWARDS INCOMPATABILITY: This may result in a backwards incompatible change for users on a case insensitive file system. If they were relying on some files getting included in their distribution due to setuptools defaults, and their files do not have the same case as the files being looked for in setuptools, those files will no longer be included in the package. For example, if a package had a file: readme.rst Previous to this commit, that file would have been included in the distribution as: README.rst But it will now no longer be included at all. To get the file included in the package, it can be added to the package's MANIFEST.in file: include readme.rst Files affected by this change will have a case variant of the files or patterns listed below: README README.txt README.rst setup.py (or whatever your setuptools script is named) setup.cfg test/test*.py --- setuptools/command/sdist.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 2aa1ee20..dc8d6773 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -8,6 +8,8 @@ import sys from setuptools import svn_utils from setuptools.compat import PY3 +from setuptools.utils import cs_path_exists + import pkg_resources READMES = ('README', 'README.rst', 'README.txt') @@ -146,7 +148,7 @@ class sdist(orig.sdist): alts = fn got_it = 0 for fn in alts: - if os.path.exists(fn): + if cs_path_exists(fn): got_it = 1 self.filelist.append(fn) break @@ -155,16 +157,17 @@ class sdist(orig.sdist): self.warn("standard file not found: should have one of " + ', '.join(alts)) else: - if os.path.exists(fn): + if cs_path_exists(fn): self.filelist.append(fn) else: self.warn("standard file '%s' not found" % fn) optional = ['test/test*.py', 'setup.cfg'] for pattern in optional: - files = list(filter(os.path.isfile, glob(pattern))) + files = list(filter(cs_path_exists, glob(pattern))) if files: - self.filelist.extend(files) + actual_fnames = map(os.path.normcase, files) + self.filelist.extend(actual_fnames) # getting python files if self.distribution.has_pure_modules(): -- cgit v1.2.1 From 1c05e6a7b7f2a54a55285857d498409df3dc9383 Mon Sep 17 00:00:00 2001 From: Randy Syring Date: Sat, 20 Sep 2014 16:37:25 -0400 Subject: remove unneeded code from last commit --- setuptools/command/sdist.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index dc8d6773..a77c39f2 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -166,8 +166,7 @@ class sdist(orig.sdist): for pattern in optional: files = list(filter(cs_path_exists, glob(pattern))) if files: - actual_fnames = map(os.path.normcase, files) - self.filelist.extend(actual_fnames) + self.filelist.extend(files) # getting python files if self.distribution.has_pure_modules(): -- cgit v1.2.1 From a7e5648bda737683c4ad220e61c44c1d17b73d87 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 24 Dec 2014 18:25:45 -0500 Subject: Removed svn support from setuptools. Ref #313. --- setuptools/command/sdist.py | 57 --------------------------------------------- 1 file changed, 57 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index a77c39f2..371bf547 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -1,12 +1,9 @@ from glob import glob -from distutils.util import convert_path from distutils import log import distutils.command.sdist as orig import os -import re import sys -from setuptools import svn_utils from setuptools.compat import PY3 from setuptools.utils import cs_path_exists @@ -22,60 +19,6 @@ def walk_revctrl(dirname=''): yield item -# TODO will need test case -class re_finder(object): - """ - Finder that locates files based on entries in a file matched by a - regular expression. - """ - - def __init__(self, path, pattern, postproc=lambda x: x): - self.pattern = pattern - self.postproc = postproc - self.entries_path = convert_path(path) - - def _finder(self, dirname, filename): - f = open(filename, 'rU') - try: - data = f.read() - finally: - f.close() - for match in self.pattern.finditer(data): - path = match.group(1) - # postproc was formerly used when the svn finder - # was an re_finder for calling unescape - path = self.postproc(path) - yield svn_utils.joinpath(dirname, path) - - def find(self, dirname=''): - path = svn_utils.joinpath(dirname, self.entries_path) - - if not os.path.isfile(path): - # entries file doesn't exist - return - for path in self._finder(dirname, path): - if os.path.isfile(path): - yield path - elif os.path.isdir(path): - for item in self.find(path): - yield item - - __call__ = find - - -def _default_revctrl(dirname=''): - 'Primary svn_cvs entry point' - for finder in finders: - for item in finder(dirname): - yield item - - -finders = [ - re_finder('CVS/Entries', re.compile(r"^\w?/([^/]+)/", re.M)), - svn_utils.svn_finder, -] - - class sdist(orig.sdist): """Smart sdist that finds anything supported by revision control""" -- cgit v1.2.1 From 314d143ffcc838e1dbf7177b601c139f8d0b609f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 31 Dec 2014 10:15:10 -0500 Subject: Restore _default_revctrl implementation (stubbed). Fixes #320. --- setuptools/command/sdist.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 371bf547..a4e8288a 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -11,6 +11,7 @@ import pkg_resources READMES = ('README', 'README.rst', 'README.txt') +_default_revctrl = list def walk_revctrl(dirname=''): """Find all files under revision control""" -- cgit v1.2.1 From 7e6639875e34bd8150a2c430f4d214da9c197e94 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 31 Dec 2014 10:19:25 -0500 Subject: Remove superfluous parentheses --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index a4e8288a..3d33df80 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -9,7 +9,7 @@ from setuptools.utils import cs_path_exists import pkg_resources -READMES = ('README', 'README.rst', 'README.txt') +READMES = 'README', 'README.rst', 'README.txt' _default_revctrl = list -- cgit v1.2.1 From 9d6a6e5927ae0e67164383e419f3145fc154467e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 4 Jan 2015 11:35:16 -0500 Subject: Use except/as, now supported by Python 2.6 --- setuptools/command/sdist.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 3d33df80..851a1775 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -70,7 +70,8 @@ class sdist(orig.sdist): try: orig.sdist.read_template(self) except: - sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() + _, _, tb = sys.exc_info() + tb.tb_next.tb_frame.f_locals['template'].close() raise # Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle -- cgit v1.2.1 From 41112f5afd0d2b0c14899ab1cf2c27183e64d6ac Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 9 Dec 2015 03:34:35 -0500 Subject: Use io.open for future compatibility and consistency --- setuptools/command/sdist.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 851a1775..71196512 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -3,6 +3,7 @@ from distutils import log import distutils.command.sdist as orig import os import sys +import io from setuptools.compat import PY3 from setuptools.utils import cs_path_exists @@ -166,11 +167,8 @@ class sdist(orig.sdist): if not os.path.isfile(self.manifest): return False - fp = open(self.manifest, 'rbU') - try: + with io.open(self.manifest, 'rb') as fp: first_line = fp.readline() - finally: - fp.close() return (first_line != '# file GENERATED by distutils, do NOT edit\n'.encode()) -- cgit v1.2.1 From 06872bb0bbbeb953e90bd0941444b0d499056557 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 31 Dec 2015 11:51:01 -0500 Subject: Update vendoring technique to match that used for packaging. Ref #229. --HG-- branch : feature/issue-229 --- setuptools/command/sdist.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 3b9f7dd5..59990cd6 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -5,7 +5,12 @@ import os import sys import io -import six +try: + from setuptools._vendor import six +except ImportError: + # fallback to naturally-installed version; allows system packagers to + # omit vendored packages. + import six from setuptools.utils import cs_path_exists -- cgit v1.2.1 From 952c1bafda1929c74c737646aa025e6ffad6632e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 31 Dec 2015 16:30:47 -0500 Subject: Modeling after Astropy's technique for bundling libraries, the imports are now much cleaner. Thanks @embray. Ref #229. --HG-- branch : feature/issue-229 --- setuptools/command/sdist.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 59990cd6..6640d4e3 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -5,12 +5,7 @@ import os import sys import io -try: - from setuptools._vendor import six -except ImportError: - # fallback to naturally-installed version; allows system packagers to - # omit vendored packages. - import six +from setuptools.extern import six from setuptools.utils import cs_path_exists -- cgit v1.2.1 From 4720c481c62d5cc0a40dd212a32c641125be8e9c Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 29 Jun 2016 10:22:12 +0200 Subject: Don't use deprecated 'U' flag to read manifest The universal newlines mode ('U' flag) is deprecated since Python 3.4. It only replaces "\r\n" with "\n", but it doesn't split lines at "\r" (Mac newline). In practice, the flag was useless, the sdist.read_manifest() method already uses line.strip() and so removes newline characters. --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 6640d4e3..f200b946 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -179,7 +179,7 @@ class sdist(orig.sdist): distribution. """ log.info("reading manifest file '%s'", self.manifest) - manifest = open(self.manifest, 'rbU') + manifest = open(self.manifest, 'rb') for line in manifest: # The manifest must contain UTF-8. See #303. if six.PY3: -- cgit v1.2.1 From 6d11e88f938f09ef16db4c6064b6e74acba4db1d Mon Sep 17 00:00:00 2001 From: stepshal Date: Tue, 12 Jul 2016 22:00:43 +0700 Subject: Fix quantity of blank lines after code object. --- setuptools/command/sdist.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index f200b946..041ee42e 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -15,6 +15,7 @@ READMES = 'README', 'README.rst', 'README.txt' _default_revctrl = list + def walk_revctrl(dirname=''): """Find all files under revision control""" for ep in pkg_resources.iter_entry_points('setuptools.file_finders'): -- cgit v1.2.1 From 9f77a068c02a3937762b8292c20e06d072247825 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 21 Jul 2016 12:14:42 -0400 Subject: Disable os.link during make_distribution. Fixes #516. Note that better would be if sdist provided some sort of hooks to better control the file copying, but since it does not, this technique will suffice for now. --- setuptools/command/sdist.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 041ee42e..b86aae50 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,6 +4,7 @@ import distutils.command.sdist as orig import os import sys import io +import contextlib from setuptools.extern import six @@ -65,6 +66,32 @@ class sdist(orig.sdist): if data not in dist_files: dist_files.append(data) + def make_distribution(self): + """ + Workaround for #516 + """ + with self._remove_os_link(): + orig.sdist.make_distribution(self) + + @staticmethod + @contextlib.contextmanager + def _remove_os_link(): + """ + In a context, remove and restore os.link if it exists + """ + class NoValue: + pass + orig_val = getattr(os, 'link', NoValue) + try: + del os.link + except Exception: + pass + try: + yield + finally: + if orig_val is not NoValue: + setattr(os, 'link', orig_val) + def __read_template_hack(self): # This grody hack closes the template file (MANIFEST.in) if an # exception occurs during read_template. -- cgit v1.2.1 From b3b8a8d106ecf9dbdb933f4f2a09ec65003b7d05 Mon Sep 17 00:00:00 2001 From: stepshal Date: Fri, 22 Jul 2016 12:56:21 +0700 Subject: Use 'except Exception:' instead of 'except:'. --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index b86aae50..b6125f58 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -99,7 +99,7 @@ class sdist(orig.sdist): # file. try: orig.sdist.read_template(self) - except: + except Exception: _, _, tb = sys.exc_info() tb.tb_next.tb_frame.f_locals['template'].close() raise -- cgit v1.2.1 From b9baa94e18e91671f9acde4e0e033be1391a7fde Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 20 Aug 2016 17:44:54 -0400 Subject: Default to gztar for sdists on all platforms. Ref #748. --- setuptools/command/sdist.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index b6125f58..1d4f5d54 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -66,6 +66,17 @@ class sdist(orig.sdist): if data not in dist_files: dist_files.append(data) + def initialize_options(self): + orig.sdist.initialize_options(self) + + self._default_to_gztar() + + def _default_to_gztar(self): + # only needed on Python prior to 3.6. + if sys.version_info >= (3, 6, 0, 'beta', 1): + return + self.formats = ['gztar'] + def make_distribution(self): """ Workaround for #516 -- cgit v1.2.1 From e50f854c4a6d2641aaad5421268fb6f717984e21 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 14 Oct 2016 14:13:51 -0400 Subject: Rely on degenerate behavior in list.extend, as found in distutils. --- setuptools/command/sdist.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 1d4f5d54..52c58055 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -150,9 +150,8 @@ class sdist(orig.sdist): optional = ['test/test*.py', 'setup.cfg'] for pattern in optional: - files = list(filter(cs_path_exists, glob(pattern))) - if files: - self.filelist.extend(files) + files = filter(cs_path_exists, glob(pattern)) + self.filelist.extend(files) # getting python files if self.distribution.has_pure_modules(): -- cgit v1.2.1 From a0fe4c8e9be2a490db4bcbaf3ffe634623ea31cc Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 14 Oct 2016 14:14:42 -0400 Subject: Always use iterator-based filter --- setuptools/command/sdist.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 52c58055..546c96d1 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -7,6 +7,7 @@ import io import contextlib from setuptools.extern import six +from setuptools.extern.six.moves import filter from setuptools.utils import cs_path_exists -- cgit v1.2.1 From 252ee6f45e0c90a21ec951cb8d024c81ab4e2b73 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 14 Oct 2016 14:55:42 -0400 Subject: Move READMES definition into class attribute. --- setuptools/command/sdist.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 546c96d1..addc6a56 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -13,8 +13,6 @@ from setuptools.utils import cs_path_exists import pkg_resources -READMES = 'README', 'README.rst', 'README.txt' - _default_revctrl = list @@ -41,6 +39,8 @@ class sdist(orig.sdist): negative_opt = {} + READMES = 'README', 'README.rst', 'README.txt' + def run(self): self.run_command('egg_info') ei_cmd = self.get_finalized_command('egg_info') @@ -128,7 +128,7 @@ class sdist(orig.sdist): read_template = __read_template_hack def add_defaults(self): - standards = [READMES, + standards = [self.READMES, self.distribution.script_name] for fn in standards: if isinstance(fn, tuple): @@ -180,13 +180,13 @@ class sdist(orig.sdist): self.filelist.extend(build_scripts.get_source_files()) def check_readme(self): - for f in READMES: + for f in self.READMES: if os.path.exists(f): return else: self.warn( "standard file not found: should have one of " + - ', '.join(READMES) + ', '.join(self.READMES) ) def make_release_tree(self, base_dir, files): -- cgit v1.2.1 From 17f89f4ffca731f1ee3d49aad717415013d047d2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 14 Oct 2016 15:53:16 -0400 Subject: Update sdist to use sdist_add_defaults forward compatibility. --- setuptools/command/sdist.py | 51 +++++++-------------------------------------- 1 file changed, 8 insertions(+), 43 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index addc6a56..b85d7d03 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -1,4 +1,3 @@ -from glob import glob from distutils import log import distutils.command.sdist as orig import os @@ -7,9 +6,8 @@ import io import contextlib from setuptools.extern import six -from setuptools.extern.six.moves import filter -from setuptools.utils import cs_path_exists +from .py36compat import sdist_add_defaults import pkg_resources @@ -23,7 +21,7 @@ def walk_revctrl(dirname=''): yield item -class sdist(orig.sdist): +class sdist(sdist_add_defaults, orig.sdist): """Smart sdist that finds anything supported by revision control""" user_options = [ @@ -127,34 +125,8 @@ class sdist(orig.sdist): if has_leaky_handle: read_template = __read_template_hack - def add_defaults(self): - standards = [self.READMES, - self.distribution.script_name] - for fn in standards: - if isinstance(fn, tuple): - alts = fn - got_it = 0 - for fn in alts: - if cs_path_exists(fn): - got_it = 1 - self.filelist.append(fn) - break - - if not got_it: - self.warn("standard file not found: should have one of " + - ', '.join(alts)) - else: - if cs_path_exists(fn): - self.filelist.append(fn) - else: - self.warn("standard file '%s' not found" % fn) - - optional = ['test/test*.py', 'setup.cfg'] - for pattern in optional: - files = filter(cs_path_exists, glob(pattern)) - self.filelist.extend(files) - - # getting python files + def _add_defaults_python(self): + """getting python files""" if self.distribution.has_pure_modules(): build_py = self.get_finalized_command('build_py') self.filelist.extend(build_py.get_source_files()) @@ -167,17 +139,10 @@ class sdist(orig.sdist): self.filelist.extend([os.path.join(src_dir, filename) for filename in filenames]) - if self.distribution.has_ext_modules(): - build_ext = self.get_finalized_command('build_ext') - self.filelist.extend(build_ext.get_source_files()) - - if self.distribution.has_c_libraries(): - build_clib = self.get_finalized_command('build_clib') - self.filelist.extend(build_clib.get_source_files()) - - if self.distribution.has_scripts(): - build_scripts = self.get_finalized_command('build_scripts') - self.filelist.extend(build_scripts.get_source_files()) + def _add_defaults_data_files(self): + """ + Don't add any data files, but why? + """ def check_readme(self): for f in self.READMES: -- cgit v1.2.1 From 31bd37c6ac8de9e8c1bacebc2d8e1215df91eb96 Mon Sep 17 00:00:00 2001 From: stepshal Date: Tue, 18 Oct 2016 20:24:35 +0700 Subject: Fix quantity of blank lines. --- setuptools/command/sdist.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index b85d7d03..9975753d 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -89,8 +89,10 @@ class sdist(sdist_add_defaults, orig.sdist): """ In a context, remove and restore os.link if it exists """ + class NoValue: pass + orig_val = getattr(os, 'link', NoValue) try: del os.link -- cgit v1.2.1 From e12256c4d32ebf59791d56576ec328131f58357a Mon Sep 17 00:00:00 2001 From: Thiebaud Weksteen Date: Wed, 26 Oct 2016 16:36:54 +1100 Subject: Remove _add_defaults_data_files override --- setuptools/command/sdist.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 9975753d..d4ac9efa 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -141,11 +141,6 @@ class sdist(sdist_add_defaults, orig.sdist): self.filelist.extend([os.path.join(src_dir, filename) for filename in filenames]) - def _add_defaults_data_files(self): - """ - Don't add any data files, but why? - """ - def check_readme(self): for f in self.READMES: if os.path.exists(f): -- cgit v1.2.1 From b18391c74e190b99cc358997f30907a5c4d78b00 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 29 Oct 2016 22:28:17 -0400 Subject: Backed out changeset e12256c4d32e. Fixes #833. Reopens #274 and reopens #521. --- setuptools/command/sdist.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index d4ac9efa..9975753d 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -141,6 +141,11 @@ class sdist(sdist_add_defaults, orig.sdist): self.filelist.extend([os.path.join(src_dir, filename) for filename in filenames]) + def _add_defaults_data_files(self): + """ + Don't add any data files, but why? + """ + def check_readme(self): for f in self.READMES: if os.path.exists(f): -- cgit v1.2.1 From 11b921f2e17586e394639e7ddbcaeae727ece4d0 Mon Sep 17 00:00:00 2001 From: Thiebaud Weksteen Date: Tue, 1 Nov 2016 15:54:23 +1100 Subject: Change _add_defaults_data_files override and add unittest --- setuptools/command/sdist.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 9975753d..ba980622 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -142,9 +142,10 @@ class sdist(sdist_add_defaults, orig.sdist): for filename in filenames]) def _add_defaults_data_files(self): - """ - Don't add any data files, but why? - """ + try: + sdist_add_defaults._add_defaults_data_files(self) + except TypeError: + log.warn("data_files contains unexpected objects") def check_readme(self): for f in self.READMES: -- cgit v1.2.1 From 5cfce47ddb304fc95660c1086f3230fc8fdead61 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 1 Dec 2016 11:23:45 -0500 Subject: Use super to resolve the superclass, but fall back to direct access on Python 2 where old style classes are used. Ref #843. --- setuptools/command/sdist.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index ba980622..84e29a1b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -143,7 +143,10 @@ class sdist(sdist_add_defaults, orig.sdist): def _add_defaults_data_files(self): try: - sdist_add_defaults._add_defaults_data_files(self) + if six.PY2: + sdist_add_defaults._add_defaults_data_files(self) + else: + super()._add_defaults_data_files() except TypeError: log.warn("data_files contains unexpected objects") -- cgit v1.2.1 From f14930e66601b462699c44384c482cd966f53b8f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 9 Dec 2016 08:16:33 -0500 Subject: Drop support for Python 2.6, removing lots of compatibility code for a leaner, cleaner codebase. Fixes #878. --- setuptools/command/sdist.py | 7 ------- 1 file changed, 7 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 84e29a1b..39e29d73 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -50,13 +50,6 @@ class sdist(sdist_add_defaults, orig.sdist): for cmd_name in self.get_sub_commands(): self.run_command(cmd_name) - # Call check_metadata only if no 'check' command - # (distutils <= 2.6) - import distutils.command - - if 'check' not in distutils.command.__all__: - self.check_metadata() - self.make_distribution() dist_files = getattr(self.distribution, 'dist_files', []) -- cgit v1.2.1 From ff371f18f0076bc63da05334f7e551c1cc29e10d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 22:34:28 -0500 Subject: Strip out vendored packages and require them instead. Ref #581. --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 84e29a1b..2c2d88af 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -5,7 +5,7 @@ import sys import io import contextlib -from setuptools.extern import six +import six from .py36compat import sdist_add_defaults -- cgit v1.2.1 From 3d0cc355fb5e8012cb8c72f0e25042a5a44f31d6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 24 Feb 2017 11:49:51 -0500 Subject: Revert "Merge pull request #933 from pypa/feature/581-depend-not-bundle" This reverts commit 089cdeb489a0fa94d11b7307b54210ef9aa40511, reversing changes made to aaec654d804cb78dbb6391afff721a63f26a71cd. --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 2c2d88af..84e29a1b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -5,7 +5,7 @@ import sys import io import contextlib -import six +from setuptools.extern import six from .py36compat import sdist_add_defaults -- cgit v1.2.1 From 500bb9a161e810523c48825491b853c5fbe595cc Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Tue, 22 Aug 2017 00:22:54 +0200 Subject: Improve README file list handling and add Markdown to the current list Markdown is a widely used format to write README files and documentation. This patch aims to simplify adding new formats and at the same time adds that one to the list. --- setuptools/command/sdist.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 84e29a1b..7b4d197d 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -37,7 +37,8 @@ class sdist(sdist_add_defaults, orig.sdist): negative_opt = {} - READMES = 'README', 'README.rst', 'README.txt' + README_EXTENSIONS = ['', '.rst', '.txt', '.md'] + READMES = tuple('README{}'.format(ext) for ext in README_EXTENSIONS) def run(self): self.run_command('egg_info') -- cgit v1.2.1 From e909e1cb7aff16a02a965fe3ebaa16a65d749d63 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Sun, 3 Sep 2017 20:10:22 +0200 Subject: Fix Python 2.6 support --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 7b4d197d..508148e0 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -38,7 +38,7 @@ class sdist(sdist_add_defaults, orig.sdist): negative_opt = {} README_EXTENSIONS = ['', '.rst', '.txt', '.md'] - READMES = tuple('README{}'.format(ext) for ext in README_EXTENSIONS) + READMES = tuple('README{0}'.format(ext) for ext in README_EXTENSIONS) def run(self): self.run_command('egg_info') -- cgit v1.2.1 From 760e2e1df9c9c9d1fc072e7b6ad9df4c32bfc835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= Date: Fri, 27 Jul 2018 14:36:34 +0200 Subject: Remove spurious executable permissions --- setuptools/command/sdist.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 setuptools/command/sdist.py (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py old mode 100755 new mode 100644 -- cgit v1.2.1 From ca0760af2071c333cda28d18279db95455ffa2de Mon Sep 17 00:00:00 2001 From: Deniz Taneli <7292227+dtaneli@users.noreply.github.com> Date: Sat, 27 Oct 2018 13:19:22 +0100 Subject: Setuptools will install licenses if included in setup.cfg Addressing #357 `python setup.py sdist` now includes the license file if `license_file` is included in `setup.cfg` unless it is explicitly excluded in `MANIFEST.in`. Co-Authored-By: Poyzan Nur Taneli <31743851+ptaneli@users.noreply.github.com> --- setuptools/command/sdist.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index bcfae4d8..a1b20733 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -6,6 +6,7 @@ import io import contextlib from setuptools.extern import six +from setuptools.extern.six.moves import configparser from .py36compat import sdist_add_defaults @@ -198,3 +199,27 @@ class sdist(sdist_add_defaults, orig.sdist): continue self.filelist.append(line) manifest.close() + + def check_license(self): + """Read the setup configuration file ('setup.cfg') and use it to find + if a license is defined with the 'license_file' attribute. + If the license is declared and exists, it will be added to + 'self.filelist'. + """ + + cfg_file = 'setup.cfg' + log.debug("Reading configuration from %s", cfg_file) + parser = configparser.RawConfigParser() + parser.read(cfg_file) + try: + license_file = parser.get('metadata', 'license_file') + + if not os.path.exists(license_file): + log.warn("warning: Failed to find license file '%s' in setup.cfg", + license_file) + return + + self.filelist.append(license_file) + except configparser.Error: + log.debug("license_file attribute is not defined in setup.cfg") + return -- cgit v1.2.1 From 4e4efa77722cc2e99171a2396252a4ddc98450e3 Mon Sep 17 00:00:00 2001 From: Deniz Taneli <7292227+dtaneli@users.noreply.github.com> Date: Sun, 28 Oct 2018 15:36:02 +0000 Subject: `check_license` no longer needs to parse `setup.cfg` --- setuptools/command/sdist.py | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index a1b20733..347f8817 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -201,25 +201,21 @@ class sdist(sdist_add_defaults, orig.sdist): manifest.close() def check_license(self): - """Read the setup configuration file ('setup.cfg') and use it to find - if a license is defined with the 'license_file' attribute. - If the license is declared and exists, it will be added to - 'self.filelist'. + """Checks if license_file' is configured and adds it to + 'self.filelist' if the value contains a valid path. """ - cfg_file = 'setup.cfg' - log.debug("Reading configuration from %s", cfg_file) - parser = configparser.RawConfigParser() - parser.read(cfg_file) + opts = self.distribution.get_option_dict('metadata') try: - license_file = parser.get('metadata', 'license_file') - - if not os.path.exists(license_file): - log.warn("warning: Failed to find license file '%s' in setup.cfg", - license_file) - return + # ignore the source of the value + _, license_file = opts.get('license_file') + except TypeError: + log.debug("'license_file' attribute is not defined") + return - self.filelist.append(license_file) - except configparser.Error: - log.debug("license_file attribute is not defined in setup.cfg") + if not os.path.exists(license_file): + log.warn("warning: Failed to find the configured license file '%s'", + license_file) return + + self.filelist.append(license_file) -- cgit v1.2.1 From 1047052e341d69c799e26ff889359e101c5e0499 Mon Sep 17 00:00:00 2001 From: Deniz Taneli <7292227+dtaneli@users.noreply.github.com> Date: Sat, 10 Nov 2018 19:55:12 +0000 Subject: Address review comments --- setuptools/command/sdist.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 347f8817..dc253981 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -6,7 +6,6 @@ import io import contextlib from setuptools.extern import six -from setuptools.extern.six.moves import configparser from .py36compat import sdist_add_defaults @@ -206,11 +205,12 @@ class sdist(sdist_add_defaults, orig.sdist): """ opts = self.distribution.get_option_dict('metadata') - try: - # ignore the source of the value - _, license_file = opts.get('license_file') - except TypeError: - log.debug("'license_file' attribute is not defined") + + # ignore the source of the value + _, license_file = opts.get('license_file', (None, None)) + + if license_file is None: + log.debug("'license_file' option was not specified") return if not os.path.exists(license_file): -- cgit v1.2.1 From d53e024af2f5d8f3a4a36588c3dc004d156bc830 Mon Sep 17 00:00:00 2001 From: Alexander Duryagin Date: Fri, 11 Jan 2019 15:57:54 +0300 Subject: do not change py36compat, put changes into sdist command --- setuptools/command/sdist.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index bcfae4d8..40965a67 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -121,6 +121,14 @@ class sdist(sdist_add_defaults, orig.sdist): if has_leaky_handle: read_template = __read_template_hack + def _add_defaults_optional(self): + if six.PY2: + sdist_add_defaults._add_defaults_optional(self) + else: + super()._add_defaults_optional() + if os.path.isfile('pyproject.toml'): + self.filelist.append('pyproject.toml') + def _add_defaults_python(self): """getting python files""" if self.distribution.has_pure_modules(): -- cgit v1.2.1 From 823ab9d2ec4ab89f90c0a781d872c9071b4afc13 Mon Sep 17 00:00:00 2001 From: Mick Koch Date: Mon, 20 May 2019 18:25:19 -0400 Subject: Add support for `license_files` option in metadata --- setuptools/command/sdist.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index dc253981..24316640 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -200,10 +200,12 @@ class sdist(sdist_add_defaults, orig.sdist): manifest.close() def check_license(self): - """Checks if license_file' is configured and adds it to - 'self.filelist' if the value contains a valid path. + """Checks if license_file' or 'license_files' is configured and adds any + valid paths to 'self.filelist'. """ + files = set() + opts = self.distribution.get_option_dict('metadata') # ignore the source of the value @@ -211,11 +213,19 @@ class sdist(sdist_add_defaults, orig.sdist): if license_file is None: log.debug("'license_file' option was not specified") - return + else: + files.add(license_file) - if not os.path.exists(license_file): - log.warn("warning: Failed to find the configured license file '%s'", - license_file) - return + try: + files.update(self.distribution.metadata.license_files) + except TypeError: + log.warn("warning: 'license_files' option is malformed") + + for f in files: + if not os.path.exists(f): + log.warn( + "warning: Failed to find the configured license file '%s'", + f) + continue - self.filelist.append(license_file) + self.filelist.append(f) -- cgit v1.2.1 From 4a31168e517134529c229b310e89039323fdb02f Mon Sep 17 00:00:00 2001 From: Mick Koch Date: Mon, 28 Oct 2019 18:45:42 -0400 Subject: Use an OrderedSet for accumulating license files --- setuptools/command/sdist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 24316640..6043e0b9 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -5,7 +5,7 @@ import sys import io import contextlib -from setuptools.extern import six +from setuptools.extern import six, ordered_set from .py36compat import sdist_add_defaults @@ -204,7 +204,7 @@ class sdist(sdist_add_defaults, orig.sdist): valid paths to 'self.filelist'. """ - files = set() + files = ordered_set.OrderedSet() opts = self.distribution.get_option_dict('metadata') -- cgit v1.2.1 From e08ec2b640f6b2bf943fea70e2a7f9881bbe6e91 Mon Sep 17 00:00:00 2001 From: Mick Koch Date: Mon, 28 Oct 2019 19:16:13 -0400 Subject: Filter out missing files and use extend() --- setuptools/command/sdist.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 6043e0b9..55ecdd97 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -226,6 +226,6 @@ class sdist(sdist_add_defaults, orig.sdist): log.warn( "warning: Failed to find the configured license file '%s'", f) - continue + files.remove(f) - self.filelist.append(f) + self.filelist.extend(files) -- cgit v1.2.1 From 3910bbb8d57a8f811ce863e9e1d09ae631cfe353 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 21 Dec 2019 22:04:09 -0500 Subject: Extract methods to separate _safe_data_files behavior and _add_data_files. --- setuptools/command/sdist.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 55ecdd97..eebdfd19 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -126,14 +126,27 @@ class sdist(sdist_add_defaults, orig.sdist): if self.distribution.has_pure_modules(): build_py = self.get_finalized_command('build_py') self.filelist.extend(build_py.get_source_files()) - # This functionality is incompatible with include_package_data, and - # will in fact create an infinite recursion if include_package_data - # is True. Use of include_package_data will imply that - # distutils-style automatic handling of package_data is disabled - if not self.distribution.include_package_data: - for _, src_dir, _, filenames in build_py.data_files: - self.filelist.extend([os.path.join(src_dir, filename) - for filename in filenames]) + self._add_data_files(self._safe_data_files(build_py)) + + def _safe_data_files(self, build_py): + """ + Extracting data_files from build_py is known to cause + infinite recursion errors when `include_package_data` + is enabled, so suppress it in that case. + """ + if self.distribution.include_package_data: + return () + return build_py.data_files + + def _add_data_files(self, data_files): + """ + Add data files as found in build_py.data_files. + """ + self.filelist.extend( + os.path.join(src_dir, name) + for _, src_dir, _, filenames in data_files + for name in filenames + ) def _add_defaults_data_files(self): try: -- cgit v1.2.1 From 796abd8dbec884cedf326cb5f85512a5d5648c4e Mon Sep 17 00:00:00 2001 From: Hugo Date: Wed, 8 Jan 2020 19:10:11 +0200 Subject: Fix for Python 4: replace unsafe six.PY3 with PY2 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index a851453f..8c3438ea 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -207,7 +207,7 @@ class sdist(sdist_add_defaults, orig.sdist): manifest = open(self.manifest, 'rb') for line in manifest: # The manifest must contain UTF-8. See #303. - if six.PY3: + if not six.PY2: try: line = line.decode('UTF-8') except UnicodeDecodeError: -- cgit v1.2.1 From fb7ab81a3d080422687bad71f9ae9d36eeefbee2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 16 Aug 2020 00:29:24 -0400 Subject: Remove Python 2 compatibility --- setuptools/command/sdist.py | 46 ++++++++------------------------------------- 1 file changed, 8 insertions(+), 38 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 8c3438ea..887b7efa 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -5,7 +5,7 @@ import sys import io import contextlib -from setuptools.extern import six, ordered_set +from setuptools.extern import ordered_set from .py36compat import sdist_add_defaults @@ -98,34 +98,8 @@ class sdist(sdist_add_defaults, orig.sdist): if orig_val is not NoValue: setattr(os, 'link', orig_val) - def __read_template_hack(self): - # This grody hack closes the template file (MANIFEST.in) if an - # exception occurs during read_template. - # Doing so prevents an error when easy_install attempts to delete the - # file. - try: - orig.sdist.read_template(self) - except Exception: - _, _, tb = sys.exc_info() - tb.tb_next.tb_frame.f_locals['template'].close() - raise - - # Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle - # has been fixed, so only override the method if we're using an earlier - # Python. - has_leaky_handle = ( - sys.version_info < (2, 7, 2) - or (3, 0) <= sys.version_info < (3, 1, 4) - or (3, 2) <= sys.version_info < (3, 2, 1) - ) - if has_leaky_handle: - read_template = __read_template_hack - def _add_defaults_optional(self): - if six.PY2: - sdist_add_defaults._add_defaults_optional(self) - else: - super()._add_defaults_optional() + super()._add_defaults_optional() if os.path.isfile('pyproject.toml'): self.filelist.append('pyproject.toml') @@ -158,10 +132,7 @@ class sdist(sdist_add_defaults, orig.sdist): def _add_defaults_data_files(self): try: - if six.PY2: - sdist_add_defaults._add_defaults_data_files(self) - else: - super()._add_defaults_data_files() + super()._add_defaults_data_files() except TypeError: log.warn("data_files contains unexpected objects") @@ -207,12 +178,11 @@ class sdist(sdist_add_defaults, orig.sdist): manifest = open(self.manifest, 'rb') for line in manifest: # The manifest must contain UTF-8. See #303. - if not six.PY2: - try: - line = line.decode('UTF-8') - except UnicodeDecodeError: - log.warn("%r not UTF-8 decodable -- skipping" % line) - continue + try: + line = line.decode('UTF-8') + except UnicodeDecodeError: + log.warn("%r not UTF-8 decodable -- skipping" % line) + continue # ignore comments and blank lines line = line.strip() if line.startswith('#') or not line: -- cgit v1.2.1 From 749b97499ea36d9a7660ed73db622837ae64c57d Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 28 Mar 2021 13:37:48 +0200 Subject: license_files - Add support for glob patterns + add default patterns --- setuptools/command/sdist.py | 53 +++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 887b7efa..cd308ab9 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,6 +4,8 @@ import os import sys import io import contextlib +import warnings +from glob import iglob from setuptools.extern import ordered_set @@ -194,29 +196,38 @@ class sdist(sdist_add_defaults, orig.sdist): """Checks if license_file' or 'license_files' is configured and adds any valid paths to 'self.filelist'. """ - - files = ordered_set.OrderedSet() - opts = self.distribution.get_option_dict('metadata') - # ignore the source of the value - _, license_file = opts.get('license_file', (None, None)) - - if license_file is None: - log.debug("'license_file' option was not specified") - else: - files.add(license_file) - + files = ordered_set.OrderedSet() try: - files.update(self.distribution.metadata.license_files) + license_files = self.distribution.metadata.license_files except TypeError: log.warn("warning: 'license_files' option is malformed") - - for f in files: - if not os.path.exists(f): - log.warn( - "warning: Failed to find the configured license file '%s'", - f) - files.remove(f) - - self.filelist.extend(files) + license_files = ordered_set.OrderedSet() + patterns = license_files if isinstance(license_files, ordered_set.OrderedSet) \ + else ordered_set.OrderedSet(license_files) + + if 'license_file' in opts: + warnings.warn( + "The 'license_file' option is deprecated. Use 'license_files' instead.", + DeprecationWarning) + patterns.append(opts['license_file'][1]) + + if 'license_file' not in opts and 'license_files' not in opts: + patterns = ('LICEN[CS]E*', 'COPYING*', 'NOTICE*', 'AUTHORS*') + + for pattern in patterns: + for path in iglob(pattern): + if path.endswith('~'): + log.debug( + "ignoring license file '%s' as it looks like a backup", + path) + continue + + if path not in files and os.path.isfile(path): + log.info( + "adding license file '%s' (matched pattern '%s')", + path, pattern) + files.add(path) + + self.filelist.extend(sorted(files)) -- cgit v1.2.1 From 0f34639e5aa630b8cbe32af9cfe8dfec7be890e7 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sun, 28 Mar 2021 17:34:01 +0200 Subject: Change deprecation warning --- setuptools/command/sdist.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index cd308ab9..278b8ce0 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,7 +4,6 @@ import os import sys import io import contextlib -import warnings from glob import iglob from setuptools.extern import ordered_set @@ -208,9 +207,9 @@ class sdist(sdist_add_defaults, orig.sdist): else ordered_set.OrderedSet(license_files) if 'license_file' in opts: - warnings.warn( - "The 'license_file' option is deprecated. Use 'license_files' instead.", - DeprecationWarning) + log.warn( + "warning: the 'license_file' option is deprecated, " + "use 'license_files' instead") patterns.append(opts['license_file'][1]) if 'license_file' not in opts and 'license_files' not in opts: -- cgit v1.2.1 From 608c376e86326c879dd52b56660b2247a3ca854e Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 3 Apr 2021 21:34:00 +0200 Subject: Small changes --- setuptools/command/sdist.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 278b8ce0..a6ea814a 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -213,6 +213,9 @@ class sdist(sdist_add_defaults, orig.sdist): patterns.append(opts['license_file'][1]) if 'license_file' not in opts and 'license_files' not in opts: + # Default patterns match the ones wheel uses + # See https://wheel.readthedocs.io/en/stable/user_guide.html + # -> 'Including license files in the generated wheel file' patterns = ('LICEN[CS]E*', 'COPYING*', 'NOTICE*', 'AUTHORS*') for pattern in patterns: -- cgit v1.2.1 From 3544de73b3662a27fac14d8eb9f5c841668d66de Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 17 Apr 2021 20:48:12 +0200 Subject: Add License-File field to package metadata --- setuptools/command/sdist.py | 46 --------------------------------------------- 1 file changed, 46 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index a6ea814a..4a014283 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,9 +4,6 @@ import os import sys import io import contextlib -from glob import iglob - -from setuptools.extern import ordered_set from .py36compat import sdist_add_defaults @@ -190,46 +187,3 @@ class sdist(sdist_add_defaults, orig.sdist): continue self.filelist.append(line) manifest.close() - - def check_license(self): - """Checks if license_file' or 'license_files' is configured and adds any - valid paths to 'self.filelist'. - """ - opts = self.distribution.get_option_dict('metadata') - - files = ordered_set.OrderedSet() - try: - license_files = self.distribution.metadata.license_files - except TypeError: - log.warn("warning: 'license_files' option is malformed") - license_files = ordered_set.OrderedSet() - patterns = license_files if isinstance(license_files, ordered_set.OrderedSet) \ - else ordered_set.OrderedSet(license_files) - - if 'license_file' in opts: - log.warn( - "warning: the 'license_file' option is deprecated, " - "use 'license_files' instead") - patterns.append(opts['license_file'][1]) - - if 'license_file' not in opts and 'license_files' not in opts: - # Default patterns match the ones wheel uses - # See https://wheel.readthedocs.io/en/stable/user_guide.html - # -> 'Including license files in the generated wheel file' - patterns = ('LICEN[CS]E*', 'COPYING*', 'NOTICE*', 'AUTHORS*') - - for pattern in patterns: - for path in iglob(pattern): - if path.endswith('~'): - log.debug( - "ignoring license file '%s' as it looks like a backup", - path) - continue - - if path not in files and os.path.isfile(path): - log.info( - "adding license file '%s' (matched pattern '%s')", - path, pattern) - files.add(path) - - self.filelist.extend(sorted(files)) -- cgit v1.2.1 From 576dece3643485052ba90fdadc81dfcf6028acc4 Mon Sep 17 00:00:00 2001 From: John Marshall Date: Wed, 22 Sep 2021 21:51:21 +0100 Subject: sdist: Accept -u/--owner and -g/--group options Controlling the file ownership recorded in tar archives is useful for those striving towards reproducible builds. These options are already understood by distutils.command.sdist.sdist, so just need to be accepted by setuptools.command.sdist.sdist to be propagated. Fixes #1893. --- setuptools/command/sdist.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 4a014283..e8062f2e 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -31,6 +31,10 @@ class sdist(sdist_add_defaults, orig.sdist): ('dist-dir=', 'd', "directory to put the source distribution archive(s) in " "[default: dist]"), + ('owner=', 'u', + "Owner name used when creating a tar file [default: current user]"), + ('group=', 'g', + "Group name used when creating a tar file [default: current group]"), ] negative_opt = {} -- cgit v1.2.1 From 2e66eb7147ae1e8a799b2276c7340f48f63a7220 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Mon, 1 Nov 2021 19:47:33 +0000 Subject: Fix 1461: Better loop breaker for `manifest_maker` The inconsistency for the `package_data` configuration in sdists when `include_package_data=True` in #1461 have been causing some problems for the community for a while, as also shown in #2835. As pointed out by [@jaraco](https://github.com/pypa/setuptools/issues/1461#issuecomment-749092366), this was being caused by a mechanism to break the recursion between the `egg_info` and `sdist` commands. In summary the loop is caused by the following behaviour: - the `egg_info` command uses a subclass of `sdist` (`manifest_maker`) to calculate the MANIFEST, - the `sdist` class needs to know the MANIFEST to calculate the data files when `include_package_data=True` Previously, the mechanism to break this loop was to simply ignore the data files in `sdist` when `include_package_data=True`. The approach implemented in this change was to replace this mechanism, by allowing `manifest_maker` to override the `_safe_data_files` method from `sdist`. --- Please notice [an extensive experiment] (https://github.com/abravalheri/experiment-setuptools-package-data) was carried out to investigate the previous confusing behaviour. There is also [a simplified theoretical analysis] (https://github.com/pyscaffold/pyscaffold/pull/535#issuecomment-956296407) comparing the observed behavior in the experiment and the expected one. This analysis point out to the same offender indicated by [@jaraco](https://github.com/pypa/setuptools/issues/1461#issuecomment-749092366) (which is being replaced in this change). --- setuptools/command/sdist.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'setuptools/command/sdist.py') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index e8062f2e..0285b690 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -114,12 +114,15 @@ class sdist(sdist_add_defaults, orig.sdist): def _safe_data_files(self, build_py): """ - Extracting data_files from build_py is known to cause - infinite recursion errors when `include_package_data` - is enabled, so suppress it in that case. + Since the ``sdist`` class is also used to compute the MANIFEST + (via :obj:`setuptools.command.egg_info.manifest_maker`), + there might be recursion problems when trying to obtain the list of + data_files and ``include_package_data=True`` (which in turn depends on + the files included in the MANIFEST). + + To avoid that, ``manifest_maker`` should be able to overwrite this + method and avoid recursive attempts to build/analyze the MANIFEST. """ - if self.distribution.include_package_data: - return () return build_py.data_files def _add_data_files(self, data_files): -- cgit v1.2.1