From 4a63bc6f16d3a4616edae1403f3c7bd67bdfa2f3 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 6 Jul 2005 01:37:41 +0000 Subject: Added ``egg_info`` command to ``setuptools``-based packages. This command just creates or updates the "projectname.egg-info" directory, without building an egg. It's used by the ``bdist_egg`` command now, and will be used by the ``test`` and ``develop`` commands later on. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041077 --- setuptools/command/egg_info.py | 164 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100755 setuptools/command/egg_info.py (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py new file mode 100755 index 00000000..b35e1956 --- /dev/null +++ b/setuptools/command/egg_info.py @@ -0,0 +1,164 @@ +"""setuptools.command.egg_info + +Create a distribution's .egg-info directory and contents""" + +# This module should be kept compatible with Python 2.3 +import os +from setuptools import Command +from distutils.errors import * +from distutils import log +from pkg_resources import parse_requirements, safe_name, \ + safe_version, yield_lines + + +class egg_info(Command): + + description = "create a distribution's .egg-info directory" + + user_options = [ + ('egg-base=', 'e', "directory containing .egg-info directories" + " (default: top of the source tree)"), + ('tag-svn-revision', 'r', + "Add subversion revision ID to version number"), + ('tag-date', 'd', "Add date stamp (e.g. 20050528) to version number"), + ('tag-build=', 'b', "Specify explicit tag to add to version number"), + ] + + boolean_options = ['tag-date','tag-svn-revision'] + + + def initialize_options (self): + self.egg_name = None + self.egg_version = None + self.egg_base = None + self.egg_info = None + self.tag_build = None + self.tag_svn_revision = 0 + self.tag_date = 0 + + + + + def finalize_options (self): + self.egg_name = safe_name(self.distribution.get_name()) + self.egg_version = self.tagged_version() + + try: + list( + parse_requirements('%s==%s' % (self.egg_name,self.egg_version)) + ) + except ValueError: + raise DistutilsOptionError( + "Invalid distribution name or version syntax: %s-%s" % + (self.egg_name,self.egg_version) + ) + + if self.egg_base is None: + dirs = self.distribution.package_dir + self.egg_base = (dirs or {}).get('',os.curdir) + + self.ensure_dirname('egg_base') + self.egg_info = os.path.join(self.egg_base, self.egg_name+'.egg-info') + + + + + + + + + + + + + + + + + + + + + + def run(self): + # Make the .egg-info directory, then write PKG-INFO and requires.txt + self.mkpath(self.egg_info) + + log.info("writing %s" % os.path.join(self.egg_info,'PKG-INFO')) + if not self.dry_run: + metadata = self.distribution.metadata + metadata.version, oldver = self.egg_version, metadata.version + metadata.name, oldname = self.egg_name, metadata.name + try: + metadata.write_pkg_info(self.egg_info) + finally: + metadata.name, metadata.version = oldname, oldver + + self.write_requirements() + if os.path.exists(os.path.join(self.egg_info,'depends.txt')): + log.warn( + "WARNING: 'depends.txt' will not be used by setuptools 0.6!\n" + "Use the install_requires/extras_require setup() args instead." + ) + + + def write_requirements(self): + dist = self.distribution + + if not getattr(dist,'install_requires',None) and \ + not getattr(dist,'extras_require',None): return + + requires = os.path.join(self.egg_info,"requires.txt") + log.info("writing %s", requires) + + if not self.dry_run: + f = open(requires, 'wt') + f.write('\n'.join(yield_lines(dist.install_requires))) + for extra,reqs in dist.extras_require.items(): + f.write('\n\n[%s]\n%s' % (extra, '\n'.join(yield_lines(reqs)))) + f.close() + + + + + def tagged_version(self): + version = self.distribution.get_version() + if self.tag_build: + version+='-'+self.tag_build + + if self.tag_svn_revision and os.path.exists('.svn'): + version += '-%s' % self.get_svn_revision() + + if self.tag_date: + import time + version += time.strftime("-%Y%m%d") + + return safe_version(version) + + + def get_svn_revision(self): + stdin, stdout = os.popen4("svn info"); stdin.close() + result = stdout.read(); stdout.close() + import re + match = re.search(r'Last Changed Rev: (\d+)', result) + if not match: + raise RuntimeError("svn info error: %s" % result.strip()) + return match.group(1) + + + + + + + + + + + + + + + + + + -- cgit v1.2.1 From 8e7eabf110643907fd1f1979d0674cf615268124 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Thu, 7 Jul 2005 02:01:54 +0000 Subject: Slightly changed the format of the generated version when you use ``--tag-build`` on the "egg_info" command, so that you can make tagged revisions compare *lower* than the version specified in setup.py (e.g. by using ``--tag-build=dev``). --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041086 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index b35e1956..0223becb 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -124,7 +124,7 @@ class egg_info(Command): def tagged_version(self): version = self.distribution.get_version() if self.tag_build: - version+='-'+self.tag_build + version+=self.tag_build if self.tag_svn_revision and os.path.exists('.svn'): version += '-%s' % self.get_svn_revision() -- cgit v1.2.1 From 56fcb8fdcc377acf0d74430a3d2d4dbffe306d44 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 8 Jul 2005 04:45:58 +0000 Subject: The "egg_info" command now always sets the distribution metadata to "safe" forms of the distribution name and version, so that distribution files will be generated with parseable names (i.e., ones that don't include '-' in the name or version). Also, this means that if you use the various ``--tag`` options of "egg_info", any distributions generated will use the tags in the version, not just egg distributions. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041092 --- setuptools/command/egg_info.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 0223becb..6fffbe24 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -60,13 +60,13 @@ class egg_info(Command): self.ensure_dirname('egg_base') self.egg_info = os.path.join(self.egg_base, self.egg_name+'.egg-info') - - - - - - - + # Set package version and name for the benefit of dumber commands + # (e.g. sdist, bdist_wininst, etc.) We escape '-' so filenames will + # be more machine-parseable. + # + metadata = self.distribution.metadata + metadata.version = self.egg_version.replace('-','_') + metadata.name = self.egg_name.replace('-','_') @@ -90,6 +90,8 @@ class egg_info(Command): metadata.version, oldver = self.egg_version, metadata.version metadata.name, oldname = self.egg_name, metadata.name try: + # write unescaped data to PKG-INFO, so older pkg_resources + # can still parse it metadata.write_pkg_info(self.egg_info) finally: metadata.name, metadata.version = oldname, oldver @@ -119,8 +121,6 @@ class egg_info(Command): f.close() - - def tagged_version(self): version = self.distribution.get_version() if self.tag_build: -- cgit v1.2.1 From f0fd39e276b547cfa3578da2de8c034bf547c6ba Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 9 Jul 2005 16:25:54 +0000 Subject: Changed --tag-svn-revision to include an "r" in front of the revision number for better readability. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041106 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 6fffbe24..907e47fb 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -127,7 +127,7 @@ class egg_info(Command): version+=self.tag_build if self.tag_svn_revision and os.path.exists('.svn'): - version += '-%s' % self.get_svn_revision() + version += '-r%s' % self.get_svn_revision() if self.tag_date: import time -- cgit v1.2.1 From 451377d0e877fc610d1bdf8181ba70a90e4c14cc Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sun, 10 Jul 2005 04:49:31 +0000 Subject: Detect and handle conflicts with "unmanaged" packages when installing packages managed by EasyInstall. Also, add an option to exclude source files from .egg distributions. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041109 --- setuptools/command/egg_info.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 907e47fb..dca4e2a3 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -97,6 +97,7 @@ class egg_info(Command): metadata.name, metadata.version = oldname, oldver self.write_requirements() + self.write_toplevel_names() if os.path.exists(os.path.join(self.egg_info,'depends.txt')): log.warn( "WARNING: 'depends.txt' will not be used by setuptools 0.6!\n" @@ -106,7 +107,6 @@ class egg_info(Command): def write_requirements(self): dist = self.distribution - if not getattr(dist,'install_requires',None) and \ not getattr(dist,'extras_require',None): return @@ -125,14 +125,11 @@ class egg_info(Command): version = self.distribution.get_version() if self.tag_build: version+=self.tag_build - if self.tag_svn_revision and os.path.exists('.svn'): version += '-r%s' % self.get_svn_revision() - if self.tag_date: import time version += time.strftime("-%Y%m%d") - return safe_version(version) @@ -142,23 +139,26 @@ class egg_info(Command): import re match = re.search(r'Last Changed Rev: (\d+)', result) if not match: - raise RuntimeError("svn info error: %s" % result.strip()) + raise DistutilsError("svn info error: %s" % result.strip()) return match.group(1) - - - - - - - - - - - - - - + def write_toplevel_names(self): + pkgs = dict.fromkeys(self.distribution.packages or ()) + pkgs.update(dict.fromkeys(self.distribution.py_modules or ())) + for ext in self.distribution.ext_modules or (): + if isinstance(ext,tuple): + name,buildinfo = ext + else: + name = ext.name + pkgs[name]=1 + pkgs = dict.fromkeys([k.split('.',1)[0] for k in pkgs]) + toplevel = os.path.join(self.egg_info,"top_level.txt") + log.info("writing list of top-level names to %s" % toplevel) + if not self.dry_run: + f = open(toplevel, 'wt') + f.write('\n'.join(pkgs)) + f.write('\n') + f.close() -- cgit v1.2.1 From 39fc2a15c4a236ae7b378ebb98aee545776d2ec1 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sun, 10 Jul 2005 15:43:08 +0000 Subject: Implement ``namespace_packages`` keyword to ``setup()``. Added keyword summary to setuptools doc. Begin work on ``zip_safe`` flag. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041113 --- setuptools/command/egg_info.py | 69 +++++++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 14 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index dca4e2a3..68e2fefb 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -9,7 +9,7 @@ from distutils.errors import * from distutils import log from pkg_resources import parse_requirements, safe_name, \ safe_version, yield_lines - +from setuptools.dist import iter_distribution_names class egg_info(Command): @@ -83,8 +83,8 @@ class egg_info(Command): def run(self): # Make the .egg-info directory, then write PKG-INFO and requires.txt self.mkpath(self.egg_info) + log.info("writing %s" % os.path.join(self.egg_info,'PKG-INFO')) - log.info("writing %s" % os.path.join(self.egg_info,'PKG-INFO')) if not self.dry_run: metadata = self.distribution.metadata metadata.version, oldver = self.egg_version, metadata.version @@ -96,15 +96,16 @@ class egg_info(Command): finally: metadata.name, metadata.version = oldname, oldver + self.write_namespace_packages() self.write_requirements() self.write_toplevel_names() + if os.path.exists(os.path.join(self.egg_info,'depends.txt')): log.warn( "WARNING: 'depends.txt' will not be used by setuptools 0.6!\n" "Use the install_requires/extras_require setup() args instead." ) - def write_requirements(self): dist = self.distribution if not getattr(dist,'install_requires',None) and \ @@ -120,7 +121,6 @@ class egg_info(Command): f.write('\n\n[%s]\n%s' % (extra, '\n'.join(yield_lines(reqs)))) f.close() - def tagged_version(self): version = self.distribution.get_version() if self.tag_build: @@ -144,21 +144,62 @@ class egg_info(Command): def write_toplevel_names(self): - pkgs = dict.fromkeys(self.distribution.packages or ()) - pkgs.update(dict.fromkeys(self.distribution.py_modules or ())) - for ext in self.distribution.ext_modules or (): - if isinstance(ext,tuple): - name,buildinfo = ext - else: - name = ext.name - pkgs[name]=1 - pkgs = dict.fromkeys([k.split('.',1)[0] for k in pkgs]) - toplevel = os.path.join(self.egg_info,"top_level.txt") + pkgs = dict.fromkeys( + [k.split('.',1)[0] + for k in iter_distribution_names(self.distribution) + ] + ) + toplevel = os.path.join(self.egg_info, "top_level.txt") log.info("writing list of top-level names to %s" % toplevel) if not self.dry_run: f = open(toplevel, 'wt') f.write('\n'.join(pkgs)) f.write('\n') f.close() + + + + + + + def write_namespace_packages(self): + nsp = getattr(self.distribution,'namespace_packages',None) + if nsp is None: + return + + filename = os.path.join(self.egg_info,"namespace_packages.txt") + + if nsp: + log.info("writing %s", filename) + if not self.dry_run: + f = open(filename, 'wt') + f.write('\n'.join(nsp)) + f.write('\n') + f.close() + + elif os.path.exists(filename): + log.info("deleting %s", filename) + if not self.dry_run: + os.unlink(filename) + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1 From 811182ed59bb1b233e2c4589ce15133bd5dad4e5 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 16 Jul 2005 16:43:02 +0000 Subject: Fix only detecting the revision number of the setup directory, not the highest revision number for the project as a whole. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041129 --- setuptools/command/egg_info.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 68e2fefb..5e5686a3 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -134,13 +134,16 @@ class egg_info(Command): def get_svn_revision(self): - stdin, stdout = os.popen4("svn info"); stdin.close() + stdin, stdout = os.popen4("svn info -R"); stdin.close() result = stdout.read(); stdout.close() import re - match = re.search(r'Last Changed Rev: (\d+)', result) - if not match: + revisions = [ + int(match.group(1)) + for match in re.finditer(r'Last Changed Rev: (\d+)', result) + ] + if not revisions: raise DistutilsError("svn info error: %s" % result.strip()) - return match.group(1) + return str(max(revisions)) def write_toplevel_names(self): @@ -159,9 +162,6 @@ class egg_info(Command): - - - def write_namespace_packages(self): nsp = getattr(self.distribution,'namespace_packages',None) if nsp is None: -- cgit v1.2.1 From 8618cfa8ac93431ffcede4f3987b559449bbbcb8 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sun, 24 Jul 2005 17:59:27 +0000 Subject: Fix eager resource extraction. Add eager_resources setup() argument. Add support for obtaining project-level resources by making get_provider() accept Requirement objects. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041151 --- setuptools/command/egg_info.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 5e5686a3..a5418568 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -96,13 +96,13 @@ class egg_info(Command): finally: metadata.name, metadata.version = oldname, oldver - self.write_namespace_packages() self.write_requirements() self.write_toplevel_names() - + self.write_or_delete_dist_arg('namespace_packages') + self.write_or_delete_dist_arg('eager_resources') if os.path.exists(os.path.join(self.egg_info,'depends.txt')): log.warn( - "WARNING: 'depends.txt' will not be used by setuptools 0.6!\n" + "WARNING: 'depends.txt' is not used by setuptools 0.6!\n" "Use the install_requires/extras_require setup() args instead." ) @@ -162,18 +162,19 @@ class egg_info(Command): - def write_namespace_packages(self): - nsp = getattr(self.distribution,'namespace_packages',None) - if nsp is None: + def write_or_delete_dist_arg(self, argname, filename=None): + value = getattr(self.distribution, argname, None) + if value is None: return - filename = os.path.join(self.egg_info,"namespace_packages.txt") + filename = filename or argname+'.txt' + filename = os.path.join(self.egg_info,filename) - if nsp: + if value: log.info("writing %s", filename) if not self.dry_run: f = open(filename, 'wt') - f.write('\n'.join(nsp)) + f.write('\n'.join(value)) f.write('\n') f.close() @@ -200,6 +201,5 @@ class egg_info(Command): - -- cgit v1.2.1 From 1c40632b88d76aea178e751483645ec3d32c81d9 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sun, 24 Jul 2005 22:47:06 +0000 Subject: Implement "entry points" for dynamic discovery of drivers and plugins. Change setuptools to discover setup commands using an entry point group called "distutils.commands". Thanks to Ian Bicking for the suggestion that led to designing this super-cool feature. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041152 --- setuptools/command/egg_info.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a5418568..8577230f 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -8,7 +8,7 @@ from setuptools import Command from distutils.errors import * from distutils import log from pkg_resources import parse_requirements, safe_name, \ - safe_version, yield_lines + safe_version, yield_lines, EntryPoint from setuptools.dist import iter_distribution_names class egg_info(Command): @@ -95,7 +95,7 @@ class egg_info(Command): metadata.write_pkg_info(self.egg_info) finally: metadata.name, metadata.version = oldname, oldver - + self.write_entry_points() self.write_requirements() self.write_toplevel_names() self.write_or_delete_dist_arg('namespace_packages') @@ -183,23 +183,23 @@ class egg_info(Command): if not self.dry_run: os.unlink(filename) + def write_entry_points(self): + ep = getattr(self.distribution,'entry_points',None) + if ep is None: + return + epname = os.path.join(self.egg_info,"entry_points.txt") + log.info("writing %s", epname) - - - - - - - - - - - - - - - - - + if not self.dry_run: + f = open(epname, 'wt') + if isinstance(ep,basestring): + f.write(ep) + else: + for section, contents in ep.items(): + if not isinstance(contents,basestring): + contents = EntryPoint.parse_list(section, contents) + contents = '\n'.join(map(str,contents.values())) + f.write('[%s]\n%s\n\n' % (section,contents)) + f.close() -- cgit v1.2.1 From 8a29467d941a7983d5f6eadc5c0e1624417944b6 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 6 Aug 2005 18:46:28 +0000 Subject: Enhanced setuptools infrastructure to support distutils extensions that can be plugged in at setup() time to define new setup() arguments or distutils commands. This allows modularization and reuse of distutils extensions in a way that was previously not possible. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041180 --- setuptools/command/egg_info.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8577230f..7d0a1473 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -9,7 +9,6 @@ from distutils.errors import * from distutils import log from pkg_resources import parse_requirements, safe_name, \ safe_version, yield_lines, EntryPoint -from setuptools.dist import iter_distribution_names class egg_info(Command): @@ -39,6 +38,7 @@ class egg_info(Command): + def finalize_options (self): self.egg_name = safe_name(self.distribution.get_name()) self.egg_version = self.tagged_version() @@ -149,7 +149,7 @@ class egg_info(Command): def write_toplevel_names(self): pkgs = dict.fromkeys( [k.split('.',1)[0] - for k in iter_distribution_names(self.distribution) + for k in self.distribution.iter_distribution_names() ] ) toplevel = os.path.join(self.egg_info, "top_level.txt") @@ -164,12 +164,8 @@ class egg_info(Command): def write_or_delete_dist_arg(self, argname, filename=None): value = getattr(self.distribution, argname, None) - if value is None: - return - filename = filename or argname+'.txt' filename = os.path.join(self.egg_info,filename) - if value: log.info("writing %s", filename) if not self.dry_run: @@ -177,8 +173,12 @@ class egg_info(Command): f.write('\n'.join(value)) f.write('\n') f.close() - elif os.path.exists(filename): + if value is None: + log.warn( + "%s not set in setup(), but %s exists", argname, filename + ) + return log.info("deleting %s", filename) if not self.dry_run: os.unlink(filename) -- cgit v1.2.1 From 899e59ff5150705852f15f90fddbfedf7544bec1 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 6 Aug 2005 21:17:50 +0000 Subject: Allow distutils extensions to define new kinds of metadata that can be written to EGG-INFO. Extensible applications and frameworks can thus make it possible for plugin projects to supply setup() metadata that can then be used by the application or framework. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041183 --- setuptools/command/egg_info.py | 213 ++++++++++++++++++++++++----------------- 1 file changed, 127 insertions(+), 86 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 7d0a1473..ae3c762b 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -8,7 +8,7 @@ from setuptools import Command from distutils.errors import * from distutils import log from pkg_resources import parse_requirements, safe_name, \ - safe_version, yield_lines, EntryPoint + safe_version, yield_lines, EntryPoint, iter_entry_points class egg_info(Command): @@ -80,47 +80,55 @@ class egg_info(Command): - def run(self): - # Make the .egg-info directory, then write PKG-INFO and requires.txt - self.mkpath(self.egg_info) - log.info("writing %s" % os.path.join(self.egg_info,'PKG-INFO')) - - if not self.dry_run: - metadata = self.distribution.metadata - metadata.version, oldver = self.egg_version, metadata.version - metadata.name, oldname = self.egg_name, metadata.name - try: - # write unescaped data to PKG-INFO, so older pkg_resources - # can still parse it - metadata.write_pkg_info(self.egg_info) - finally: - metadata.name, metadata.version = oldname, oldver - self.write_entry_points() - self.write_requirements() - self.write_toplevel_names() - self.write_or_delete_dist_arg('namespace_packages') - self.write_or_delete_dist_arg('eager_resources') - if os.path.exists(os.path.join(self.egg_info,'depends.txt')): - log.warn( - "WARNING: 'depends.txt' is not used by setuptools 0.6!\n" - "Use the install_requires/extras_require setup() args instead." - ) + def write_or_delete_file(self, what, filename, data): + """Write `data` to `filename` or delete if empty - def write_requirements(self): - dist = self.distribution - if not getattr(dist,'install_requires',None) and \ - not getattr(dist,'extras_require',None): return + If `data` is non-empty, this routine is the same as ``write_file()``. + If `data` is empty but not ``None``, this is the same as calling + ``delete_file(filename)`. If `data` is ``None``, then this is a no-op + unless `filename` exists, in which case a warning is issued about the + orphaned file. + """ + if data: + self.write_file(what, filename, data) + elif os.path.exists(filename): + if data is None: + log.warn( + "%s not set in setup(), but %s exists", what, filename + ) + return + else: + self.delete_file(filename) - requires = os.path.join(self.egg_info,"requires.txt") - log.info("writing %s", requires) + def write_file(self, what, filename, data): + """Write `data` to `filename` (if not a dry run) after announcing it + `what` is used in a log message to identify what is being written + to the file. + """ + log.info("writing %s to %s", what, filename) if not self.dry_run: - f = open(requires, 'wt') - f.write('\n'.join(yield_lines(dist.install_requires))) - for extra,reqs in dist.extras_require.items(): - f.write('\n\n[%s]\n%s' % (extra, '\n'.join(yield_lines(reqs)))) + f = open(filename, 'wb') + f.write(data) f.close() + def delete_file(self, filename): + """Delete `filename` (if not a dry run) after announcing it""" + log.info("deleting %s", filename) + if not self.dry_run: + os.unlink(filename) + + + + + def run(self): + # Make the .egg-info directory, then write PKG-INFO and requires.txt + self.mkpath(self.egg_info) + installer = self.distribution.fetch_build_egg + for ep in iter_entry_points('egg_info.writers'): + writer = ep.load(installer=installer) + writer(self, ep.name, os.path.join(self.egg_info,ep.name)) + def tagged_version(self): version = self.distribution.get_version() if self.tag_build: @@ -132,7 +140,6 @@ class egg_info(Command): version += time.strftime("-%Y%m%d") return safe_version(version) - def get_svn_revision(self): stdin, stdout = os.popen4("svn info -R"); stdin.close() result = stdout.read(); stdout.close() @@ -146,60 +153,94 @@ class egg_info(Command): return str(max(revisions)) - def write_toplevel_names(self): - pkgs = dict.fromkeys( - [k.split('.',1)[0] - for k in self.distribution.iter_distribution_names() - ] + + + + + + + + + +def write_pkg_info(cmd, basename, filename): + log.info("writing %s", filename) + if not cmd.dry_run: + metadata = cmd.distribution.metadata + metadata.version, oldver = cmd.egg_version, metadata.version + metadata.name, oldname = cmd.egg_name, metadata.name + try: + # write unescaped data to PKG-INFO, so older pkg_resources + # can still parse it + metadata.write_pkg_info(cmd.egg_info) + finally: + metadata.name, metadata.version = oldname, oldver + +def warn_depends_obsolete(cmd, basename, filename): + if os.path.exists(filename): + log.warn( + "WARNING: 'depends.txt' is not used by setuptools 0.6!\n" + "Use the install_requires/extras_require setup() args instead." ) - toplevel = os.path.join(self.egg_info, "top_level.txt") - log.info("writing list of top-level names to %s" % toplevel) - if not self.dry_run: - f = open(toplevel, 'wt') - f.write('\n'.join(pkgs)) - f.write('\n') - f.close() + + +def write_requirements(cmd, basename, filename): + dist = cmd.distribution + data = ['\n'.join(yield_lines(dist.install_requires or ()))] + for extra,reqs in (dist.extras_require or {}).items(): + data.append('\n\n[%s]\n%s' % (extra, '\n'.join(yield_lines(reqs)))) + cmd.write_or_delete_file("requirements", filename, ''.join(data)) + +def write_toplevel_names(cmd, basename, filename): + pkgs = dict.fromkeys( + [k.split('.',1)[0] + for k in cmd.distribution.iter_distribution_names() + ] + ) + cmd.write_file("top-level names", filename, '\n'.join(pkgs)+'\n') + + + + + + +def write_arg(cmd, basename, filename): + argname = os.path.splitext(basename)[0] + value = getattr(cmd.distribution, argname, None) + if value is not None: + value = '\n'.join(value)+'\n' + cmd.write_or_delete_file(argname, filename, value) + +def write_entries(cmd, basename, filename): + ep = cmd.distribution.entry_points + + if isinstance(ep,basestring) or ep is None: + data = ep + elif ep is not None: + data = [] + for section, contents in ep.items(): + if not isinstance(contents,basestring): + contents = EntryPoint.parse_list(section, contents) + contents = '\n'.join(map(str,contents.values())) + data.append('[%s]\n%s\n\n' % (section,contents)) + data = ''.join(data) + + cmd.write_or_delete_file('entry points', filename, data) + + + + + + + + + + + + - def write_or_delete_dist_arg(self, argname, filename=None): - value = getattr(self.distribution, argname, None) - filename = filename or argname+'.txt' - filename = os.path.join(self.egg_info,filename) - if value: - log.info("writing %s", filename) - if not self.dry_run: - f = open(filename, 'wt') - f.write('\n'.join(value)) - f.write('\n') - f.close() - elif os.path.exists(filename): - if value is None: - log.warn( - "%s not set in setup(), but %s exists", argname, filename - ) - return - log.info("deleting %s", filename) - if not self.dry_run: - os.unlink(filename) - def write_entry_points(self): - ep = getattr(self.distribution,'entry_points',None) - if ep is None: - return - epname = os.path.join(self.egg_info,"entry_points.txt") - log.info("writing %s", epname) - if not self.dry_run: - f = open(epname, 'wt') - if isinstance(ep,basestring): - f.write(ep) - else: - for section, contents in ep.items(): - if not isinstance(contents,basestring): - contents = EntryPoint.parse_list(section, contents) - contents = '\n'.join(map(str,contents.values())) - f.write('[%s]\n%s\n\n' % (section,contents)) - f.close() -- cgit v1.2.1 From 53cf2db1ed9a75fc4093cb81277510865e8a6db9 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 13 Aug 2005 23:04:08 +0000 Subject: Added docs for main EntryPoint APIs, and cleaned up the API itself a bit. Also fixed a few bugs. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041192 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index ae3c762b..c05601a4 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -219,7 +219,7 @@ def write_entries(cmd, basename, filename): data = [] for section, contents in ep.items(): if not isinstance(contents,basestring): - contents = EntryPoint.parse_list(section, contents) + contents = EntryPoint.parse_group(section, contents) contents = '\n'.join(map(str,contents.values())) data.append('[%s]\n%s\n\n' % (section,contents)) data = ''.join(data) -- cgit v1.2.1 From 6861a1ffbb22a507dd28571f7d3e48d9f0d089de Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sun, 21 Aug 2005 21:49:39 +0000 Subject: Parse .svn/entries directly instead of using 'svn info' to obtain a revision number. (Christopher Lenz reported that svn info's output is different in non-English locales.) --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041212 --- setuptools/command/egg_info.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index c05601a4..8bfc8d42 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -3,7 +3,7 @@ Create a distribution's .egg-info directory and contents""" # This module should be kept compatible with Python 2.3 -import os +import os, re from setuptools import Command from distutils.errors import * from distutils import log @@ -141,26 +141,26 @@ class egg_info(Command): return safe_version(version) def get_svn_revision(self): - stdin, stdout = os.popen4("svn info -R"); stdin.close() - result = stdout.read(); stdout.close() - import re - revisions = [ - int(match.group(1)) - for match in re.finditer(r'Last Changed Rev: (\d+)', result) - ] - if not revisions: - raise DistutilsError("svn info error: %s" % result.strip()) - return str(max(revisions)) - - - - - - - - - - + revision = 0 + urlre = re.compile('url="([^"]+)"') + revre = re.compile('committed-rev="(\d+)"') + for base,dirs,files in os.walk(os.curdir): + if '.svn' not in dirs: + dirs[:] = [] + continue # no sense walking uncontrolled subdirs + dirs.remove('.svn') + f = open(os.path.join(base,'.svn','entries')) + data = f.read() + f.close() + dirurl = urlre.search(data).group(1) # get repository URL + if base==os.curdir: + base_url = dirurl+'/' # save the root url + elif not dirurl.startswith(base_url): + dirs[:] = [] + continue # not part of the same svn tree, skip it + for match in revre.finditer(data): + revision = max(revision, int(match.group(1))) + return str(revision) def write_pkg_info(cmd, basename, filename): log.info("writing %s", filename) -- cgit v1.2.1 From 040f032a1f39038ed3209712b468c356c34a5df5 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sun, 21 Aug 2005 23:33:40 +0000 Subject: Fix problem w/bdist_rpm and setuptools, reported by Walter Doerwald. I was trying to have setuptools fix distutils' broken filename handling that assumes people haven't put punctuation in their distribution names, including '-' (which prevents unambiguous parsing of distribution names). However, bdist_rpm's attempt to guess a source distribution's filename isn't compatible with this fix, without making other changes. I decided therefore to drop the fixes for the sake of backward compatibility, but monkeypatch bdist_rpm so that it runs "egg_info" first, to ensure that any --tag-svn-revision or other tagging options take effect. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041215 --- setuptools/command/egg_info.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8bfc8d42..2c9a953e 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -60,13 +60,13 @@ class egg_info(Command): self.ensure_dirname('egg_base') self.egg_info = os.path.join(self.egg_base, self.egg_name+'.egg-info') - # Set package version and name for the benefit of dumber commands - # (e.g. sdist, bdist_wininst, etc.) We escape '-' so filenames will - # be more machine-parseable. + # Set package version for the benefit of dumber commands + # (e.g. sdist, bdist_wininst, etc.) # - metadata = self.distribution.metadata - metadata.version = self.egg_version.replace('-','_') - metadata.name = self.egg_name.replace('-','_') + self.distribution.metadata.version = self.egg_version + + + -- cgit v1.2.1 From 8312542db5a016d80d7e35951fc7991bace1368c Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 4 Nov 2005 05:38:22 +0000 Subject: Made ``egg_info --tag-svn-revision`` fall back to extracting the revision number from ``PKG-INFO`` in case it is being run on a source distribution of a snapshot taken from a Subversion-based project. That is, if a project builds an sdist with --tag-svn-revision in setup.cfg, then the built sdist will create binaries with the same version number as the checkout that was used to create the sdist. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041396 --- setuptools/command/egg_info.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 2c9a953e..c5a404e9 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -160,7 +160,7 @@ class egg_info(Command): continue # not part of the same svn tree, skip it for match in revre.finditer(data): revision = max(revision, int(match.group(1))) - return str(revision) + return str(revision or get_pkg_info_revision()) def write_pkg_info(cmd, basename, filename): log.info("writing %s", filename) @@ -226,17 +226,17 @@ def write_entries(cmd, basename, filename): cmd.write_or_delete_file('entry points', filename, data) - - - - - - - - - - - +def get_pkg_info_revision(): + # See if we can get a -r### off of PKG-INFO, in case this is an sdist of + # a subversion revision + # + if os.path.exists('PKG-INFO'): + f = open('PKG-INFO','rU') + for line in f: + match = re.match(r"Version:.*-r(\d+)\s*$", line) + if match: + return int(match.group(1)) + return 0 -- cgit v1.2.1 From f9aa7e9e50d68830954facf280a02b551357c524 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Sat, 5 Nov 2005 05:50:26 +0000 Subject: Fixed some problems with fresh checkouts of projects that don't include ``.egg-info/PKG-INFO`` under revision control and put the project's source code directly in the project directory. If such a package had any requirements that get processed before the ``egg_info`` command can be run, the setup scripts would fail with a "Missing 'Version:' header and/or PKG-INFO file" error, because the egg runtime interpreted the unbuilt metadata in a directory on ``sys.path`` (i.e. the current directory) as being a corrupted egg. Setuptools now monkeypatches the distribution metadata cache to pretend that the egg has valid version information, until it has a chance to make it actually be so (via the ``egg_info`` command). --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041401 --- setuptools/command/egg_info.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index c5a404e9..198f9635 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -7,7 +7,7 @@ import os, re from setuptools import Command from distutils.errors import * from distutils import log -from pkg_resources import parse_requirements, safe_name, \ +from pkg_resources import parse_requirements, safe_name, parse_version, \ safe_version, yield_lines, EntryPoint, iter_entry_points class egg_info(Command): @@ -65,16 +65,16 @@ class egg_info(Command): # self.distribution.metadata.version = self.egg_version - - - - - - - - - - + # If we bootstrapped around the lack of a PKG-INFO, as might be the + # case in a fresh checkout, make sure that any special tags get added + # to the version info + # + pd = self.distribution._patched_dist + if pd is not None and pd.key==self.egg_name.lower(): + pd._version = self.egg_version + pd._parsed_version = parse_version(self.egg_version) + self.distribution._patched_dist = None + -- cgit v1.2.1 From 873ebe91a8de43df836c873d9106e5af31c302e4 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 18 Nov 2005 03:13:07 +0000 Subject: Build a SOURCES.txt manifest file in .egg-info, that can then be included in sdist distributions to support building an sdist from an sdist (which the bdist_rpm command requires). This will also be the basis for enhanced package data support, that will allow optionally using the manifest to identify package data files instead of having separate manual identification of the data files. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041471 --- setuptools/command/egg_info.py | 143 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 133 insertions(+), 10 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 198f9635..2375eb96 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -7,11 +7,15 @@ import os, re from setuptools import Command from distutils.errors import * from distutils import log +from distutils.command.sdist import sdist +from distutils import file_util +from distutils.util import convert_path +from distutils.filelist import FileList from pkg_resources import parse_requirements, safe_name, parse_version, \ safe_version, yield_lines, EntryPoint, iter_entry_points +from sdist import walk_revctrl class egg_info(Command): - description = "create a distribution's .egg-info directory" user_options = [ @@ -25,7 +29,6 @@ class egg_info(Command): boolean_options = ['tag-date','tag-svn-revision'] - def initialize_options (self): self.egg_name = None self.egg_version = None @@ -36,9 +39,6 @@ class egg_info(Command): self.tag_date = 0 - - - def finalize_options (self): self.egg_name = safe_name(self.distribution.get_name()) self.egg_version = self.tagged_version() @@ -58,10 +58,12 @@ class egg_info(Command): self.egg_base = (dirs or {}).get('',os.curdir) self.ensure_dirname('egg_base') - self.egg_info = os.path.join(self.egg_base, self.egg_name+'.egg-info') + self.egg_info = self.egg_name+'.egg-info' + if self.egg_base != os.curdir: + self.egg_info = os.path.join(self.egg_base, self.egg_info) # Set package version for the benefit of dumber commands - # (e.g. sdist, bdist_wininst, etc.) + # (e.g. sdist, bdist_wininst, etc.) # self.distribution.metadata.version = self.egg_version @@ -74,8 +76,6 @@ class egg_info(Command): pd._version = self.egg_version pd._parsed_version = parse_version(self.egg_version) self.distribution._patched_dist = None - - @@ -122,12 +122,12 @@ class egg_info(Command): def run(self): - # Make the .egg-info directory, then write PKG-INFO and requires.txt self.mkpath(self.egg_info) installer = self.distribution.fetch_build_egg for ep in iter_entry_points('egg_info.writers'): writer = ep.load(installer=installer) writer(self, ep.name, os.path.join(self.egg_info,ep.name)) + self.find_sources() def tagged_version(self): version = self.distribution.get_version() @@ -161,6 +161,129 @@ class egg_info(Command): for match in revre.finditer(data): revision = max(revision, int(match.group(1))) return str(revision or get_pkg_info_revision()) + + def find_sources(self): + """Generate SOURCES.txt manifest file""" + manifest_filename = os.path.join(self.egg_info,"SOURCES.txt") + mm = manifest_maker(self.distribution) + mm.manifest = manifest_filename + mm.run() + self.filelist = mm.filelist + + +class FileList(FileList): + """File list that accepts only existing, platform-independent paths""" + + def append(self, item): + path = convert_path(item) + if os.path.exists(path): + self.files.append(path) + + + + + + + + + + + + + + + + + + + + + + + + + +class manifest_maker(sdist): + + template = "MANIFEST.in" + + def initialize_options (self): + self.use_defaults = 1 + self.prune = 1 + self.manifest_only = 1 + self.force_manifest = 1 + + def finalize_options(self): + pass + + def run(self): + self.filelist = FileList() + self.filelist.findall() + self.add_defaults() + if os.path.exists(self.template): + self.read_template() + self.prune_file_list() + self.filelist.sort() + self.filelist.remove_duplicates() + self.write_manifest() + + def write_manifest (self): + """Write the file list in 'self.filelist' (presumably as filled in + by 'add_defaults()' and 'read_template()') to the manifest file + named by 'self.manifest'. + """ + files = self.filelist.files + if os.sep!='/': + files = [f.replace(os.sep,'/') for f in files] + self.execute(file_util.write_file, (self.manifest, files), + "writing manifest file '%s'" % self.manifest) + + + + + + + + def add_defaults(self): + sdist.add_defaults(self) + self.filelist.extend([self.template,self.manifest]) + rcfiles = list(walk_revctrl()) + if rcfiles: + self.filelist.extend(rcfiles) + elif os.path.exists(self.manifest): + self.read_manifest() + ei_cmd = self.get_finalized_command('egg_info') + self.filelist.include_pattern("*", prefix=ei_cmd.egg_info) + + def prune_file_list (self): + build = self.get_finalized_command('build') + base_dir = self.distribution.get_fullname() + self.filelist.exclude_pattern(None, prefix=build.build_base) + self.filelist.exclude_pattern(None, prefix=base_dir) + self.filelist.exclude_pattern(os.sep+'\(RCS|CVS|\.svn)', is_regex=1) + + + + + + + + + + + + + + + + + + + + + + + def write_pkg_info(cmd, basename, filename): log.info("writing %s", filename) -- 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/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 2375eb96..3f17c041 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -246,7 +246,8 @@ class manifest_maker(sdist): def add_defaults(self): sdist.add_defaults(self) - self.filelist.extend([self.template,self.manifest]) + self.filelist.append(self.template) + self.filelist.append(self.manifest) rcfiles = list(walk_revctrl()) if rcfiles: self.filelist.extend(rcfiles) @@ -280,7 +281,6 @@ class manifest_maker(sdist): - -- cgit v1.2.1 From fdf5cd175d701b095bff23faedc5f6c1d4c131d8 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 18 Nov 2005 11:29:50 +0000 Subject: Fixed ``--tag-svn-revision`` not working when run from a source distribution. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041474 --- setuptools/command/egg_info.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 3f17c041..a245002e 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -133,11 +133,11 @@ class egg_info(Command): version = self.distribution.get_version() if self.tag_build: version+=self.tag_build - if self.tag_svn_revision and os.path.exists('.svn'): - version += '-r%s' % self.get_svn_revision() + if self.tag_svn_revision and ( + os.path.exists('.svn') or os.path.exists('PKG-INFO') + ): version += '-r%s' % self.get_svn_revision() if self.tag_date: - import time - version += time.strftime("-%Y%m%d") + import time; version += time.strftime("-%Y%m%d") return safe_version(version) def get_svn_revision(self): -- cgit v1.2.1 From 94c96c8c6583470e19fd2202ab2d70cc47f7a24c Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 18 Nov 2005 13:15:33 +0000 Subject: Fix .svn exclude pattern for non-Windows platforms. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041475 --- setuptools/command/egg_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a245002e..2879d5da 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -261,7 +261,8 @@ class manifest_maker(sdist): base_dir = self.distribution.get_fullname() self.filelist.exclude_pattern(None, prefix=build.build_base) self.filelist.exclude_pattern(None, prefix=base_dir) - self.filelist.exclude_pattern(os.sep+'\(RCS|CVS|\.svn)', is_regex=1) + sep = re.escape(os.sep) + self.filelist.exclude_pattern(sep+r'(RCS|CVS|\.svn)'+sep, is_regex=1) -- cgit v1.2.1 From 207ddcbad2db42f7f94099ab501ab46351e56f4d Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 14 Dec 2005 20:49:36 +0000 Subject: Basic roundtripping support between bdist_wininst and eggs. EasyInstall will now recognize when a bdist_wininst .exe wraps a .egg-info style package, and reconstitute it correctly, maintaining the original zip safety flag, if applicable. This still needs support for entrypoint scripts, though, as does the install_scripts command. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041678 --- setuptools/command/egg_info.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 2879d5da..1c5ed53a 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -282,7 +282,6 @@ class manifest_maker(sdist): - @@ -299,6 +298,9 @@ def write_pkg_info(cmd, basename, filename): finally: metadata.name, metadata.version = oldname, oldver + safe = getattr(cmd.distribution,'zip_safe',None) + import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) + def warn_depends_obsolete(cmd, basename, filename): if os.path.exists(filename): log.warn( @@ -324,9 +326,6 @@ def write_toplevel_names(cmd, basename, filename): - - - def write_arg(cmd, basename, filename): argname = os.path.splitext(basename)[0] value = getattr(cmd.distribution, argname, None) -- cgit v1.2.1 From 839a5f3185aa83187c66a2f190f3daab36803a5f Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 30 Dec 2005 16:11:35 +0000 Subject: Fix unescaped '-' in .egg-info directory names. Note that this means you must rename any existing .egg-info directory inside a project that has a '-' in it! --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041856 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 1c5ed53a..9d39b79b 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -58,7 +58,7 @@ class egg_info(Command): self.egg_base = (dirs or {}).get('',os.curdir) self.ensure_dirname('egg_base') - self.egg_info = self.egg_name+'.egg-info' + self.egg_info = self.egg_name.replace('-','_')+'.egg-info' if self.egg_base != os.curdir: self.egg_info = os.path.join(self.egg_base, self.egg_info) -- cgit v1.2.1 From def626a4f5aa9c03da1fc2418fcad8055687f4b1 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 30 Dec 2005 16:35:42 +0000 Subject: Allow most commands to work with an existing .egg-info directory w/a '-' in it, but warn about it and refuse to run "develop" until the existing directory is renamed. This should allow older source distributions and checkouts to keep working with 0.6a9. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041857 --- setuptools/command/egg_info.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9d39b79b..e5f95d4f 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -37,7 +37,7 @@ class egg_info(Command): self.tag_build = None self.tag_svn_revision = 0 self.tag_date = 0 - + self.broken_egg_info = False def finalize_options (self): self.egg_name = safe_name(self.distribution.get_name()) @@ -61,6 +61,7 @@ class egg_info(Command): self.egg_info = self.egg_name.replace('-','_')+'.egg-info' if self.egg_base != os.curdir: self.egg_info = os.path.join(self.egg_base, self.egg_info) + if '-' in self.egg_name: self.check_broken_egg_info() # Set package version for the benefit of dumber commands # (e.g. sdist, bdist_wininst, etc.) @@ -79,7 +80,6 @@ class egg_info(Command): - def write_or_delete_file(self, what, filename, data): """Write `data` to `filename` or delete if empty @@ -170,6 +170,20 @@ class egg_info(Command): mm.run() self.filelist = mm.filelist + def check_broken_egg_info(self): + bei = self.egg_name+'.egg-info' + if self.egg_base != os.curdir: + bei = os.path.join(self.egg_base, bei) + if os.path.exists(bei): + log.warn( + "-"*78+'\n' + "Note: Your current .egg-info directory has a '-' in its name;" + '\nthis will not work correctly with "setup.py develop".\n\n' + 'Please rename %s to %s to correct this problem.\n'+'-'*78, + bei, self.egg_info + ) + self.broken_egg_info = self.egg_info + self.egg_info = bei # make it work for now class FileList(FileList): """File list that accepts only existing, platform-independent paths""" @@ -185,19 +199,6 @@ class FileList(FileList): - - - - - - - - - - - - - @@ -206,7 +207,7 @@ class FileList(FileList): class manifest_maker(sdist): template = "MANIFEST.in" - + def initialize_options (self): self.use_defaults = 1 self.prune = 1 @@ -300,7 +301,7 @@ def write_pkg_info(cmd, basename, filename): safe = getattr(cmd.distribution,'zip_safe',None) import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) - + def warn_depends_obsolete(cmd, basename, filename): if os.path.exists(filename): log.warn( -- cgit v1.2.1 From abed75c8f1a0b6a449b5411caf3d9581fabae3df Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Tue, 10 Jan 2006 04:00:54 +0000 Subject: EasyInstall can now download bare ``.py`` files and wrap them in an egg, as long as you include an ``#egg=name-version`` suffix on the URL, or if the ``.py`` file is listed as the "Download URL" on the project's PyPI page. This allows third parties to "package" trivial Python modules just by linking to them (e.g. from within their own PyPI page or download links page). --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4041995 --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index e5f95d4f..ec09209a 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -12,7 +12,7 @@ from distutils import file_util from distutils.util import convert_path from distutils.filelist import FileList from pkg_resources import parse_requirements, safe_name, parse_version, \ - safe_version, yield_lines, EntryPoint, iter_entry_points + safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename from sdist import walk_revctrl class egg_info(Command): @@ -58,7 +58,7 @@ class egg_info(Command): self.egg_base = (dirs or {}).get('',os.curdir) self.ensure_dirname('egg_base') - self.egg_info = self.egg_name.replace('-','_')+'.egg-info' + self.egg_info = to_filename(self.egg_name)+'.egg-info' if self.egg_base != os.curdir: self.egg_info = os.path.join(self.egg_base, self.egg_info) if '-' in self.egg_name: self.check_broken_egg_info() -- 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/egg_info.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index ec09209a..b73d42ee 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -7,7 +7,7 @@ import os, re from setuptools import Command from distutils.errors import * from distutils import log -from distutils.command.sdist import sdist +from setuptools.command.sdist import sdist from distutils import file_util from distutils.util import convert_path from distutils.filelist import FileList @@ -203,7 +203,6 @@ class FileList(FileList): - class manifest_maker(sdist): template = "MANIFEST.in" -- cgit v1.2.1 From d5eb0afd436989651a9f28de4a3521e456df3b15 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Fri, 24 Mar 2006 17:34:52 +0000 Subject: Ensure SOURCES.txt references itself even the first time it is generated (i.e., when it didn't exist prior to egg_info being run). --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4043295 --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index b73d42ee..15d8ae19 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -218,6 +218,8 @@ class manifest_maker(sdist): def run(self): self.filelist = FileList() + if not os.path.exists(self.manifest): + self.write_manifest() # it must exist so it'll get in the list self.filelist.findall() self.add_defaults() if os.path.exists(self.template): @@ -242,8 +244,6 @@ class manifest_maker(sdist): - - def add_defaults(self): sdist.add_defaults(self) self.filelist.append(self.template) -- cgit v1.2.1 From 4da195dc370305433ac4f448c647af8d9fa3691d Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 29 Mar 2006 19:23:55 +0000 Subject: Implement dependency_links feature, courtesy of Tres Seaver's rough draft of a patch. --HG-- branch : setuptools extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4043423 --- setuptools/command/egg_info.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 15d8ae19..d9fcd3f0 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -80,19 +80,19 @@ class egg_info(Command): - def write_or_delete_file(self, what, filename, data): + def write_or_delete_file(self, what, filename, data, force=False): """Write `data` to `filename` or delete if empty If `data` is non-empty, this routine is the same as ``write_file()``. If `data` is empty but not ``None``, this is the same as calling ``delete_file(filename)`. If `data` is ``None``, then this is a no-op unless `filename` exists, in which case a warning is issued about the - orphaned file. + orphaned file (if `force` is false), or deleted (if `force` is true). """ if data: self.write_file(what, filename, data) elif os.path.exists(filename): - if data is None: + if data is None and not force: log.warn( "%s not set in setup(), but %s exists", what, filename ) @@ -326,12 +326,15 @@ def write_toplevel_names(cmd, basename, filename): -def write_arg(cmd, basename, filename): +def overwrite_arg(cmd, basename, filename): + write_arg(cmd, basename, filename, True) + +def write_arg(cmd, basename, filename, force=False): argname = os.path.splitext(basename)[0] value = getattr(cmd.distribution, argname, None) if value is not None: value = '\n'.join(value)+'\n' - cmd.write_or_delete_file(argname, filename, value) + cmd.write_or_delete_file(argname, filename, value, force) def write_entries(cmd, basename, filename): ep = cmd.distribution.entry_points @@ -347,7 +350,7 @@ def write_entries(cmd, basename, filename): data.append('[%s]\n%s\n\n' % (section,contents)) data = ''.join(data) - cmd.write_or_delete_file('entry points', filename, data) + cmd.write_or_delete_file('entry points', filename, data, True) def get_pkg_info_revision(): # See if we can get a -r### off of PKG-INFO, in case this is an sdist of @@ -364,6 +367,3 @@ def get_pkg_info_revision(): - - - -- cgit v1.2.1 From ec2e4eaa16bd6a1ca4e9f142a82b5b29701dd6e3 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Mon, 10 Jul 2006 20:47:59 +0000 Subject: Added ``--no-date`` and ``--no-svn-revision`` options to ``egg_info`` command, to allow suppressing tags configured in ``setup.cfg``. (backports from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4050539 --- setuptools/command/egg_info.py | 45 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index d9fcd3f0..8c2eb763 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -25,9 +25,19 @@ class egg_info(Command): "Add subversion revision ID to version number"), ('tag-date', 'd', "Add date stamp (e.g. 20050528) to version number"), ('tag-build=', 'b', "Specify explicit tag to add to version number"), + ('no-svn-revision', 'R', + "Don't add subversion revision ID [default]"), + ('no-date', 'D', "Don't include date stamp [default]"), + ('tag-build=', 'b', "Specify explicit tag to add to version number"), ] - boolean_options = ['tag-date','tag-svn-revision'] + boolean_options = ['tag-date', 'tag-svn-revision'] + negative_opt = {'no-svn-revision': 'tag-svn-revision', + 'no-date': 'tag-date'} + + + + def initialize_options (self): self.egg_name = None @@ -39,6 +49,37 @@ class egg_info(Command): self.tag_date = 0 self.broken_egg_info = False + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + def finalize_options (self): self.egg_name = safe_name(self.distribution.get_name()) self.egg_version = self.tagged_version() @@ -366,4 +407,4 @@ def get_pkg_info_revision(): - +# -- 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/egg_info.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8c2eb763..39b05866 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -281,9 +281,9 @@ class manifest_maker(sdist): self.execute(file_util.write_file, (self.manifest, files), "writing manifest file '%s'" % self.manifest) - - - + def warn(self, msg): # suppress missing-file warnings from sdist + if not msg.startswith("standard file not found:"): + sdist.warn(self, msg) def add_defaults(self): sdist.add_defaults(self) -- cgit v1.2.1 From d9cf1dca48e1ad0e14c06a89ab92ffd3dc9e9df8 Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Tue, 11 Jul 2006 19:51:23 +0000 Subject: Fix doubled --tag-build help display (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4050593 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 39b05866..f8e78e96 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -28,7 +28,6 @@ class egg_info(Command): ('no-svn-revision', 'R', "Don't add subversion revision ID [default]"), ('no-date', 'D', "Don't include date stamp [default]"), - ('tag-build=', 'b', "Specify explicit tag to add to version number"), ] boolean_options = ['tag-date', 'tag-svn-revision'] @@ -39,6 +38,7 @@ class egg_info(Command): + def initialize_options (self): self.egg_name = None self.egg_version = None -- 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/egg_info.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index f8e78e96..e1203b9f 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -39,7 +39,7 @@ class egg_info(Command): - def initialize_options (self): + def initialize_options(self): self.egg_name = None self.egg_version = None self.egg_base = None @@ -48,16 +48,16 @@ class egg_info(Command): self.tag_svn_revision = 0 self.tag_date = 0 self.broken_egg_info = False - - - - - - - - - - + self.vtags = None + + def save_version_info(self, filename): + from setopt import edit_config + edit_config( + filename, + {'egg_info': + {'tag_svn_revision':0, 'tag_date': 0, 'tag_build': self.tags()} + } + ) @@ -82,6 +82,7 @@ class egg_info(Command): def finalize_options (self): self.egg_name = safe_name(self.distribution.get_name()) + self.vtags = self.tags() self.egg_version = self.tagged_version() try: @@ -120,7 +121,6 @@ class egg_info(Command): self.distribution._patched_dist = None - def write_or_delete_file(self, what, filename, data, force=False): """Write `data` to `filename` or delete if empty @@ -159,8 +159,8 @@ class egg_info(Command): if not self.dry_run: os.unlink(filename) - - + def tagged_version(self): + return safe_version(self.distribution.get_version() + self.vtags) def run(self): self.mkpath(self.egg_info) @@ -170,8 +170,8 @@ class egg_info(Command): writer(self, ep.name, os.path.join(self.egg_info,ep.name)) self.find_sources() - def tagged_version(self): - version = self.distribution.get_version() + def tags(self): + version = '' if self.tag_build: version+=self.tag_build if self.tag_svn_revision and ( @@ -179,7 +179,7 @@ class egg_info(Command): ): version += '-r%s' % self.get_svn_revision() if self.tag_date: import time; version += time.strftime("-%Y%m%d") - return safe_version(version) + return version def get_svn_revision(self): revision = 0 -- 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/egg_info.py | 47 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index e1203b9f..eb7aeae2 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -181,10 +181,33 @@ class egg_info(Command): import time; version += time.strftime("-%Y%m%d") return version + + + + + + + + + + + + + + + + + + + + + + def get_svn_revision(self): revision = 0 urlre = re.compile('url="([^"]+)"') revre = re.compile('committed-rev="(\d+)"') + for base,dirs,files in os.walk(os.curdir): if '.svn' not in dirs: dirs[:] = [] @@ -193,16 +216,34 @@ class egg_info(Command): f = open(os.path.join(base,'.svn','entries')) data = f.read() f.close() - dirurl = urlre.search(data).group(1) # get repository URL + + if data.startswith('8'): + data = map(str.splitlines,data.split('\n\x0c\n')) + del data[0][0] # get rid of the '8' + dirurl = data[0][3] + localrev = max([int(d[9]) for d in data if len(d)>9]) + elif data.startswith(' Date: Tue, 26 Sep 2006 16:21:25 +0000 Subject: Handle empty revision numbers in SVN 1.4 "entries" format (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4052007 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index eb7aeae2..1223385f 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -221,7 +221,7 @@ class egg_info(Command): data = map(str.splitlines,data.split('\n\x0c\n')) del data[0][0] # get rid of the '8' dirurl = data[0][3] - localrev = max([int(d[9]) for d in data if len(d)>9]) + localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]) elif data.startswith(' 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/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 1223385f..eae7312e 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -226,8 +226,7 @@ class egg_info(Command): dirurl = urlre.search(data).group(1) # get repository URL localrev = max([int(m.group(1)) for m in revre.finditer(data)]) else: - from warnings import warn - warn("unrecognized .svn/entries format; skipping "+base) + log.warn("unrecognized .svn/entries format; skipping %s", base) dirs[:] = [] continue if base==os.curdir: @@ -244,6 +243,7 @@ class egg_info(Command): + def find_sources(self): """Generate SOURCES.txt manifest file""" manifest_filename = os.path.join(self.egg_info,"SOURCES.txt") -- cgit v1.2.1 From 74aaaf1c55d624b3424a435928b4ab310784a57c Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Wed, 11 Jul 2007 17:37:17 +0000 Subject: Fix distutils.filelist.findall() crashing on broken symlinks. Fix egg_info failures on new, uncommitted SVN directories. --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4056277 --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index eae7312e..f89dab7c 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -221,10 +221,10 @@ class egg_info(Command): data = map(str.splitlines,data.split('\n\x0c\n')) del data[0][0] # get rid of the '8' dirurl = data[0][3] - localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]) + localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0]) elif data.startswith(' Date: Wed, 26 Sep 2007 17:07:52 +0000 Subject: Fixed a missing files problem when using Windows source distributions on non-Windows platforms, due to distutils not handling manifest file line endings correctly. (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4058259 --- setuptools/command/egg_info.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index f89dab7c..290f0cdc 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -8,7 +8,6 @@ from setuptools import Command from distutils.errors import * from distutils import log from setuptools.command.sdist import sdist -from distutils import file_util from distutils.util import convert_path from distutils.filelist import FileList from pkg_resources import parse_requirements, safe_name, parse_version, \ @@ -39,6 +38,7 @@ class egg_info(Command): + def initialize_options(self): self.egg_name = None self.egg_version = None @@ -271,6 +271,8 @@ class FileList(FileList): """File list that accepts only existing, platform-independent paths""" def append(self, item): + if item.endswith('\r'): # Fix older sdists built on Windows + item = item[:-1] path = convert_path(item) if os.path.exists(path): self.files.append(path) @@ -283,8 +285,6 @@ class FileList(FileList): - - class manifest_maker(sdist): template = "MANIFEST.in" @@ -319,7 +319,7 @@ class manifest_maker(sdist): files = self.filelist.files if os.sep!='/': files = [f.replace(os.sep,'/') for f in files] - self.execute(file_util.write_file, (self.manifest, files), + self.execute(write_file, (self.manifest, files), "writing manifest file '%s'" % self.manifest) def warn(self, msg): # suppress missing-file warnings from sdist @@ -347,13 +347,13 @@ class manifest_maker(sdist): self.filelist.exclude_pattern(sep+r'(RCS|CVS|\.svn)'+sep, is_regex=1) - - - - - - - +def write_file (filename, contents): + """Create a file with the specified name and write 'contents' (a + sequence of strings without line terminators) to it. + """ + f = open(filename, "wb") # always write POSIX-style manifest + f.write("\n".join(contents)) + f.close() -- cgit v1.2.1 From b3ba9a6a83610ca0f85be171061d9f2f4a871cbb Mon Sep 17 00:00:00 2001 From: PJ Eby Date: Thu, 24 Jul 2008 21:17:31 +0000 Subject: Backport egg_info SVN fix from trunk --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4065223 --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 290f0cdc..4e135d33 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -217,9 +217,9 @@ class egg_info(Command): data = f.read() f.close() - if data.startswith('8'): + if data.startswith('9') or data.startswith('8'): data = map(str.splitlines,data.split('\n\x0c\n')) - del data[0][0] # get rid of the '8' + del data[0][0] # get rid of the '8' or '9' dirurl = data[0][3] localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0]) elif data.startswith(' Date: Thu, 21 Aug 2008 19:20:10 +0000 Subject: Fix for http://bugs.python.org/setuptools/issue9 (backport from trunk) --HG-- branch : setuptools-0.6 extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/branches/setuptools-0.6%4065955 --- setuptools/command/egg_info.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 4e135d33..9741e26a 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -168,6 +168,12 @@ class egg_info(Command): for ep in iter_entry_points('egg_info.writers'): writer = ep.load(installer=installer) writer(self, ep.name, os.path.join(self.egg_info,ep.name)) + + # Get rid of native_libs.txt if it was put there by older bdist_egg + nl = os.path.join(self.egg_info, "native_libs.txt") + if os.path.exists(nl): + self.delete_file(nl) + self.find_sources() def tags(self): @@ -194,12 +200,6 @@ class egg_info(Command): - - - - - - -- 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/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9741e26a..b14a78b0 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -217,9 +217,9 @@ class egg_info(Command): data = f.read() f.close() - if data.startswith('9') or data.startswith('8'): + if data.startswith('10') or data.startswith('9') or data.startswith('8'): data = map(str.splitlines,data.split('\n\x0c\n')) - del data[0][0] # get rid of the '8' or '9' + del data[0][0] # get rid of the '8' or '9' or '10' dirurl = data[0][3] localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0]) elif data.startswith(' Date: Thu, 16 Jul 2009 16:57:09 +0200 Subject: Apply patch from pjenvey. Closes #3. --HG-- branch : distribute extra : rebase_source : 3a61d0692c74559b140c179dcc5f4ac4905bb982 --- setuptools/command/egg_info.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index b14a78b0..a8315d23 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -444,6 +444,7 @@ def get_pkg_info_revision(): match = re.match(r"Version:.*-r(\d+)\s*$", line) if match: return int(match.group(1)) + f.close() return 0 -- cgit v1.2.1 From 0fb87f9bdf3dd85bc4a0e2f17f2a7c98d0d0cf53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Sat, 12 Sep 2009 12:38:35 +0200 Subject: Explicitly encode data as UTF-8 before writing to a binary file. --HG-- branch : distribute extra : rebase_source : c9de4f92e3e50dd88fd1d29e2a9b2f3288fd4b88 --- setuptools/command/egg_info.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a8315d23..46cdf4e0 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -3,7 +3,7 @@ Create a distribution's .egg-info directory and contents""" # This module should be kept compatible with Python 2.3 -import os, re +import os, re, sys from setuptools import Command from distutils.errors import * from distutils import log @@ -148,6 +148,8 @@ class egg_info(Command): to the file. """ log.info("writing %s to %s", what, filename) + if sys.version_info >= (3,): + data = data.encode("utf-8") if not self.dry_run: f = open(filename, 'wb') f.write(data) @@ -351,8 +353,11 @@ def write_file (filename, contents): """Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it. """ + contents = "\n".join(contents) + if sys.version_info >= (3,): + contents = contents.encode("utf-8") f = open(filename, "wb") # always write POSIX-style manifest - f.write("\n".join(contents)) + f.write(contents) f.close() -- 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/egg_info.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 46cdf4e0..9ccbe68f 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -8,11 +8,12 @@ from setuptools import Command from distutils.errors import * from distutils import log from setuptools.command.sdist import sdist +from setuptools.compat import basestring from distutils.util import convert_path from distutils.filelist import FileList from pkg_resources import parse_requirements, safe_name, parse_version, \ safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename -from sdist import walk_revctrl +from setuptools.command.sdist import walk_revctrl class egg_info(Command): description = "create a distribution's .egg-info directory" @@ -51,7 +52,7 @@ class egg_info(Command): self.vtags = None def save_version_info(self, filename): - from setopt import edit_config + from setuptools.command.setopt import edit_config edit_config( filename, {'egg_info': @@ -220,7 +221,7 @@ class egg_info(Command): f.close() if data.startswith('10') or data.startswith('9') or data.startswith('8'): - data = map(str.splitlines,data.split('\n\x0c\n')) + data = list(map(str.splitlines,data.split('\n\x0c\n'))) del data[0][0] # get rid of the '8' or '9' or '10' dirurl = data[0][3] localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0]) @@ -386,7 +387,8 @@ def write_pkg_info(cmd, basename, filename): metadata.name, metadata.version = oldname, oldver safe = getattr(cmd.distribution,'zip_safe',None) - import bdist_egg; bdist_egg.write_safety_flag(cmd.egg_info, safe) + from setuptools.command import bdist_egg + bdist_egg.write_safety_flag(cmd.egg_info, safe) def warn_depends_obsolete(cmd, basename, filename): if os.path.exists(filename): -- cgit v1.2.1 From 6851d4e38e1e4e5a2bbbf2556523fd19675cdbf7 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 19:48:19 +0200 Subject: Make sure the manifest never contains decomposed UTF-8. --HG-- branch : distribute extra : rebase_source : 0e0fb3beac56f66f12670ec69ebfd3996d12d912 --- setuptools/command/egg_info.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 46cdf4e0..e932d46a 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -287,6 +287,19 @@ class FileList(FileList): +def compose(path): + # Apple's HFS Plus returns decomposed UTF-8. Since just about + # everyone else chokes on it, we must make sure to return fully + # composed UTF-8 only. + if sys.getfilesystemencoding().lower() == 'utf-8': + from unicodedata import normalize + if sys.version_info >= (3,): + path = normalize('NFC', path) + else: + path = normalize('NFC', path.decode('utf-8')).encode('utf-8') + return path + + class manifest_maker(sdist): template = "MANIFEST.in" @@ -311,6 +324,7 @@ class manifest_maker(sdist): self.prune_file_list() self.filelist.sort() self.filelist.remove_duplicates() + self.filelist.files = [compose(path) for path in self.filelist.files] self.write_manifest() def write_manifest (self): -- cgit v1.2.1 From 907d9f46c3e0ef8dbc55528da9efe5087c182c9f Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 21:06:52 +0200 Subject: Fix duplicate application of version tags in 'egg_info' command. Fixes #299. --HG-- branch : distribute extra : rebase_source : 9f6fb87944bc3b9828b04bf8ac5ba7b3a40bfc95 --- setuptools/command/egg_info.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index e932d46a..2dc59187 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -162,7 +162,12 @@ class egg_info(Command): os.unlink(filename) def tagged_version(self): - return safe_version(self.distribution.get_version() + self.vtags) + version = self.distribution.get_version() + # egg_info may be called more than once for a distribution, + # in which case the version string already contains all tags. + if self.vtags and version.endswith(self.vtags): + return safe_version(version) + return safe_version(version + self.vtags) def run(self): self.mkpath(self.egg_info) -- cgit v1.2.1 From 21ead63de1689b99007d0ab9b41a19b09543e7b3 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 15 Oct 2012 14:48:49 +0200 Subject: Revert 86d7748 drive-by commit because of unclear BBB consequences. --HG-- branch : distribute extra : rebase_source : 2fb9a6ec09184e238551be4d0ea908e719badd27 --- setuptools/command/egg_info.py | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 2dc59187..e1a8c9ad 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -292,19 +292,6 @@ class FileList(FileList): -def compose(path): - # Apple's HFS Plus returns decomposed UTF-8. Since just about - # everyone else chokes on it, we must make sure to return fully - # composed UTF-8 only. - if sys.getfilesystemencoding().lower() == 'utf-8': - from unicodedata import normalize - if sys.version_info >= (3,): - path = normalize('NFC', path) - else: - path = normalize('NFC', path.decode('utf-8')).encode('utf-8') - return path - - class manifest_maker(sdist): template = "MANIFEST.in" @@ -329,7 +316,6 @@ class manifest_maker(sdist): self.prune_file_list() self.filelist.sort() self.filelist.remove_duplicates() - self.filelist.files = [compose(path) for path in self.filelist.files] self.write_manifest() def write_manifest (self): -- cgit v1.2.1 From 422682d8c44fb310e3431d56b2ee0a991ced72db Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Tue, 16 Oct 2012 13:08:55 +0200 Subject: Don't re-use FileList global name in egg_info.py. --HG-- branch : distribute extra : rebase_source : ac180d4a23ab4fc03c243aa92dd8e6bc42bdabeb --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index e1a8c9ad..e1aaa491 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -9,7 +9,7 @@ from distutils.errors import * from distutils import log from setuptools.command.sdist import sdist from distutils.util import convert_path -from distutils.filelist import FileList +from distutils.filelist import FileList as _FileList from pkg_resources import parse_requirements, safe_name, parse_version, \ safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename from sdist import walk_revctrl @@ -274,7 +274,7 @@ class egg_info(Command): self.broken_egg_info = self.egg_info self.egg_info = bei # make it work for now -class FileList(FileList): +class FileList(_FileList): """File list that accepts only existing, platform-independent paths""" def append(self, item): -- 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/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index e1aaa491..9955c8ef 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -360,7 +360,7 @@ def write_file (filename, contents): """ contents = "\n".join(contents) if sys.version_info >= (3,): - contents = contents.encode("utf-8") + contents = contents.encode("utf-8", "surrogateescape") f = open(filename, "wb") # always write POSIX-style manifest f.write(contents) f.close() -- 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/egg_info.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9955c8ef..6e3d67af 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -323,6 +323,18 @@ class manifest_maker(sdist): by 'add_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'. """ + # The manifest must be UTF-8 encodable. See #303. + if sys.version_info >= (3,): + files = [] + for file in self.filelist.files: + try: + file.encode("utf-8") + except UnicodeEncodeError: + log.warn("'%s' not UTF-8 encodable -- skipping" % file) + else: + files.append(file) + self.filelist.files = files + files = self.filelist.files if os.sep!='/': files = [f.replace(os.sep,'/') for f in files] @@ -360,7 +372,7 @@ def write_file (filename, contents): """ contents = "\n".join(contents) if sys.version_info >= (3,): - contents = contents.encode("utf-8", "surrogateescape") + contents = contents.encode("utf-8") f = open(filename, "wb") # always write POSIX-style manifest f.write(contents) f.close() -- cgit v1.2.1 From 19a723890b724f92b8c42b162cea2a4052a746f2 Mon Sep 17 00:00:00 2001 From: "stefan@epy" Date: Mon, 5 Nov 2012 01:35:25 +0100 Subject: Warn if filenames cannot be added to the filelist. --HG-- branch : distribute extra : rebase_source : 9fdc3c28b097e191db384cd81319c7a4edccf52b --- setuptools/command/egg_info.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 6e3d67af..cf6ef63c 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -281,8 +281,14 @@ class FileList(_FileList): if item.endswith('\r'): # Fix older sdists built on Windows item = item[:-1] path = convert_path(item) - if os.path.exists(path): - self.files.append(path) + try: + if os.path.exists(path): + self.files.append(path) + else: + log.warn("%r not found -- skipping", path) + except UnicodeEncodeError: + log.warn("%r not %s encodable -- skipping", path, + sys.getfilesystemencoding()) -- cgit v1.2.1 From 924d4355aeacd172c32ce6a894f3c141bc363991 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 5 Nov 2012 11:44:41 +0100 Subject: Don't warn about a missing MANIFEST.in. --HG-- branch : distribute extra : rebase_source : 219c8a4e10da4a319a736c728d162528220d36e1 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index cf6ef63c..098dfe84 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -284,7 +284,7 @@ class FileList(_FileList): try: if os.path.exists(path): self.files.append(path) - else: + elif path != manifest_maker.template: log.warn("%r not found -- skipping", path) except UnicodeEncodeError: log.warn("%r not %s encodable -- skipping", path, -- cgit v1.2.1 From e69eb1098a650ba05b6ef998d8a118cbc10365a7 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Sat, 10 Nov 2012 02:05:17 +0100 Subject: Never skip because of encoding in append. --HG-- branch : distribute extra : rebase_source : 89414e7f828ed2ca2b7118dfd5e17c72ccc44f5b --- setuptools/command/egg_info.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 098dfe84..ad02cec8 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -281,14 +281,15 @@ class FileList(_FileList): if item.endswith('\r'): # Fix older sdists built on Windows item = item[:-1] path = convert_path(item) + # Filter unused template files all of which have ASCII names try: + if sys.version_info >= (3,): + path.encode('ascii') + except UnicodeEncodeError: + self.files.append(path) + else: if os.path.exists(path): self.files.append(path) - elif path != manifest_maker.template: - log.warn("%r not found -- skipping", path) - except UnicodeEncodeError: - log.warn("%r not %s encodable -- skipping", path, - sys.getfilesystemencoding()) -- cgit v1.2.1 From 057a7d98522cfb5fbee1c183b9922c919fb782b9 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Sat, 10 Nov 2012 14:18:53 +0100 Subject: Revert yesterday's misguided attempt at being smart. --HG-- branch : distribute extra : rebase_source : 224fb95e8c8ad385a35187c49a102259e03e89a6 --- setuptools/command/egg_info.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index ad02cec8..098dfe84 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -281,15 +281,14 @@ class FileList(_FileList): if item.endswith('\r'): # Fix older sdists built on Windows item = item[:-1] path = convert_path(item) - # Filter unused template files all of which have ASCII names try: - if sys.version_info >= (3,): - path.encode('ascii') - except UnicodeEncodeError: - self.files.append(path) - else: if os.path.exists(path): self.files.append(path) + elif path != manifest_maker.template: + log.warn("%r not found -- skipping", path) + except UnicodeEncodeError: + log.warn("%r not %s encodable -- skipping", path, + sys.getfilesystemencoding()) -- cgit v1.2.1 From 98c3a5e71e558a80dafce9b5bb7baf8da9da7ec6 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Sat, 10 Nov 2012 14:47:30 +0100 Subject: Log file not found message at debug level. --HG-- branch : distribute extra : rebase_source : 2c3afe957adc1b3c83f1dfba3d30adf7b0d7b3f3 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 098dfe84..8b29e672 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -285,7 +285,7 @@ class FileList(_FileList): if os.path.exists(path): self.files.append(path) elif path != manifest_maker.template: - log.warn("%r not found -- skipping", path) + log.debug("%r not found -- skipping", path) except UnicodeEncodeError: log.warn("%r not %s encodable -- skipping", path, sys.getfilesystemencoding()) -- cgit v1.2.1 From b7c5bd34a32f20e54100fd88ede20c136571b1cf Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Sat, 10 Nov 2012 17:22:59 +0100 Subject: Windows can store UTF-8 bytes as is. --HG-- branch : distribute extra : rebase_source : 99e089901a7dac003a53d53e85b0c08480c86e27 --- setuptools/command/egg_info.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8b29e672..9695627b 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -281,15 +281,19 @@ class FileList(_FileList): if item.endswith('\r'): # Fix older sdists built on Windows item = item[:-1] path = convert_path(item) - try: + if sys.version_info >= (3,): + try: + if os.path.exists(path): + self.files.append(path) + elif sys.platform == 'win32': + if os.path.exists(path.encode('utf-8')): + self.files.append(path) + except UnicodeEncodeError: + log.warn("%r not %s encodable -- skipping", path, + sys.getfilesystemencoding()) + else: if os.path.exists(path): self.files.append(path) - elif path != manifest_maker.template: - log.debug("%r not found -- skipping", path) - except UnicodeEncodeError: - log.warn("%r not %s encodable -- skipping", path, - sys.getfilesystemencoding()) - -- 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/egg_info.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9695627b..d37ba900 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -286,6 +286,7 @@ class FileList(_FileList): if os.path.exists(path): self.files.append(path) elif sys.platform == 'win32': + # NTFS can store UTF-8 filenames as is if os.path.exists(path.encode('utf-8')): self.files.append(path) except UnicodeEncodeError: -- cgit v1.2.1 From be8173d7f6e5e971c5f028d5049d932cf5043efb Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Sat, 10 Nov 2012 22:14:57 +0100 Subject: Accept UTF-8 filenames into the filelist even if LANG=C. --HG-- branch : distribute extra : rebase_source : 499443a97846396e5790d80af32050f57f4aa43d --- setuptools/command/egg_info.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index d37ba900..085a499b 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -281,17 +281,18 @@ class FileList(_FileList): if item.endswith('\r'): # Fix older sdists built on Windows item = item[:-1] path = convert_path(item) + if sys.version_info >= (3,): try: - if os.path.exists(path): + if os.path.exists(path) or os.path.exists(path.encode('utf-8')): self.files.append(path) - elif sys.platform == 'win32': - # NTFS can store UTF-8 filenames as is - if os.path.exists(path.encode('utf-8')): - self.files.append(path) except UnicodeEncodeError: - log.warn("%r not %s encodable -- skipping", path, - sys.getfilesystemencoding()) + # Support UTF-8 filenames even if LANG=C + if os.path.exists(path.encode('utf-8')): + self.files.append(path) + else: + log.warn("%r not %s encodable -- skipping", path, + sys.getfilesystemencoding()) else: if os.path.exists(path): self.files.append(path) -- cgit v1.2.1 From cdb51001a8302e2948a42c68654550be1e2f941d Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 12 Nov 2012 22:56:15 +0100 Subject: No need for repr as path is always str. --HG-- branch : distribute extra : rebase_source : 6784f7ac37d43a341bb8b2466fbf68a082af2bee --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 085a499b..6145d6ea 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -291,7 +291,7 @@ class FileList(_FileList): if os.path.exists(path.encode('utf-8')): self.files.append(path) else: - log.warn("%r not %s encodable -- skipping", path, + log.warn("'%s' not %s encodable -- skipping", path, sys.getfilesystemencoding()) else: if os.path.exists(path): -- cgit v1.2.1 From 12599860ec654a39179704ce02323718c987114c Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Tue, 13 Nov 2012 14:01:29 +0100 Subject: Don't claim support for LANG=C. --HG-- branch : distribute extra : rebase_source : a366e936bfbce0c92831114e92a9d2c015841b5d --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 6145d6ea..0c2ea0cc 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -287,7 +287,7 @@ class FileList(_FileList): if os.path.exists(path) or os.path.exists(path.encode('utf-8')): self.files.append(path) except UnicodeEncodeError: - # Support UTF-8 filenames even if LANG=C + # Accept UTF-8 filenames even if LANG=C if os.path.exists(path.encode('utf-8')): self.files.append(path) else: -- 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/egg_info.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9741e26a..5a8b2db8 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -217,18 +217,21 @@ class egg_info(Command): data = f.read() f.close() - if data.startswith('9') or data.startswith('8'): + if data.startswith('9 and d[9]]+[0]) - elif data.startswith(' Date: Wed, 19 Jun 2013 08:38:55 -0500 Subject: Add test capturing failure on Python 3 in egg_info.get_svn_revision (#20). egg_info.get_svn_revision is now a staticmethod. --- setuptools/command/egg_info.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index cd3ea198..5863d2d4 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -210,7 +210,8 @@ class egg_info(Command): - def get_svn_revision(self): + @staticmethod + def get_svn_revision(): revision = 0 urlre = re.compile('url="([^"]+)"') revre = re.compile('committed-rev="(\d+)"') @@ -234,7 +235,7 @@ class egg_info(Command): log.warn("unrecognized .svn/entries format; skipping %s", base) dirs[:] = [] continue - + data = map(str.splitlines,data.split('\n\x0c\n')) del data[0][0] # get rid of the '8' or '9' or '10' dirurl = data[0][3] -- cgit v1.2.1 From e2b6f95a403f2152dacba8229ea8b91aecc3328e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 19 Jun 2013 08:47:43 -0500 Subject: Reference parsed svn version variable instead of the whole of the data. Fixes #20 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 5863d2d4..b283b28a 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -231,7 +231,7 @@ class egg_info(Command): else: try: svnver = int(data.splitlines()[0]) except: svnver=-1 - if data<8: + if svnver<8: log.warn("unrecognized .svn/entries format; skipping %s", base) dirs[:] = [] continue -- cgit v1.2.1 From d26d42296c45c25703e7c1fb76bf78fc5aa8347e Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Fri, 28 Jun 2013 21:55:47 -0500 Subject: Quick addition to get past svn test in another package. --HG-- extra : rebase_source : a36601a66f574d7c0919b7c885dcae7b820bb7dd --- setuptools/command/egg_info.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 642687b2..7daaee0f 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -15,6 +15,9 @@ from pkg_resources import parse_requirements, safe_name, parse_version, \ safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename from setuptools.command.sdist import walk_revctrl +#requires python >= 2.4 +from subprocess import Popen as _Popen, PIPE as _PIPE + class egg_info(Command): description = "create a distribution's .egg-info directory" @@ -216,6 +219,8 @@ class egg_info(Command): revision = 0 urlre = re.compile('url="([^"]+)"') revre = re.compile('committed-rev="(\d+)"') + urlre11 = re.compile('([^<>]+)') + revre11 = re.compile(']*revision="(\d+)"') for base,dirs,files in os.walk(os.curdir): if '.svn' not in dirs: @@ -236,11 +241,17 @@ class egg_info(Command): log.warn("unrecognized .svn/entries format; skipping %s", base) dirs[:] = [] continue + elif svnver > 10: + p = _Popen(['svn', 'info', '--xml'], stdout=_PIPE, shell=(sys.platform=='win32')) + data = unicode(p.communicate()[0], encoding='utf-8') + dirurl = urlre11.search(data).group(1) + localrev = max([int(m.group(1)) for m in revre11.finditer(data)]+[0]) + else: + data = list(map(str.splitlines,data.split('\n\x0c\n'))) + del data[0][0] # get rid of the '8' or '9' or '10' + dirurl = data[0][3] + localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0]) - data = list(map(str.splitlines,data.split('\n\x0c\n'))) - del data[0][0] # get rid of the '8' or '9' or '10' - dirurl = data[0][3] - localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0]) if base==os.curdir: base_url = dirurl+'/' # save the root url elif not dirurl.startswith(base_url): @@ -253,6 +264,8 @@ class egg_info(Command): + + def find_sources(self): """Generate SOURCES.txt manifest file""" manifest_filename = os.path.join(self.egg_info,"SOURCES.txt") -- cgit v1.2.1 From 8d389a37b8237d9dfb3f2b92baf79acda9c5b3f1 Mon Sep 17 00:00:00 2001 From: Philip Thiem 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/egg_info.py | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 7daaee0f..7ed50d73 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -9,6 +9,7 @@ from distutils.errors import * from distutils import log from setuptools.command.sdist import sdist from setuptools.compat import basestring +from setuptools import svn_util from distutils.util import convert_path from distutils.filelist import FileList as _FileList from pkg_resources import parse_requirements, safe_name, parse_version, \ @@ -217,40 +218,21 @@ class egg_info(Command): @staticmethod def get_svn_revision(): revision = 0 - urlre = re.compile('url="([^"]+)"') - revre = re.compile('committed-rev="(\d+)"') - urlre11 = re.compile('([^<>]+)') - revre11 = re.compile(']*revision="(\d+)"') for base,dirs,files in os.walk(os.curdir): if '.svn' not in dirs: dirs[:] = [] continue # no sense walking uncontrolled subdirs dirs.remove('.svn') - f = open(os.path.join(base,'.svn','entries')) - data = f.read() - f.close() - if data.startswith(' 10: - p = _Popen(['svn', 'info', '--xml'], stdout=_PIPE, shell=(sys.platform=='win32')) - data = unicode(p.communicate()[0], encoding='utf-8') - dirurl = urlre11.search(data).group(1) - localrev = max([int(m.group(1)) for m in revre11.finditer(data)]+[0]) - else: - data = list(map(str.splitlines,data.split('\n\x0c\n'))) - del data[0][0] # get rid of the '8' or '9' or '10' - dirurl = data[0][3] - localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0]) + enteries = svn_util.SVNEntries.load(base) + if not entries.is_valid: + log.warn(" get_svn_revision: Cannot determine how to read enteries.") + dirs[:] = [] + continue + + localrev = entries.parse_revsion() + dirurl = entries.get_url() if base==os.curdir: base_url = dirurl+'/' # save the root url -- cgit v1.2.1 From 05fbc85a834bbd43850e736ffbe3b081f4fc4a26 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Sun, 30 Jun 2013 19:03:56 -0500 Subject: minor naming issues in egg_info.py --HG-- extra : rebase_source : d5877c7a9fe537d567d557bbcc7e89a596fa3c87 --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 7ed50d73..43321119 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -9,7 +9,7 @@ from distutils.errors import * from distutils import log from setuptools.command.sdist import sdist from setuptools.compat import basestring -from setuptools import svn_util +from setuptools import svn_utils from distutils.util import convert_path from distutils.filelist import FileList as _FileList from pkg_resources import parse_requirements, safe_name, parse_version, \ @@ -225,7 +225,7 @@ class egg_info(Command): continue # no sense walking uncontrolled subdirs dirs.remove('.svn') - enteries = svn_util.SVNEntries.load(base) + entries = svn_utils.SVNEntries.load_dir(base) if not entries.is_valid: log.warn(" get_svn_revision: Cannot determine how to read enteries.") dirs[:] = [] -- cgit v1.2.1 From c7bd44256ce9f77a54e22561405b06690a805e94 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Sun, 30 Jun 2013 21:11:35 -0500 Subject: Finished some 1.7 tests, and updated the zip file to include the .svn dirs Several fixes to get the code to pass the tests --HG-- extra : rebase_source : 76e13888a6efc871cc254076c7e58f201af24472 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 43321119..9d30b125 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -231,7 +231,7 @@ class egg_info(Command): dirs[:] = [] continue - localrev = entries.parse_revsion() + localrev = entries.parse_revision() dirurl = entries.get_url() if base==os.curdir: -- cgit v1.2.1 From b46fff3b028fb1c0c423eddd6d53ca9f70a10bb0 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Thu, 4 Jul 2013 11:20:20 -0500 Subject: get_svn_method now direectly called svn_utils.parse_revision --HG-- extra : rebase_source : 4af53ce7fcf4d69c0d65800e57fabec7d081ce35 --- setuptools/command/egg_info.py | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9d30b125..345ec8ae 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -217,31 +217,7 @@ class egg_info(Command): @staticmethod def get_svn_revision(): - revision = 0 - - for base,dirs,files in os.walk(os.curdir): - if '.svn' not in dirs: - dirs[:] = [] - continue # no sense walking uncontrolled subdirs - dirs.remove('.svn') - - entries = svn_utils.SVNEntries.load_dir(base) - if not entries.is_valid: - log.warn(" get_svn_revision: Cannot determine how to read enteries.") - dirs[:] = [] - continue - - localrev = entries.parse_revision() - dirurl = entries.get_url() - - if base==os.curdir: - base_url = dirurl+'/' # save the root url - elif not dirurl.startswith(base_url): - dirs[:] = [] - continue # not part of the same svn tree, skip it - revision = max(revision, localrev) - - return str(revision or get_pkg_info_revision()) + return str(svn_utils.parse_revision(os.curdir)) -- cgit v1.2.1 From 5b7992850b0cddec9bc405042359cf751d970d59 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Fri, 5 Jul 2013 08:23:44 -0500 Subject: urlparse --> urllib.parse in py3 --HG-- extra : rebase_source : b845737250a36a725f75aa04109ea357f09955d0 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 345ec8ae..cb557361 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -9,7 +9,7 @@ from distutils.errors import * from distutils import log from setuptools.command.sdist import sdist from setuptools.compat import basestring -from setuptools import svn_utils +from .. import svn_utils from distutils.util import convert_path from distutils.filelist import FileList as _FileList from pkg_resources import parse_requirements, safe_name, parse_version, \ -- cgit v1.2.1 From 0c39ec94423bda77dc46dc6c82294cdfd7447f89 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Fri, 5 Jul 2013 10:37:42 -0500 Subject: fixed some issues with OSError have to emulate zipfile extract on py2.5 and earlier for tests --HG-- extra : rebase_source : c6ad4eab19a2a454b8b8043d88d9582168f617aa --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index cb557361..345ec8ae 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -9,7 +9,7 @@ from distutils.errors import * from distutils import log from setuptools.command.sdist import sdist from setuptools.compat import basestring -from .. import svn_utils +from setuptools import svn_utils from distutils.util import convert_path from distutils.filelist import FileList as _FileList from pkg_resources import parse_requirements, safe_name, parse_version, \ -- 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/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 345ec8ae..31700648 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -217,7 +217,7 @@ class egg_info(Command): @staticmethod def get_svn_revision(): - return str(svn_utils.parse_revision(os.curdir)) + return str(svn_utils.SvnInfo.load(os.curdir).get_revision()) -- cgit v1.2.1 From 8c645eb0c310e8ff4efe73849279ea391d25bced Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Sat, 20 Jul 2013 19:53:07 -0500 Subject: Removed extra stuff in egg_info --HG-- extra : rebase_source : 4b3cf921154e759744963b34aaf42018477deb29 --- setuptools/command/egg_info.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 31700648..a0ba5305 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -16,8 +16,6 @@ from pkg_resources import parse_requirements, safe_name, parse_version, \ safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename from setuptools.command.sdist import walk_revctrl -#requires python >= 2.4 -from subprocess import Popen as _Popen, PIPE as _PIPE class egg_info(Command): description = "create a distribution's .egg-info directory" -- cgit v1.2.1 From fef4d5165d47e33a2143bba3961eefeff6ca218a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 27 Nov 2013 13:46:03 -0500 Subject: Normalize whitespace, removing pyflakes warnings. --- setuptools/command/egg_info.py | 107 ++++++++--------------------------------- 1 file changed, 21 insertions(+), 86 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a0ba5305..a1ce862c 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -3,7 +3,10 @@ Create a distribution's .egg-info directory and contents""" # This module should be kept compatible with Python 2.3 -import os, re, sys +import os +import re +import sys + from setuptools import Command from distutils.errors import * from distutils import log @@ -36,12 +39,6 @@ class egg_info(Command): negative_opt = {'no-svn-revision': 'tag-svn-revision', 'no-date': 'tag-date'} - - - - - - def initialize_options(self): self.egg_name = None self.egg_version = None @@ -55,35 +52,16 @@ class egg_info(Command): def save_version_info(self, filename): from setuptools.command.setopt import edit_config - edit_config( - filename, - {'egg_info': - {'tag_svn_revision':0, 'tag_date': 0, 'tag_build': self.tags()} - } + values = dict( + egg_info=dict( + tag_svn_revision=0, + tag_date=0, + tag_build=self.tags(), + ) ) + edit_config(filename, values) - - - - - - - - - - - - - - - - - - - - - - def finalize_options (self): + def finalize_options(self): self.egg_name = safe_name(self.distribution.get_name()) self.vtags = self.tags() self.egg_version = self.tagged_version() @@ -123,7 +101,6 @@ class egg_info(Command): pd._parsed_version = parse_version(self.egg_version) self.distribution._patched_dist = None - def write_or_delete_file(self, what, filename, data, force=False): """Write `data` to `filename` or delete if empty @@ -194,34 +171,14 @@ class egg_info(Command): os.path.exists('.svn') or os.path.exists('PKG-INFO') ): version += '-r%s' % self.get_svn_revision() if self.tag_date: - import time; version += time.strftime("-%Y%m%d") + import time + version += time.strftime("-%Y%m%d") return version - - - - - - - - - - - - - - - - @staticmethod def get_svn_revision(): return str(svn_utils.SvnInfo.load(os.curdir).get_revision()) - - - - - def find_sources(self): """Generate SOURCES.txt manifest file""" manifest_filename = os.path.join(self.egg_info,"SOURCES.txt") @@ -269,17 +226,11 @@ class FileList(_FileList): self.files.append(path) - - - - - - class manifest_maker(sdist): template = "MANIFEST.in" - def initialize_options (self): + def initialize_options(self): self.use_defaults = 1 self.prune = 1 self.manifest_only = 1 @@ -301,7 +252,7 @@ class manifest_maker(sdist): self.filelist.remove_duplicates() self.write_manifest() - def write_manifest (self): + def write_manifest(self): """Write the file list in 'self.filelist' (presumably as filled in by 'add_defaults()' and 'read_template()') to the manifest file named by 'self.manifest'. @@ -340,7 +291,7 @@ class manifest_maker(sdist): ei_cmd = self.get_finalized_command('egg_info') self.filelist.include_pattern("*", prefix=ei_cmd.egg_info) - def prune_file_list (self): + def prune_file_list(self): build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() self.filelist.exclude_pattern(None, prefix=build.build_base) @@ -349,7 +300,7 @@ class manifest_maker(sdist): self.filelist.exclude_pattern(sep+r'(RCS|CVS|\.svn)'+sep, is_regex=1) -def write_file (filename, contents): +def write_file(filename, contents): """Create a file with the specified name and write 'contents' (a sequence of strings without line terminators) to it. """ @@ -360,24 +311,12 @@ def write_file (filename, contents): f.write(contents) f.close() - - - - - - - - - - - - def write_pkg_info(cmd, basename, filename): log.info("writing %s", filename) if not cmd.dry_run: metadata = cmd.distribution.metadata metadata.version, oldver = cmd.egg_version, metadata.version - metadata.name, oldname = cmd.egg_name, metadata.name + metadata.name, oldname = cmd.egg_name, metadata.name try: # write unescaped data to PKG-INFO, so older pkg_resources # can still parse it @@ -406,14 +345,14 @@ def write_requirements(cmd, basename, filename): def write_toplevel_names(cmd, basename, filename): pkgs = dict.fromkeys( - [k.split('.',1)[0] + [ + k.split('.',1)[0] for k in cmd.distribution.iter_distribution_names() ] ) cmd.write_file("top-level names", filename, '\n'.join(pkgs)+'\n') - def overwrite_arg(cmd, basename, filename): write_arg(cmd, basename, filename, True) @@ -452,7 +391,3 @@ def get_pkg_info_revision(): return int(match.group(1)) f.close() return 0 - - - -# -- cgit v1.2.1 From b436cf3d092afc3021fe1d6bd1165762b60bf643 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 27 Nov 2013 13:46:54 -0500 Subject: Remove import * --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a1ce862c..b4216129 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -8,7 +8,7 @@ import re import sys from setuptools import Command -from distutils.errors import * +import distutils.errors from distutils import log from setuptools.command.sdist import sdist from setuptools.compat import basestring @@ -71,7 +71,7 @@ class egg_info(Command): parse_requirements('%s==%s' % (self.egg_name,self.egg_version)) ) except ValueError: - raise DistutilsOptionError( + raise distutils.errors.DistutilsOptionError( "Invalid distribution name or version syntax: %s-%s" % (self.egg_name,self.egg_version) ) -- cgit v1.2.1 From a14216e2f541e8b9f2f875ffeefeb4e5495eac1e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 27 Nov 2013 13:47:29 -0500 Subject: Prefer paranthetical import to line continuation. --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index b4216129..9b7e6b42 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -15,8 +15,8 @@ from setuptools.compat import basestring from setuptools import svn_utils from distutils.util import convert_path from distutils.filelist import FileList as _FileList -from pkg_resources import parse_requirements, safe_name, parse_version, \ - safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename +from pkg_resources import (parse_requirements, safe_name, parse_version, + safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) from setuptools.command.sdist import walk_revctrl -- cgit v1.2.1 From bc47a75d4d97f34f9ad49a5142c351c74354cd41 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 27 Nov 2013 13:48:22 -0500 Subject: Remove historical comment about compatibility. --- setuptools/command/egg_info.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9b7e6b42..5953aad4 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -2,7 +2,6 @@ Create a distribution's .egg-info directory and contents""" -# This module should be kept compatible with Python 2.3 import os import re import sys -- cgit v1.2.1 From 97724357315e4ec8068cc2c80a450cd19766f875 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 16 Mar 2014 06:23:24 -0400 Subject: Sort entry points when writing so they render consistently --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 5953aad4..4f5c9694 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -369,10 +369,10 @@ def write_entries(cmd, basename, filename): data = ep elif ep is not None: data = [] - for section, contents in ep.items(): + for section, contents in sorted(ep.items()): if not isinstance(contents,basestring): contents = EntryPoint.parse_group(section, contents) - contents = '\n'.join(map(str,contents.values())) + contents = '\n'.join(sorted(map(str,contents.values()))) data.append('[%s]\n%s\n\n' % (section,contents)) data = ''.join(data) -- cgit v1.2.1 From cb2fa7e5dd86949a06dcdb3babdecc778985fd02 Mon Sep 17 00:00:00 2001 From: "yyfeng88625@gmail.com" Date: Fri, 21 Mar 2014 13:43:54 +0800 Subject: Python2.x needs encode as well. --HG-- extra : source : ab82442e2205a4ab1016711e482388590688fa15 --- setuptools/command/egg_info.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 4f5c9694..30873e19 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -304,8 +304,7 @@ def write_file(filename, contents): sequence of strings without line terminators) to it. """ contents = "\n".join(contents) - if sys.version_info >= (3,): - contents = contents.encode("utf-8") + contents = contents.encode("utf-8") f = open(filename, "wb") # always write POSIX-style manifest f.write(contents) f.close() -- cgit v1.2.1 From 5208cd6fc27e0459e251a967f432c77556d2bf40 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Wed, 16 Apr 2014 18:26:58 -0500 Subject: Applied Patch from cazabon to handle svn tag revisions --HG-- branch : develop extra : rebase_source : 571dac8142fc43b54bcd0302598766b0bb9e13ff --- setuptools/command/egg_info.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9019524d..6bb2ead9 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -168,9 +168,10 @@ class egg_info(Command): version = '' if self.tag_build: version+=self.tag_build - if self.tag_svn_revision and ( - os.path.exists('.svn') or os.path.exists('PKG-INFO') - ): version += '-r%s' % self.get_svn_revision() + if self.tag_svn_revision: + rev = self.get_svn_revision() + if rev: # is 0 if it's not an svn working copy + version += '-r%s' % rev if self.tag_date: import time version += time.strftime("-%Y%m%d") -- cgit v1.2.1 From d118aae6b768cfdf387aca862e150e7736c7cd71 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Wed, 23 Apr 2014 21:54:27 -0500 Subject: Prune paths file list starting with (RCS|CVS|.svn) as well as path with such sub directories. --HG-- branch : develop extra : rebase_source : 2b3326fe668e880b351b0d5f388472239d915d58 --- setuptools/command/egg_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 6bb2ead9..be326ac2 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -316,7 +316,8 @@ class manifest_maker(sdist): self.filelist.exclude_pattern(None, prefix=build.build_base) self.filelist.exclude_pattern(None, prefix=base_dir) sep = re.escape(os.sep) - self.filelist.exclude_pattern(sep+r'(RCS|CVS|\.svn)'+sep, is_regex=1) + self.filelist.exclude_pattern(r'(^|'+sep+r')(RCS|CVS|\.svn)'+sep, + is_regex=1) def write_file(filename, contents): -- cgit v1.2.1 From 0515f30739d1dce3bc10921db403f336358ef447 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 3 May 2014 12:58:13 -0400 Subject: Backed out changeset: b0a2fcc5275a Ref #193 --- setuptools/command/egg_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 30873e19..4f5c9694 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -304,7 +304,8 @@ def write_file(filename, contents): sequence of strings without line terminators) to it. """ contents = "\n".join(contents) - contents = contents.encode("utf-8") + if sys.version_info >= (3,): + contents = contents.encode("utf-8") f = open(filename, "wb") # always write POSIX-style manifest f.write(contents) f.close() -- cgit v1.2.1 From 16cffb5544e37d9f30ce0b5f485fefb991633d1e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 15 May 2014 23:26:19 -0400 Subject: Clean up docstring --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 4f5c9694..c9d4d82e 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -252,8 +252,8 @@ class manifest_maker(sdist): self.write_manifest() def write_manifest(self): - """Write the file list in 'self.filelist' (presumably as filled in - by 'add_defaults()' and 'read_template()') to the manifest file + """ + Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. """ # The manifest must be UTF-8 encodable. See #303. -- cgit v1.2.1 From c442269b78d994fb061afddc7a1314d96f91d487 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 15 May 2014 23:33:46 -0400 Subject: This code path doesn't make sense. If the UnicodeEncodeError occurred above, it will occur here too. --- setuptools/command/egg_info.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index c9d4d82e..ed8e458a 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -214,10 +214,6 @@ class FileList(_FileList): if os.path.exists(path) or os.path.exists(path.encode('utf-8')): self.files.append(path) except UnicodeEncodeError: - # Accept UTF-8 filenames even if LANG=C - if os.path.exists(path.encode('utf-8')): - self.files.append(path) - else: log.warn("'%s' not %s encodable -- skipping", path, sys.getfilesystemencoding()) else: -- cgit v1.2.1 From 83658a39f37a2ece19b1f7409edc11a1bdd9cce3 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 15 May 2014 23:34:00 -0400 Subject: Reindent --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index ed8e458a..f6347af9 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -214,8 +214,8 @@ class FileList(_FileList): if os.path.exists(path) or os.path.exists(path.encode('utf-8')): self.files.append(path) except UnicodeEncodeError: - log.warn("'%s' not %s encodable -- skipping", path, - sys.getfilesystemencoding()) + log.warn("'%s' not %s encodable -- skipping", path, + sys.getfilesystemencoding()) else: if os.path.exists(path): self.files.append(path) -- cgit v1.2.1 From c8c9b75cbb82654b463d3175430900f58ba951ca Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 15 May 2014 23:43:19 -0400 Subject: FileList.append already excludes files that are not UTF-8 encodable, so rely on it when building the manifest. Ref #193 --- setuptools/command/egg_info.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index f6347af9..0175bbaa 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -252,21 +252,8 @@ class manifest_maker(sdist): Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. """ - # The manifest must be UTF-8 encodable. See #303. - if sys.version_info >= (3,): - files = [] - for file in self.filelist.files: - try: - file.encode("utf-8") - except UnicodeEncodeError: - log.warn("'%s' not UTF-8 encodable -- skipping" % file) - else: - files.append(file) - self.filelist.files = files - - files = self.filelist.files if os.sep!='/': - files = [f.replace(os.sep,'/') for f in files] + files = [f.replace(os.sep,'/') for f in self.filelist.files] self.execute(write_file, (self.manifest, files), "writing manifest file '%s'" % self.manifest) -- cgit v1.2.1 From 4ba4909fe29c82db4a5db4bab2c0de2e6e0b1d10 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 16 May 2014 00:14:24 -0400 Subject: Fix failure on non-Windows systems --- setuptools/command/egg_info.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 0175bbaa..ad3f4c17 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -252,8 +252,7 @@ class manifest_maker(sdist): Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. """ - if os.sep!='/': - files = [f.replace(os.sep,'/') for f in self.filelist.files] + files = [f.replace(os.sep, '/') for f in self.filelist.files] self.execute(write_file, (self.manifest, files), "writing manifest file '%s'" % self.manifest) -- cgit v1.2.1 From 592c525ea6ae94f6d5434e25f6db1bb8f8ff73c5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 16 May 2014 00:15:06 -0400 Subject: Reindent --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index ad3f4c17..00a50d0b 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -253,8 +253,8 @@ class manifest_maker(sdist): named by 'self.manifest'. """ files = [f.replace(os.sep, '/') for f in self.filelist.files] - self.execute(write_file, (self.manifest, files), - "writing manifest file '%s'" % self.manifest) + msg = "writing manifest file '%s'" % self.manifest + self.execute(write_file, (self.manifest, files), msg) def warn(self, msg): # suppress missing-file warnings from sdist if not msg.startswith("standard file not found:"): -- cgit v1.2.1 From fb2038bb99b46b8ec92ad046b79d21c182e718a4 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 16 May 2014 00:28:45 -0400 Subject: Extract _safe_path --- setuptools/command/egg_info.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 00a50d0b..88027dd0 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -209,17 +209,20 @@ class FileList(_FileList): item = item[:-1] path = convert_path(item) + if self._safe_path(path): + self.files.append(path) + + def _safe_path(self, path): if sys.version_info >= (3,): try: if os.path.exists(path) or os.path.exists(path.encode('utf-8')): - self.files.append(path) + return True except UnicodeEncodeError: log.warn("'%s' not %s encodable -- skipping", path, sys.getfilesystemencoding()) else: if os.path.exists(path): - self.files.append(path) - + return True class manifest_maker(sdist): -- cgit v1.2.1 From a35ca3bb2f7e025270a7b305c133b57f917e0ef2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 16 May 2014 00:29:36 -0400 Subject: Use compat for Python 3 detection --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 88027dd0..50c2096a 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -10,7 +10,7 @@ from setuptools import Command import distutils.errors from distutils import log from setuptools.command.sdist import sdist -from setuptools.compat import basestring +from setuptools.compat import basestring, PY3 from setuptools import svn_utils from distutils.util import convert_path from distutils.filelist import FileList as _FileList @@ -213,7 +213,7 @@ class FileList(_FileList): self.files.append(path) def _safe_path(self, path): - if sys.version_info >= (3,): + if PY3: try: if os.path.exists(path) or os.path.exists(path.encode('utf-8')): return True -- cgit v1.2.1 From 9d5d875b2ba0414eeef36aa135621cb214abe463 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 16 May 2014 00:33:29 -0400 Subject: Move Python 3 code to the body of the function --- setuptools/command/egg_info.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 50c2096a..bb832ea6 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -213,16 +213,15 @@ class FileList(_FileList): self.files.append(path) def _safe_path(self, path): - if PY3: - try: - if os.path.exists(path) or os.path.exists(path.encode('utf-8')): - return True - except UnicodeEncodeError: - log.warn("'%s' not %s encodable -- skipping", path, - sys.getfilesystemencoding()) - else: - if os.path.exists(path): + if not PY3: + return os.path.exists(path) + + try: + if os.path.exists(path) or os.path.exists(path.encode('utf-8')): return True + except UnicodeEncodeError: + log.warn("'%s' not %s encodable -- skipping", path, + sys.getfilesystemencoding()) class manifest_maker(sdist): -- cgit v1.2.1 From afa18c94fe1ae79db2542af2cc056e31998400d6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 16 May 2014 00:35:56 -0400 Subject: Also override extend to check paths for safety. --- setuptools/command/egg_info.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index bb832ea6..a2f4d444 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -212,6 +212,9 @@ class FileList(_FileList): if self._safe_path(path): self.files.append(path) + def extend(self, paths): + self.files.extend(filter(self._safe_path, paths)) + def _safe_path(self, path): if not PY3: return os.path.exists(path) -- cgit v1.2.1 From 98252c9624c564444307544bf77c7aa3828aa024 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 16 May 2014 09:05:37 -0400 Subject: Add a _repair method to repair the FileList after unsafe entries have been added. --- setuptools/command/egg_info.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a2f4d444..2097f2a9 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -215,6 +215,16 @@ class FileList(_FileList): def extend(self, paths): self.files.extend(filter(self._safe_path, paths)) + def _repair(self): + """ + Replace self.files with only safe paths + + Because some owners of FileList manipulate the underlying + ``files`` attribute directly, this method must be called to + repair those paths. + """ + self.files = list(filter(self._safe_path, self.files)) + def _safe_path(self, path): if not PY3: return os.path.exists(path) @@ -257,6 +267,8 @@ class manifest_maker(sdist): Write the file list in 'self.filelist' to the manifest file named by 'self.manifest'. """ + self.filelist._repair() + files = [f.replace(os.sep, '/') for f in self.filelist.files] msg = "writing manifest file '%s'" % self.manifest self.execute(write_file, (self.manifest, files), msg) -- cgit v1.2.1 From 60a42fcd2ae461bac7bbe93af92a9d7e0d13b746 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Sat, 17 May 2014 02:40:07 -0500 Subject: with_statements and output utf-8 output *Since py2.5 has been dropped, we can use future imports to make use of with statements. *End goal was to always decode to utf-8 in write_file on 307 --HG-- extra : rebase_source : 502ea7128f4e3b843b16c6d64d6d0b2ac56ce87d --- setuptools/command/egg_info.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 2097f2a9..1eca04ad 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -1,6 +1,7 @@ """setuptools.command.egg_info Create a distribution's .egg-info directory and contents""" +from __future__ import with_statement import os import re @@ -10,7 +11,7 @@ from setuptools import Command import distutils.errors from distutils import log from setuptools.command.sdist import sdist -from setuptools.compat import basestring, PY3 +from setuptools.compat import basestring, PY3, unicode from setuptools import svn_utils from distutils.util import convert_path from distutils.filelist import FileList as _FileList @@ -303,11 +304,13 @@ def write_file(filename, contents): sequence of strings without line terminators) to it. """ contents = "\n".join(contents) - if sys.version_info >= (3,): - contents = contents.encode("utf-8") - f = open(filename, "wb") # always write POSIX-style manifest - f.write(contents) - f.close() + + #assuming the contents has been vetted for utf-8 encoding + contents = contents.encode("utf-8") + + with open(filename, "wb") as f: # always write POSIX-style manifest + f.write(contents) + def write_pkg_info(cmd, basename, filename): log.info("writing %s", filename) -- cgit v1.2.1 From cade48d7d2751fe69d81957963f0a12d1606c9f6 Mon Sep 17 00:00:00 2001 From: Philip Thiem Date: Sat, 17 May 2014 04:15:55 -0500 Subject: In corporate the old unicode with the spirit of what the FileList updating. --HG-- extra : source : 199c917b8a0be209144878872269c3bd08936d6a --- setuptools/command/egg_info.py | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 1eca04ad..33fe147e 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -18,6 +18,7 @@ from distutils.filelist import FileList as _FileList from pkg_resources import (parse_requirements, safe_name, parse_version, safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) from setuptools.command.sdist import walk_revctrl +import setuptools.unicode_utils as unicode_utils class egg_info(Command): @@ -227,15 +228,28 @@ class FileList(_FileList): self.files = list(filter(self._safe_path, self.files)) def _safe_path(self, path): - if not PY3: - return os.path.exists(path) + enc_warn = "'%s' not %s encodable -- skipping" + + #To avoid accidental trans-codings errors, first to unicode + u_path = unicode_utils.filesys_decode(path) + if u_path is None: + log.warn("'%s' in unexpected encoding -- skipping" % path) + return False + + #Must ensure utf-8 encodability + utf8_path = unicode_utils.try_encode(u_path, "utf-8") + if utf8_path is None: + log.warn(enc_warn, path, 'utf-8') + return False try: - if os.path.exists(path) or os.path.exists(path.encode('utf-8')): + #accept is either way checks out + if os.path.exists(u_path) or os.path.exists(utf8_path): return True + #this will catch any encode errors decoding u_path except UnicodeEncodeError: - log.warn("'%s' not %s encodable -- skipping", path, - sys.getfilesystemencoding()) + log.warn(enc_warn, path, sys.getfilesystemencoding()) + class manifest_maker(sdist): @@ -263,6 +277,10 @@ class manifest_maker(sdist): self.filelist.remove_duplicates() self.write_manifest() + def _manifest_normalize(self, path): + path = unicode_utils.filesys_decode(path) + return path.replace(os.sep, '/') + def write_manifest(self): """ Write the file list in 'self.filelist' to the manifest file @@ -270,7 +288,8 @@ class manifest_maker(sdist): """ self.filelist._repair() - files = [f.replace(os.sep, '/') for f in self.filelist.files] + #Now _repairs should encodability, but not unicode + files = [self._manifest_normalize(f) for f in self.filelist.files] msg = "writing manifest file '%s'" % self.manifest self.execute(write_file, (self.manifest, files), msg) -- cgit v1.2.1 From 3d6068d5f67f044b2e37711b6275d58915e41895 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 17 May 2014 12:09:26 -0400 Subject: with_statement is available naturally in Python 2.6 --- setuptools/command/egg_info.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 33fe147e..22501c44 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -1,7 +1,6 @@ """setuptools.command.egg_info Create a distribution's .egg-info directory and contents""" -from __future__ import with_statement import os import re @@ -238,7 +237,7 @@ class FileList(_FileList): #Must ensure utf-8 encodability utf8_path = unicode_utils.try_encode(u_path, "utf-8") - if utf8_path is None: + if utf8_path is None: log.warn(enc_warn, path, 'utf-8') return False @@ -326,7 +325,7 @@ def write_file(filename, contents): #assuming the contents has been vetted for utf-8 encoding contents = contents.encode("utf-8") - + with open(filename, "wb") as f: # always write POSIX-style manifest f.write(contents) -- 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/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 22501c44..646f9460 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -128,7 +128,7 @@ class egg_info(Command): to the file. """ log.info("writing %s to %s", what, filename) - if sys.version_info >= (3,): + if PY3: data = data.encode("utf-8") if not self.dry_run: f = open(filename, 'wb') -- cgit v1.2.1 From 60beb22b4ca7e7d4f549c7137c7a20a633d72916 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 17 May 2014 18:58:29 -0400 Subject: Extract variable --- setuptools/command/egg_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 646f9460..169fcd3e 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -358,7 +358,8 @@ def warn_depends_obsolete(cmd, basename, filename): def write_requirements(cmd, basename, filename): dist = cmd.distribution data = ['\n'.join(yield_lines(dist.install_requires or ()))] - for extra,reqs in (dist.extras_require or {}).items(): + extras_require = dist.extras_require or {} + for extra,reqs in extras_require.items(): data.append('\n\n[%s]\n%s' % (extra, '\n'.join(yield_lines(reqs)))) cmd.write_or_delete_file("requirements", filename, ''.join(data)) -- cgit v1.2.1 From 380e609d0d788edbdc5808f6d58c6c730a78cb3a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 17 May 2014 19:02:55 -0400 Subject: Write requirements in a deterministic order. --- setuptools/command/egg_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 169fcd3e..38a01fbf 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -359,7 +359,8 @@ def write_requirements(cmd, basename, filename): dist = cmd.distribution data = ['\n'.join(yield_lines(dist.install_requires or ()))] extras_require = dist.extras_require or {} - for extra,reqs in extras_require.items(): + for extra in sorted(extras_require): + reqs = extras_require[extra] data.append('\n\n[%s]\n%s' % (extra, '\n'.join(yield_lines(reqs)))) cmd.write_or_delete_file("requirements", filename, ''.join(data)) -- cgit v1.2.1 From faae7b49cab317203b07d4a418ee7b68c7afb48e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 17 May 2014 19:14:29 -0400 Subject: Use StringIO to write out requirements. Use more common convention of adding newline to each line of the file, not just intervening lines. --- setuptools/command/egg_info.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 38a01fbf..470ba466 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -5,6 +5,7 @@ Create a distribution's .egg-info directory and contents""" import os import re import sys +import io from setuptools import Command import distutils.errors @@ -355,14 +356,21 @@ def warn_depends_obsolete(cmd, basename, filename): ) +def _write_requirements(stream, reqs): + lines = yield_lines(reqs or ()) + append_cr = lambda line: line + '\n' + lines = map(append_cr, lines) + stream.writelines(lines) + def write_requirements(cmd, basename, filename): dist = cmd.distribution - data = ['\n'.join(yield_lines(dist.install_requires or ()))] + data = io.StringIO() + _write_requirements(data, dist.install_requires) extras_require = dist.extras_require or {} for extra in sorted(extras_require): - reqs = extras_require[extra] - data.append('\n\n[%s]\n%s' % (extra, '\n'.join(yield_lines(reqs)))) - cmd.write_or_delete_file("requirements", filename, ''.join(data)) + data.write('\n[{extra}]\n'.format(**vars())) + _write_requirements(data, extras_require[extra]) + cmd.write_or_delete_file("requirements", filename, data.getvalue()) def write_toplevel_names(cmd, basename, filename): pkgs = dict.fromkeys( -- cgit v1.2.1 From 95ca77339cdcd24fc1193b701c979e5f6fa72335 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 17 May 2014 19:26:30 -0400 Subject: Restore Python 2 compatibility. --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 470ba466..9019524d 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -364,7 +364,7 @@ def _write_requirements(stream, reqs): def write_requirements(cmd, basename, filename): dist = cmd.distribution - data = io.StringIO() + data = io.StringIO() if PY3 else io.BytesIO() _write_requirements(data, dist.install_requires) extras_require = dist.extras_require or {} for extra in sorted(extras_require): -- cgit v1.2.1 From 18c255d1e1a83d45a055cfcc0fa3140c775afc0d Mon Sep 17 00:00:00 2001 From: Matthew Iversen Date: Mon, 2 Jun 2014 22:26:36 +1000 Subject: Use compat's StringIO. Should fix bitbucket #213 https://bitbucket.org/pypa/setuptools/issue/213/regression-setuptools-37-installation --HG-- extra : source : 182f68beacf5e436609fb7d1064a18279cbbd24a --- setuptools/command/egg_info.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9019524d..04ed6357 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -5,13 +5,12 @@ Create a distribution's .egg-info directory and contents""" import os import re import sys -import io from setuptools import Command import distutils.errors from distutils import log from setuptools.command.sdist import sdist -from setuptools.compat import basestring, PY3, unicode +from setuptools.compat import basestring, PY3, StringIO from setuptools import svn_utils from distutils.util import convert_path from distutils.filelist import FileList as _FileList @@ -364,7 +363,7 @@ def _write_requirements(stream, reqs): def write_requirements(cmd, basename, filename): dist = cmd.distribution - data = io.StringIO() if PY3 else io.BytesIO() + data = StringIO() _write_requirements(data, dist.install_requires) extras_require = dist.extras_require or {} for extra in sorted(extras_require): -- 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/egg_info.py | 100 +++++++++++++++++++++++------------------ 1 file changed, 57 insertions(+), 43 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 04ed6357..981c7ab7 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -2,21 +2,22 @@ Create a distribution's .egg-info directory and contents""" +from distutils.filelist import FileList as _FileList +from distutils.util import convert_path +from distutils import log +import distutils.errors import os import re import sys from setuptools import Command -import distutils.errors -from distutils import log from setuptools.command.sdist import sdist from setuptools.compat import basestring, PY3, StringIO from setuptools import svn_utils -from distutils.util import convert_path -from distutils.filelist import FileList as _FileList -from pkg_resources import (parse_requirements, safe_name, parse_version, - safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) from setuptools.command.sdist import walk_revctrl +from pkg_resources import ( + parse_requirements, safe_name, parse_version, + safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) import setuptools.unicode_utils as unicode_utils @@ -27,11 +28,11 @@ class egg_info(Command): ('egg-base=', 'e', "directory containing .egg-info directories" " (default: top of the source tree)"), ('tag-svn-revision', 'r', - "Add subversion revision ID to version number"), + "Add subversion revision ID to version number"), ('tag-date', 'd', "Add date stamp (e.g. 20050528) to version number"), ('tag-build=', 'b', "Specify explicit tag to add to version number"), ('no-svn-revision', 'R', - "Don't add subversion revision ID [default]"), + "Don't add subversion revision ID [default]"), ('no-date', 'D', "Don't include date stamp [default]"), ] @@ -52,6 +53,7 @@ class egg_info(Command): def save_version_info(self, filename): from setuptools.command.setopt import edit_config + values = dict( egg_info=dict( tag_svn_revision=0, @@ -68,23 +70,25 @@ class egg_info(Command): try: list( - parse_requirements('%s==%s' % (self.egg_name,self.egg_version)) + parse_requirements('%s==%s' % (self.egg_name, + self.egg_version)) ) except ValueError: raise distutils.errors.DistutilsOptionError( "Invalid distribution name or version syntax: %s-%s" % - (self.egg_name,self.egg_version) + (self.egg_name, self.egg_version) ) if self.egg_base is None: dirs = self.distribution.package_dir - self.egg_base = (dirs or {}).get('',os.curdir) + self.egg_base = (dirs or {}).get('', os.curdir) self.ensure_dirname('egg_base') - self.egg_info = to_filename(self.egg_name)+'.egg-info' + self.egg_info = to_filename(self.egg_name) + '.egg-info' if self.egg_base != os.curdir: self.egg_info = os.path.join(self.egg_base, self.egg_info) - if '-' in self.egg_name: self.check_broken_egg_info() + if '-' in self.egg_name: + self.check_broken_egg_info() # Set package version for the benefit of dumber commands # (e.g. sdist, bdist_wininst, etc.) @@ -96,7 +100,7 @@ class egg_info(Command): # to the version info # pd = self.distribution._patched_dist - if pd is not None and pd.key==self.egg_name.lower(): + if pd is not None and pd.key == self.egg_name.lower(): pd._version = self.egg_version pd._parsed_version = parse_version(self.egg_version) self.distribution._patched_dist = None @@ -154,7 +158,7 @@ class egg_info(Command): installer = self.distribution.fetch_build_egg for ep in iter_entry_points('egg_info.writers'): writer = ep.load(installer=installer) - writer(self, ep.name, os.path.join(self.egg_info,ep.name)) + writer(self, ep.name, os.path.join(self.egg_info, ep.name)) # Get rid of native_libs.txt if it was put there by older bdist_egg nl = os.path.join(self.egg_info, "native_libs.txt") @@ -166,12 +170,14 @@ class egg_info(Command): def tags(self): version = '' if self.tag_build: - version+=self.tag_build + version += self.tag_build if self.tag_svn_revision and ( os.path.exists('.svn') or os.path.exists('PKG-INFO') - ): version += '-r%s' % self.get_svn_revision() + ): + version += '-r%s' % self.get_svn_revision() if self.tag_date: import time + version += time.strftime("-%Y%m%d") return version @@ -181,32 +187,33 @@ class egg_info(Command): def find_sources(self): """Generate SOURCES.txt manifest file""" - manifest_filename = os.path.join(self.egg_info,"SOURCES.txt") + manifest_filename = os.path.join(self.egg_info, "SOURCES.txt") mm = manifest_maker(self.distribution) mm.manifest = manifest_filename mm.run() self.filelist = mm.filelist def check_broken_egg_info(self): - bei = self.egg_name+'.egg-info' + bei = self.egg_name + '.egg-info' if self.egg_base != os.curdir: bei = os.path.join(self.egg_base, bei) if os.path.exists(bei): log.warn( - "-"*78+'\n' + "-" * 78 + '\n' "Note: Your current .egg-info directory has a '-' in its name;" '\nthis will not work correctly with "setup.py develop".\n\n' - 'Please rename %s to %s to correct this problem.\n'+'-'*78, + 'Please rename %s to %s to correct this problem.\n' + '-' * 78, bei, self.egg_info ) self.broken_egg_info = self.egg_info - self.egg_info = bei # make it work for now + self.egg_info = bei # make it work for now + class FileList(_FileList): """File list that accepts only existing, platform-independent paths""" def append(self, item): - if item.endswith('\r'): # Fix older sdists built on Windows + if item.endswith('\r'): # Fix older sdists built on Windows item = item[:-1] path = convert_path(item) @@ -229,29 +236,28 @@ class FileList(_FileList): def _safe_path(self, path): enc_warn = "'%s' not %s encodable -- skipping" - #To avoid accidental trans-codings errors, first to unicode + # To avoid accidental trans-codings errors, first to unicode u_path = unicode_utils.filesys_decode(path) if u_path is None: log.warn("'%s' in unexpected encoding -- skipping" % path) return False - #Must ensure utf-8 encodability + # Must ensure utf-8 encodability utf8_path = unicode_utils.try_encode(u_path, "utf-8") if utf8_path is None: log.warn(enc_warn, path, 'utf-8') return False try: - #accept is either way checks out + # accept is either way checks out if os.path.exists(u_path) or os.path.exists(utf8_path): return True - #this will catch any encode errors decoding u_path + # this will catch any encode errors decoding u_path except UnicodeEncodeError: log.warn(enc_warn, path, sys.getfilesystemencoding()) class manifest_maker(sdist): - template = "MANIFEST.in" def initialize_options(self): @@ -266,7 +272,7 @@ class manifest_maker(sdist): def run(self): self.filelist = FileList() if not os.path.exists(self.manifest): - self.write_manifest() # it must exist so it'll get in the list + self.write_manifest() # it must exist so it'll get in the list self.filelist.findall() self.add_defaults() if os.path.exists(self.template): @@ -287,12 +293,12 @@ class manifest_maker(sdist): """ self.filelist._repair() - #Now _repairs should encodability, but not unicode + # Now _repairs should encodability, but not unicode files = [self._manifest_normalize(f) for f in self.filelist.files] msg = "writing manifest file '%s'" % self.manifest self.execute(write_file, (self.manifest, files), msg) - def warn(self, msg): # suppress missing-file warnings from sdist + def warn(self, msg): # suppress missing-file warnings from sdist if not msg.startswith("standard file not found:"): sdist.warn(self, msg) @@ -314,7 +320,8 @@ class manifest_maker(sdist): self.filelist.exclude_pattern(None, prefix=build.build_base) self.filelist.exclude_pattern(None, prefix=base_dir) sep = re.escape(os.sep) - self.filelist.exclude_pattern(sep+r'(RCS|CVS|\.svn)'+sep, is_regex=1) + self.filelist.exclude_pattern(sep + r'(RCS|CVS|\.svn)' + sep, + is_regex=1) def write_file(filename, contents): @@ -323,10 +330,10 @@ def write_file(filename, contents): """ contents = "\n".join(contents) - #assuming the contents has been vetted for utf-8 encoding + # assuming the contents has been vetted for utf-8 encoding contents = contents.encode("utf-8") - with open(filename, "wb") as f: # always write POSIX-style manifest + with open(filename, "wb") as f: # always write POSIX-style manifest f.write(contents) @@ -343,10 +350,12 @@ def write_pkg_info(cmd, basename, filename): finally: metadata.name, metadata.version = oldname, oldver - safe = getattr(cmd.distribution,'zip_safe',None) + safe = getattr(cmd.distribution, 'zip_safe', None) from setuptools.command import bdist_egg + bdist_egg.write_safety_flag(cmd.egg_info, safe) + def warn_depends_obsolete(cmd, basename, filename): if os.path.exists(filename): log.warn( @@ -361,6 +370,7 @@ def _write_requirements(stream, reqs): lines = map(append_cr, lines) stream.writelines(lines) + def write_requirements(cmd, basename, filename): dist = cmd.distribution data = StringIO() @@ -371,48 +381,52 @@ def write_requirements(cmd, basename, filename): _write_requirements(data, extras_require[extra]) cmd.write_or_delete_file("requirements", filename, data.getvalue()) + def write_toplevel_names(cmd, basename, filename): pkgs = dict.fromkeys( [ - k.split('.',1)[0] + k.split('.', 1)[0] for k in cmd.distribution.iter_distribution_names() ] ) - cmd.write_file("top-level names", filename, '\n'.join(pkgs)+'\n') + cmd.write_file("top-level names", filename, '\n'.join(pkgs) + '\n') def overwrite_arg(cmd, basename, filename): write_arg(cmd, basename, filename, True) + def write_arg(cmd, basename, filename, force=False): argname = os.path.splitext(basename)[0] value = getattr(cmd.distribution, argname, None) if value is not None: - value = '\n'.join(value)+'\n' + value = '\n'.join(value) + '\n' cmd.write_or_delete_file(argname, filename, value, force) + def write_entries(cmd, basename, filename): ep = cmd.distribution.entry_points - if isinstance(ep,basestring) or ep is None: + if isinstance(ep, basestring) or ep is None: data = ep elif ep is not None: data = [] for section, contents in sorted(ep.items()): - if not isinstance(contents,basestring): + if not isinstance(contents, basestring): contents = EntryPoint.parse_group(section, contents) - contents = '\n'.join(sorted(map(str,contents.values()))) - data.append('[%s]\n%s\n\n' % (section,contents)) + contents = '\n'.join(sorted(map(str, contents.values()))) + data.append('[%s]\n%s\n\n' % (section, contents)) data = ''.join(data) cmd.write_or_delete_file('entry points', filename, data, True) + def get_pkg_info_revision(): # See if we can get a -r### off of PKG-INFO, in case this is an sdist of # a subversion revision # if os.path.exists('PKG-INFO'): - f = open('PKG-INFO','rU') + f = open('PKG-INFO', 'rU') for line in f: match = re.match(r"Version:.*-r(\d+)\s*$", line) if match: -- cgit v1.2.1 From d559b45bb0f9e3472ac62574c858f4ab29707a8e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 2 Jul 2014 08:04:52 -0400 Subject: Resave with excess whitespace removed --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a1818edc..72493d0b 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -320,7 +320,7 @@ class manifest_maker(sdist): self.filelist.exclude_pattern(None, prefix=build.build_base) self.filelist.exclude_pattern(None, prefix=base_dir) sep = re.escape(os.sep) - self.filelist.exclude_pattern(r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep, + self.filelist.exclude_pattern(r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep, is_regex=1) -- 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/egg_info.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 72493d0b..debb52e4 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -10,9 +10,10 @@ import os import re import sys +import six + from setuptools import Command from setuptools.command.sdist import sdist -from setuptools.compat import basestring, PY3, StringIO from setuptools import svn_utils from setuptools.command.sdist import walk_revctrl from pkg_resources import ( @@ -132,7 +133,7 @@ class egg_info(Command): to the file. """ log.info("writing %s to %s", what, filename) - if PY3: + if six.PY3: data = data.encode("utf-8") if not self.dry_run: f = open(filename, 'wb') @@ -373,7 +374,7 @@ def _write_requirements(stream, reqs): def write_requirements(cmd, basename, filename): dist = cmd.distribution - data = StringIO() + data = six.StringIO() _write_requirements(data, dist.install_requires) extras_require = dist.extras_require or {} for extra in sorted(extras_require): @@ -407,12 +408,12 @@ def write_arg(cmd, basename, filename, force=False): def write_entries(cmd, basename, filename): ep = cmd.distribution.entry_points - if isinstance(ep, basestring) or ep is None: + if isinstance(ep, six.string_types) or ep is None: data = ep elif ep is not None: data = [] for section, contents in sorted(ep.items()): - if not isinstance(contents, basestring): + if not isinstance(contents, six.string_types): contents = EntryPoint.parse_group(section, contents) contents = '\n'.join(sorted(map(str, contents.values()))) data.append('[%s]\n%s\n\n' % (section, contents)) -- cgit v1.2.1 From ac14ffe92376c54bb2d5a443e5177d85faeda75d Mon Sep 17 00:00:00 2001 From: Benedikt Morbach Date: Thu, 7 Aug 2014 17:57:00 +0200 Subject: make order of lines in top_level.txt deterministic like it was done for requirements and entry_points --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 72493d0b..1ef723da 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -389,7 +389,7 @@ def write_toplevel_names(cmd, basename, filename): for k in cmd.distribution.iter_distribution_names() ] ) - cmd.write_file("top-level names", filename, '\n'.join(pkgs) + '\n') + cmd.write_file("top-level names", filename, '\n'.join(sorted(pkgs) + '\n') def overwrite_arg(cmd, basename, filename): -- cgit v1.2.1 From 7702536f882a3e03cea35bb3066069793351f1ce Mon Sep 17 00:00:00 2001 From: Hugues Lerebours Date: Mon, 18 Aug 2014 14:11:34 +0200 Subject: [Fix/Typo] Fix missing parenthesis in egg_info.py Syntax error introduced in be37eff86c761a399c1ec98b0e5eeed9a90c9cd7 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 1ef723da..06764a17 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -389,7 +389,7 @@ def write_toplevel_names(cmd, basename, filename): for k in cmd.distribution.iter_distribution_names() ] ) - cmd.write_file("top-level names", filename, '\n'.join(sorted(pkgs) + '\n') + cmd.write_file("top-level names", filename, '\n'.join(sorted(pkgs)) + '\n') def overwrite_arg(cmd, basename, filename): -- cgit v1.2.1 From f8844d7508fd6fe81b161b14320b2dcd8ec88315 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 21 Aug 2014 09:48:06 -0400 Subject: Backed out changeset: be37eff86c76 Syntax was invalid. --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 1ef723da..72493d0b 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -389,7 +389,7 @@ def write_toplevel_names(cmd, basename, filename): for k in cmd.distribution.iter_distribution_names() ] ) - cmd.write_file("top-level names", filename, '\n'.join(sorted(pkgs) + '\n') + cmd.write_file("top-level names", filename, '\n'.join(pkgs) + '\n') def overwrite_arg(cmd, basename, filename): -- cgit v1.2.1 From 9382fa0c05e533400613e1c7c0a777cabb463390 Mon Sep 17 00:00:00 2001 From: Donald Stufft Date: Thu, 4 Sep 2014 21:04:06 -0400 Subject: Implement PEP 440 by using the packaging library --- setuptools/command/egg_info.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 72493d0b..cb67255b 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -15,6 +15,7 @@ from setuptools.command.sdist import sdist from setuptools.compat import basestring, PY3, StringIO from setuptools import svn_utils from setuptools.command.sdist import walk_revctrl +from setuptools._vendor.packaging.version import Version from pkg_resources import ( parse_requirements, safe_name, parse_version, safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) @@ -68,9 +69,14 @@ class egg_info(Command): self.vtags = self.tags() self.egg_version = self.tagged_version() + parsed_version = parse_version(self.egg_version) + try: + spec = ( + "%s==%s" if isinstance(parsed_version, Version) else "%s===%s" + ) list( - parse_requirements('%s==%s' % (self.egg_name, + parse_requirements(spec % (self.egg_name, self.egg_version)) ) except ValueError: -- cgit v1.2.1 From a9541756f6a12c91704feffec4ddfee859f12c30 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 27 Sep 2014 16:10:17 -0400 Subject: Fix indent --- setuptools/command/egg_info.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9ba719fe..de43bf0c 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -76,8 +76,7 @@ class egg_info(Command): "%s==%s" if isinstance(parsed_version, Version) else "%s===%s" ) list( - parse_requirements(spec % (self.egg_name, - self.egg_version)) + parse_requirements(spec % (self.egg_name, self.egg_version)) ) except ValueError: raise distutils.errors.DistutilsOptionError( -- cgit v1.2.1 From 7d9c21a893431798ba77edd62b5490ff4ce47ecf Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 27 Sep 2014 16:13:48 -0400 Subject: Prefer packaging library if available. --- setuptools/command/egg_info.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index de43bf0c..43df87dc 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -10,12 +10,18 @@ import os import re import sys +try: + import packaging.version +except ImportError: + # fallback to vendored version + import setuptools._vendor.packaging.version + packaging = setuptools._vendor.packaging + from setuptools import Command from setuptools.command.sdist import sdist from setuptools.compat import basestring, PY3, StringIO from setuptools import svn_utils from setuptools.command.sdist import walk_revctrl -from setuptools._vendor.packaging.version import Version from pkg_resources import ( parse_requirements, safe_name, parse_version, safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) @@ -72,8 +78,9 @@ class egg_info(Command): parsed_version = parse_version(self.egg_version) try: + is_version = isinstance(parsed_version, packaging.version.Version) spec = ( - "%s==%s" if isinstance(parsed_version, Version) else "%s===%s" + "%s==%s" if is_version else "%s===%s" ) list( parse_requirements(spec % (self.egg_name, self.egg_version)) -- cgit v1.2.1 From 76906b7a50726de89307d55690338d0f40a5aadb Mon Sep 17 00:00:00 2001 From: "\"W. Trevor King\"" Date: Thu, 16 Oct 2014 17:31:16 -0700 Subject: egg_info: Search egg-base for files to add to the manifest Before this commit, this: $ mkdir -p /tmp/xyz/{home,lib,scripts,data,egg} $ cat >/tmp/xyz/home/.pydistutils.cfg < [egg_info] > egg-base = /tmp/xyz/egg > EOF $ export PYTHONPATH=/tmp/xyz/lib $ export HOME=/tmp/xyz/home $ setup.py install --home=/tmp/xyz/home --install-lib=/tmp/xyz/lib \ > --install-scripts=/tmp/xyz/scripts --install-data=/tmp/xyz/data drops a lot of metadata, installing only SOURCES.txt and zip-safe under EGG-INFO. The problem is that the metadata files are written to egg-base, but egg-base is not searched when creating the manifest because it's outside of the current directory. Work around this by explicitly searching egg-base with distutils.filelist.findall (which is really the version monkeypatched in by setuptools/__init__.py). Since findall records relative paths, prefix the returned paths with egg-base, so the include_pattern looking for the absolute ei_cmd.egg_info will match them. --- setuptools/command/egg_info.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 43df87dc..2318e54d 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -6,6 +6,7 @@ from distutils.filelist import FileList as _FileList from distutils.util import convert_path from distutils import log import distutils.errors +import distutils.filelist import os import re import sys @@ -324,6 +325,10 @@ class manifest_maker(sdist): elif os.path.exists(self.manifest): self.read_manifest() ei_cmd = self.get_finalized_command('egg_info') + if ei_cmd.egg_base != os.curdir: + self.filelist.allfiles.extend([ + os.path.join(ei_cmd.egg_base, path) + for path in distutils.filelist.findall(ei_cmd.egg_base)]) self.filelist.include_pattern("*", prefix=ei_cmd.egg_info) def prune_file_list(self): -- cgit v1.2.1 From 03048c86ba6f955179cb4dcab5dd2db024609f19 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 16 Oct 2014 21:49:22 -0700 Subject: egg_info: Split manifest_maker._add_egg_info into its own method On Sat, Oct 11, 2014 at 04:23:37PM -0000, Jason R. Coombs wrote [1]: > I suggest implementing the functionality as a separate method with a > docstring explaining the purpose. so that's what we have here. The docstring is adapted from the cbd4f603 (egg_info: Search egg-base for files to add to the manifest, 2014-10-16) commit message. It's a lot of docs for a single command (although there is a newsted list comprehension), so I'm fine if you drop this commit before merging. The motivation behind the lines would still be available in the version control history: $ hg blame -c setuptools/command/egg_info.py | grep -A1 ei_cmd.egg_base cbd4f6038604: if ei_cmd.egg_base != os.curdir: cbd4f6038604: self.filelist.allfiles.extend([ cbd4f6038604: os.path.join(ei_cmd.egg_base, path) cbd4f6038604: for path in distutils.filelist.findall(ei_cmd.egg_base)]) 80108b046cb6: self.filelist.include_pattern("*", prefix=ei_cmd.egg_info) $ hg log -vr cbd4f6038604 changeset: 3163:cbd4f6038604 ... description: egg_info: Search egg-base for files to add to the manifest Before this commit, this: $ mkdir -p /tmp/xyz/{home,lib,scripts,data,egg} $ cat >/tmp/xyz/home/.pydistutils.cfg < Date: Mon, 3 Nov 2014 14:06:44 +0000 Subject: Make egg_info command write out setup requirements This commit makes the egg_info command write out setup requirements as well as install requirements, setup requirements are written to a setup_requires.txt file. The commit adds a new function write_setup_requirements which uses the existing _write_requirements function to write setup requirements out to a file and adds a new entry point to the egg_info.writers group. --- setuptools/command/egg_info.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 06764a17..78d86981 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -382,6 +382,12 @@ def write_requirements(cmd, basename, filename): cmd.write_or_delete_file("requirements", filename, data.getvalue()) +def write_setup_requirements(cmd, basename, filename): + data = StringIO() + _write_requirements(data, cmd.distribution.setup_requires) + cmd.write_or_delete_file("setup-requirements", filename, data.getvalue()) + + def write_toplevel_names(cmd, basename, filename): pkgs = dict.fromkeys( [ -- cgit v1.2.1 From 9a010cff9c654b4224721111eed0a27bb5ce726a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 13 Dec 2014 14:59:23 -0500 Subject: Edit docstring for imperative form --- setuptools/command/egg_info.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 302d6874..cbc30ff8 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -330,12 +330,13 @@ class manifest_maker(sdist): self.filelist.include_pattern("*", prefix=ei_cmd.egg_info) def _add_egg_info(self, cmd): - """Add paths for egg-info files for an external egg-base. + """ + Add paths for egg-info files for an external egg-base. - The egg-info files are written to egg-base. If egg-base is - outside the current working directory, we need a separate step - (this method) to search the egg-base directory when creating - the manifest. We use distutils.filelist.findall (which is + The egg-info files are written to egg-base. If egg-base is + outside the current working directory, this method + searchs the egg-base directory for files to include + in the manifest. Uses distutils.filelist.findall (which is really the version monkeypatched in by setuptools/__init__.py) to perform the search. -- cgit v1.2.1 From 3ad4ef1f994dcacc32b1a5f77d4c119ec0ce75af Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 13 Dec 2014 15:00:07 -0500 Subject: Remove superfluous list construction. --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index cbc30ff8..e7e4cd7e 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -345,9 +345,9 @@ class manifest_maker(sdist): (which is looking for the absolute cmd.egg_info) will match them. """ - self.filelist.allfiles.extend([ + self.filelist.allfiles.extend( os.path.join(cmd.egg_base, path) - for path in distutils.filelist.findall(cmd.egg_base)]) + for path in distutils.filelist.findall(cmd.egg_base)) def prune_file_list(self): build = self.get_finalized_command('build') -- cgit v1.2.1 From fec71bcbc8b0aa6bde0b0d054587bcd9c08019e9 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 13 Dec 2014 15:03:48 -0500 Subject: Extract variables to capture substeps. --- setuptools/command/egg_info.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index e7e4cd7e..782b2777 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -345,9 +345,9 @@ class manifest_maker(sdist): (which is looking for the absolute cmd.egg_info) will match them. """ - self.filelist.allfiles.extend( - os.path.join(cmd.egg_base, path) - for path in distutils.filelist.findall(cmd.egg_base)) + discovered = distutils.filelist.findall(cmd.egg_base) + resolved = (os.path.join(cmd.egg_base, path) for path in discovered) + self.filelist.allfiles.extend(resolved) def prune_file_list(self): build = self.get_finalized_command('build') -- cgit v1.2.1 From e0bd38e357b89880dde1340a4089aacc1af4a89b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 13 Dec 2014 15:07:15 -0500 Subject: Move invocation bypass into function itself, pertinent to the docstring. --- setuptools/command/egg_info.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 782b2777..e1324127 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -325,8 +325,7 @@ class manifest_maker(sdist): elif os.path.exists(self.manifest): self.read_manifest() ei_cmd = self.get_finalized_command('egg_info') - if ei_cmd.egg_base != os.curdir: - self._add_egg_info(cmd=ei_cmd) + self._add_egg_info(cmd=ei_cmd) self.filelist.include_pattern("*", prefix=ei_cmd.egg_info) def _add_egg_info(self, cmd): @@ -345,6 +344,10 @@ class manifest_maker(sdist): (which is looking for the absolute cmd.egg_info) will match them. """ + if cmd.egg_base == os.curdir: + # egg-info files were already added by something else + return + discovered = distutils.filelist.findall(cmd.egg_base) resolved = (os.path.join(cmd.egg_base, path) for path in discovered) self.filelist.allfiles.extend(resolved) -- cgit v1.2.1 From 9063c163e105545bacb67865f5d35056eb342a49 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 24 Dec 2014 17:02:04 -0500 Subject: Move vendored packaging module into pkg_resources._vendor, restoring independence of pkg_resources from setuptools. Fixes #311. --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index e1324127..dfbab0e9 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -15,8 +15,8 @@ try: import packaging.version except ImportError: # fallback to vendored version - import setuptools._vendor.packaging.version - packaging = setuptools._vendor.packaging + import pkg_resources._vendor.packaging.version + packaging = pkg_resources._vendor.packaging from setuptools import Command from setuptools.command.sdist import sdist -- cgit v1.2.1 From 170657b68f4b92e7e1bf82f5e19a831f5744af67 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 24 Dec 2014 17:11:49 -0500 Subject: Setuptools now uses the 'packaging' package from pkg_resources, unifying the behavior around resolution of that package. --- setuptools/command/egg_info.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index dfbab0e9..88ab0b82 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -11,13 +11,6 @@ import os import re import sys -try: - import packaging.version -except ImportError: - # fallback to vendored version - import pkg_resources._vendor.packaging.version - packaging = pkg_resources._vendor.packaging - from setuptools import Command from setuptools.command.sdist import sdist from setuptools.compat import basestring, PY3, StringIO @@ -28,6 +21,7 @@ from pkg_resources import ( safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) import setuptools.unicode_utils as unicode_utils +from pkg_resources import packaging class egg_info(Command): description = "create a distribution's .egg-info directory" -- 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/egg_info.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 88ab0b82..526e0a8f 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -11,10 +11,14 @@ import os import re import sys +try: + from setuptools_svn import svn_utils +except ImportError: + pass + from setuptools import Command from setuptools.command.sdist import sdist from setuptools.compat import basestring, PY3, StringIO -from setuptools import svn_utils from setuptools.command.sdist import walk_revctrl from pkg_resources import ( parse_requirements, safe_name, parse_version, @@ -190,6 +194,8 @@ class egg_info(Command): @staticmethod def get_svn_revision(): + if 'svn_utils' not in globals(): + return "0" return str(svn_utils.SvnInfo.load(os.curdir).get_revision()) def find_sources(self): -- cgit v1.2.1 From 3ff70513dceb10287c79ca9eb902e42b74f3e55f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 19 Mar 2015 14:10:49 -0400 Subject: Replace deprecated usage with preferred usage. Fixes #364. --- setuptools/command/egg_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a9940677..50f3d5c0 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -168,7 +168,8 @@ class egg_info(Command): self.mkpath(self.egg_info) installer = self.distribution.fetch_build_egg for ep in iter_entry_points('egg_info.writers'): - writer = ep.load(installer=installer) + ep.require(installer=installer) + writer = ep.resolve() writer(self, ep.name, os.path.join(self.egg_info, ep.name)) # Get rid of native_libs.txt if it was put there by older bdist_egg -- 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/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 50f3d5c0..9a9193c1 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -10,6 +10,7 @@ import distutils.filelist import os import re import sys +import io try: from setuptools_svn import svn_utils @@ -471,10 +472,9 @@ def get_pkg_info_revision(): # a subversion revision # if os.path.exists('PKG-INFO'): - f = open('PKG-INFO', 'rU') + with io.open('PKG-INFO') as f: for line in f: match = re.match(r"Version:.*-r(\d+)\s*$", line) if match: return int(match.group(1)) - f.close() return 0 -- cgit v1.2.1 From 50d864aa0693530a70efd6ffc8007d8328bfea6d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 9 Dec 2015 03:35:46 -0500 Subject: Reindent --- setuptools/command/egg_info.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 9a9193c1..fb94a044 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -472,9 +472,9 @@ def get_pkg_info_revision(): # a subversion revision # if os.path.exists('PKG-INFO'): - with io.open('PKG-INFO') as f: - for line in f: - match = re.match(r"Version:.*-r(\d+)\s*$", line) - if match: - return int(match.group(1)) + with io.open('PKG-INFO') as f: + for line in f: + match = re.match(r"Version:.*-r(\d+)\s*$", line) + if match: + return int(match.group(1)) return 0 -- cgit v1.2.1 From 1265c31f954afe7a1e47edc6dddfe7a5d4c9aa2a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 9 Dec 2015 03:40:13 -0500 Subject: Replace comment with docstring --- setuptools/command/egg_info.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index fb94a044..57e89c07 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -468,9 +468,10 @@ def write_entries(cmd, basename, filename): def get_pkg_info_revision(): - # See if we can get a -r### off of PKG-INFO, in case this is an sdist of - # a subversion revision - # + """ + Get a -r### off of PKG-INFO Version in case this is an sdist of + a subversion revision. + """ if os.path.exists('PKG-INFO'): with io.open('PKG-INFO') as f: for line in f: -- cgit v1.2.1 From ebaf4f2547e71247248abc77f9899e2106482646 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 9 Dec 2015 03:51:59 -0500 Subject: Deprecate get_pkg_info_revision --- setuptools/command/egg_info.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 57e89c07..3afd0a45 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -11,6 +11,7 @@ import os import re import sys import io +import warnings try: from setuptools_svn import svn_utils @@ -472,6 +473,7 @@ def get_pkg_info_revision(): Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision. """ + warnings.warn("get_pkg_info_revision is deprecated.", DeprecationWarning) if os.path.exists('PKG-INFO'): with io.open('PKG-INFO') as f: for line in f: -- cgit v1.2.1 From 6840f40ad0cc4df8c98cd8b78f4c86d6200c1b57 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 9 Dec 2015 03:53:38 -0500 Subject: Remove check that would never succeed, because svn_utils always returns an integer and get_svn_revision always returns a non-empty string. --- setuptools/command/egg_info.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 3afd0a45..28aa7994 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -186,9 +186,7 @@ class egg_info(Command): if self.tag_build: version += self.tag_build if self.tag_svn_revision: - rev = self.get_svn_revision() - if rev: # is 0 if it's not an svn working copy - version += '-r%s' % rev + version += '-r%s' % self.get_svn_revision() if self.tag_date: import time -- cgit v1.2.1 From 2a379eac97f2defcb828589ad5b46ace8a54d0f5 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 9 Dec 2015 03:54:32 -0500 Subject: Reorganize imports --- setuptools/command/egg_info.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 28aa7994..8b393a71 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -13,11 +13,6 @@ import sys import io import warnings -try: - from setuptools_svn import svn_utils -except ImportError: - pass - from setuptools import Command from setuptools.command.sdist import sdist from setuptools.compat import basestring, PY3, StringIO @@ -29,6 +24,12 @@ import setuptools.unicode_utils as unicode_utils from pkg_resources import packaging +try: + from setuptools_svn import svn_utils +except ImportError: + pass + + class egg_info(Command): description = "create a distribution's .egg-info directory" -- cgit v1.2.1 From 81ca4fea9e4672f39864439f2049108ad731c8fa Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 9 Dec 2015 03:57:25 -0500 Subject: Move imports to top --- setuptools/command/egg_info.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8b393a71..1301bd84 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -12,11 +12,15 @@ import re import sys import io import warnings +import time + +from setuptools.compat import basestring, PY3, StringIO from setuptools import Command from setuptools.command.sdist import sdist -from setuptools.compat import basestring, PY3, StringIO from setuptools.command.sdist import walk_revctrl +from setuptools.command.setopt import edit_config +from setuptools.command import bdist_egg from pkg_resources import ( parse_requirements, safe_name, parse_version, safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) @@ -61,8 +65,6 @@ class egg_info(Command): self.vtags = None def save_version_info(self, filename): - from setuptools.command.setopt import edit_config - values = dict( egg_info=dict( tag_svn_revision=0, @@ -189,8 +191,6 @@ class egg_info(Command): if self.tag_svn_revision: version += '-r%s' % self.get_svn_revision() if self.tag_date: - import time - version += time.strftime("-%Y%m%d") return version @@ -391,7 +391,6 @@ def write_pkg_info(cmd, basename, filename): metadata.name, metadata.version = oldname, oldver safe = getattr(cmd.distribution, 'zip_safe', None) - from setuptools.command import bdist_egg bdist_egg.write_safety_flag(cmd.egg_info, safe) -- 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/egg_info.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 19849e66..5b996a11 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -14,7 +14,12 @@ import io import warnings import time -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 import Command from setuptools.command.sdist import sdist -- 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/egg_info.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 5b996a11..cf46d24a 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -14,12 +14,7 @@ import io import warnings import time -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 import Command from setuptools.command.sdist import sdist -- cgit v1.2.1 From 9b985a9112d9be396adca6a1948076378c70cc34 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 31 Dec 2015 16:47:55 -0500 Subject: Use the same technique in pkg_resources, relying on an 'extern' module to resolve the conditional import. --HG-- branch : feature/issue-229 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index cf46d24a..18a3105f 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -26,7 +26,7 @@ from pkg_resources import ( safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) import setuptools.unicode_utils as unicode_utils -from pkg_resources import packaging +from pkg_resources.extern import packaging try: from setuptools_svn import svn_utils -- cgit v1.2.1 From 8af3b6ef5b4173a0d0d6735147c98c882ae98344 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2016 06:54:00 -0500 Subject: Always use Python 3 version of map --- setuptools/command/egg_info.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 18a3105f..d1bd9b04 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -15,6 +15,7 @@ import warnings import time from setuptools.extern import six +from setuptools.extern.six.moves import map from setuptools import Command from setuptools.command.sdist import sdist -- cgit v1.2.1 From 085247fa441f9b0fac05117ca1a3283e3510fb32 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 20 Apr 2016 09:25:21 -0400 Subject: Use OrderedDict to retain deterministic ordering of version info in egg_info command. Remove lexicographic ordering in setopt.edit_config. Ref #553 --- setuptools/command/egg_info.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index d1bd9b04..3c033300 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -13,6 +13,7 @@ import sys import io import warnings import time +import collections from setuptools.extern import six from setuptools.extern.six.moves import map @@ -66,14 +67,20 @@ class egg_info(Command): self.vtags = None def save_version_info(self, filename): - values = dict( - egg_info=dict( - tag_svn_revision=0, - tag_date=0, - tag_build=self.tags(), - ) - ) - edit_config(filename, values) + """ + Materialize the values of svn_revision and date into the + build tag. Install these keys in a deterministic order + to avoid arbitrary reordering on subsequent builds. + """ + # python 2.6 compatibility + odict = getattr(collections, 'OrderedDict', dict) + egg_info = odict() + # follow the order these keys would have been added + # when PYTHONHASHSEED=0 + egg_info['tag_date'] = 0 + egg_info['tag_svn_revision'] = 0 + egg_info['tag_build'] = self.tags() + edit_config(filename, dict(egg_info=egg_info)) def finalize_options(self): self.egg_name = safe_name(self.distribution.get_name()) -- cgit v1.2.1 From 3ea245437c2094a5eae415732c7b349606fd111f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 20 Apr 2016 10:16:37 -0400 Subject: Correction for expected dict order when PYTHONHASHSEED=0 --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 3c033300..8e1502a5 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -77,9 +77,9 @@ class egg_info(Command): egg_info = odict() # follow the order these keys would have been added # when PYTHONHASHSEED=0 + egg_info['tag_build'] = self.tags() egg_info['tag_date'] = 0 egg_info['tag_svn_revision'] = 0 - egg_info['tag_build'] = self.tags() edit_config(filename, dict(egg_info=egg_info)) def finalize_options(self): -- cgit v1.2.1 From 3cee4d8f79a20f1d67b194ee383dddd826695e0d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 24 Jun 2016 09:44:52 -0400 Subject: Nicer indentation --- setuptools/command/egg_info.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8e1502a5..829f03f9 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -52,8 +52,10 @@ class egg_info(Command): ] boolean_options = ['tag-date', 'tag-svn-revision'] - negative_opt = {'no-svn-revision': 'tag-svn-revision', - 'no-date': 'tag-date'} + negative_opt = { + 'no-svn-revision': 'tag-svn-revision', + 'no-date': 'tag-date', + } def initialize_options(self): self.egg_name = None -- cgit v1.2.1 From 542a921bb6943feb1c90874ba5151c94622b52b3 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 24 Jun 2016 10:17:41 -0400 Subject: Mark tag_svn_revision as deprecated. Ref #619. --- setuptools/command/egg_info.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 829f03f9..5183eedc 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -199,6 +199,10 @@ class egg_info(Command): if self.tag_build: version += self.tag_build if self.tag_svn_revision: + warnings.warn( + "tag_svn_revision is deprecated and will not be honored " + "in a future release" + ) version += '-r%s' % self.get_svn_revision() if self.tag_date: version += time.strftime("-%Y%m%d") -- cgit v1.2.1 From bb45468d27615c2ce9f9c9757a367c44d6ee80d2 Mon Sep 17 00:00:00 2001 From: Tim Heap Date: Tue, 16 Aug 2016 16:40:10 +1000 Subject: Much faster implementation of FileList, for big egg_info speedups --- setuptools/command/egg_info.py | 262 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 232 insertions(+), 30 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 5183eedc..6cc8f4c4 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -3,6 +3,7 @@ Create a distribution's .egg-info directory and contents""" from distutils.filelist import FileList as _FileList +from distutils.errors import DistutilsInternalError from distutils.util import convert_path from distutils import log import distutils.errors @@ -27,6 +28,7 @@ from pkg_resources import ( parse_requirements, safe_name, parse_version, safe_version, yield_lines, EntryPoint, iter_entry_points, to_filename) import setuptools.unicode_utils as unicode_utils +from setuptools.glob import glob from pkg_resources.extern import packaging @@ -36,6 +38,88 @@ except ImportError: pass +def translate_pattern(glob): + """ + Translate a file path glob like '*.txt' in to a regular expression. + This differs from fnmatch.translate which allows wildcards to match + directory separators. It also knows about '**/' which matches any number of + directories. + """ + pat = '' + + # This will split on '/' within [character classes]. This is deliberate. + chunks = glob.split(os.path.sep) + + sep = re.escape(os.sep) + valid_char = '[^%s]' % (sep,) + + for c, chunk in enumerate(chunks): + last_chunk = c == len(chunks) - 1 + + # Chunks that are a literal ** are globstars. They match anything. + if chunk == '**': + if last_chunk: + # Match anything if this is the last component + pat += '.*' + else: + # Match '(name/)*' + pat += '(?:%s+%s)*' % (valid_char, sep) + continue # Break here as the whole path component has been handled + + # Find any special characters in the remainder + i = 0 + chunk_len = len(chunk) + while i < chunk_len: + char = chunk[i] + if char == '*': + # Match any number of name characters + pat += valid_char + '*' + elif char == '?': + # Match a name character + pat += valid_char + elif char == '[': + # Character class + inner_i = i + 1 + # Skip initial !/] chars + if inner_i < chunk_len and chunk[inner_i] == '!': + inner_i = inner_i + 1 + if inner_i < chunk_len and chunk[inner_i] == ']': + inner_i = inner_i + 1 + + # Loop till the closing ] is found + while inner_i < chunk_len and chunk[inner_i] != ']': + inner_i = inner_i + 1 + + if inner_i >= chunk_len: + # Got to the end of the string without finding a closing ] + # Do not treat this as a matching group, but as a literal [ + pat += re.escape(char) + else: + # Grab the insides of the [brackets] + inner = chunk[i + 1:inner_i] + char_class = '' + + # Class negation + if inner[0] == '!': + char_class = '^' + inner = inner[1:] + + char_class += re.escape(inner) + pat += '[%s]' % (char_class,) + + # Skip to the end ] + i = inner_i + else: + pat += re.escape(char) + i += 1 + + # Join each chunk with the dir separator + if not last_chunk: + pat += sep + + return re.compile(pat + r'\Z(?ms)') + + class egg_info(Command): description = "create a distribution's .egg-info directory" @@ -239,7 +323,151 @@ class egg_info(Command): class FileList(_FileList): - """File list that accepts only existing, platform-independent paths""" + # Implementations of the various MANIFEST.in commands + + def process_template_line(self, line): + # Parse the line: split it up, make sure the right number of words + # is there, and return the relevant words. 'action' is always + # defined: it's the first word of the line. Which of the other + # three are defined depends on the action; it'll be either + # patterns, (dir and patterns), or (dir_pattern). + (action, patterns, dir, dir_pattern) = self._parse_template_line(line) + + # OK, now we know that the action is valid and we have the + # right number of words on the line for that action -- so we + # can proceed with minimal error-checking. + if action == 'include': + self.debug_print("include " + ' '.join(patterns)) + for pattern in patterns: + if not self.include(pattern): + log.warn("warning: no files found matching '%s'", pattern) + + elif action == 'exclude': + self.debug_print("exclude " + ' '.join(patterns)) + for pattern in patterns: + if not self.exclude(pattern): + log.warn(("warning: no previously-included files " + "found matching '%s'"), pattern) + + elif action == 'global-include': + self.debug_print("global-include " + ' '.join(patterns)) + for pattern in patterns: + if not self.global_include(pattern): + log.warn(("warning: no files found matching '%s' " + "anywhere in distribution"), pattern) + + elif action == 'global-exclude': + self.debug_print("global-exclude " + ' '.join(patterns)) + for pattern in patterns: + if not self.global_exclude(pattern): + log.warn(("warning: no previously-included files matching " + "'%s' found anywhere in distribution"), + pattern) + + elif action == 'recursive-include': + self.debug_print("recursive-include %s %s" % + (dir, ' '.join(patterns))) + for pattern in patterns: + if not self.recursive_include(dir, pattern): + log.warn(("warning: no files found matching '%s' " + "under directory '%s'"), + pattern, dir) + + elif action == 'recursive-exclude': + self.debug_print("recursive-exclude %s %s" % + (dir, ' '.join(patterns))) + for pattern in patterns: + if not self.recursive_exclude(dir, pattern): + log.warn(("warning: no previously-included files matching " + "'%s' found under directory '%s'"), + pattern, dir) + + elif action == 'graft': + self.debug_print("graft " + dir_pattern) + if not self.graft(dir_pattern): + log.warn("warning: no directories found matching '%s'", + dir_pattern) + + elif action == 'prune': + self.debug_print("prune " + dir_pattern) + if not self.prune(dir_pattern): + log.warn(("no previously-included directories found " + "matching '%s'"), dir_pattern) + + else: + raise DistutilsInternalError( + "this cannot happen: invalid action '%s'" % action) + + def _remove_files(self, predicate): + """ + Remove all files from the file list that match the predicate. + Return True if any matching files were removed + """ + found = False + for i in range(len(self.files) - 1, -1, -1): + if predicate(self.files[i]): + self.debug_print(" removing " + self.files[i]) + del self.files[i] + found = True + return found + + def include(self, pattern): + """Include files that match 'pattern'.""" + found = [f for f in glob(pattern) if not os.path.isdir(f)] + self.extend(found) + return bool(found) + + def exclude(self, pattern): + """Exclude files that match 'pattern'.""" + match = translate_pattern(pattern) + return self._remove_files(match.match) + + def recursive_include(self, dir, pattern): + """ + Include all files anywhere in 'dir/' that match the pattern. + """ + full_pattern = os.path.join(dir, '**', pattern) + found = [f for f in glob(full_pattern, recursive=True) + if not os.path.isdir(f)] + self.extend(found) + return bool(found) + + def recursive_exclude(self, dir, pattern): + """ + Exclude any file anywhere in 'dir/' that match the pattern. + """ + match = translate_pattern(os.path.join(dir, '**', pattern)) + return self._remove_files(match.match) + + def graft(self, dir): + """Include all files from 'dir/'.""" + found = distutils.filelist.findall(dir) + self.extend(found) + return bool(found) + + def prune(self, dir): + """Filter out files from 'dir/'.""" + match = translate_pattern(os.path.join(dir, '**')) + return self._remove_files(match.match) + + def global_include(self, pattern): + """ + Include all files anywhere in the current directory that match the + pattern. This is very inefficient on large file trees. + """ + if self.allfiles is None: + self.findall() + match = translate_pattern(os.path.join('**', pattern)) + found = [f for f in self.allfiles if match.match(f)] + self.extend(found) + return bool(found) + + def global_exclude(self, pattern): + """ + Exclude all files anywhere that match the pattern. + """ + match = translate_pattern(os.path.join('**', pattern)) + return self._remove_files(match.match) def append(self, item): if item.endswith('\r'): # Fix older sdists built on Windows @@ -302,7 +530,6 @@ class manifest_maker(sdist): self.filelist = FileList() if not os.path.exists(self.manifest): self.write_manifest() # it must exist so it'll get in the list - self.filelist.findall() self.add_defaults() if os.path.exists(self.template): self.read_template() @@ -341,38 +568,13 @@ class manifest_maker(sdist): elif os.path.exists(self.manifest): self.read_manifest() ei_cmd = self.get_finalized_command('egg_info') - self._add_egg_info(cmd=ei_cmd) - self.filelist.include_pattern("*", prefix=ei_cmd.egg_info) - - def _add_egg_info(self, cmd): - """ - Add paths for egg-info files for an external egg-base. - - The egg-info files are written to egg-base. If egg-base is - outside the current working directory, this method - searchs the egg-base directory for files to include - in the manifest. Uses distutils.filelist.findall (which is - really the version monkeypatched in by setuptools/__init__.py) - to perform the search. - - Since findall records relative paths, prefix the returned - paths with cmd.egg_base, so add_default's include_pattern call - (which is looking for the absolute cmd.egg_info) will match - them. - """ - if cmd.egg_base == os.curdir: - # egg-info files were already added by something else - return - - discovered = distutils.filelist.findall(cmd.egg_base) - resolved = (os.path.join(cmd.egg_base, path) for path in discovered) - self.filelist.allfiles.extend(resolved) + self.filelist.graft(ei_cmd.egg_info) def prune_file_list(self): build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() - self.filelist.exclude_pattern(None, prefix=build.build_base) - self.filelist.exclude_pattern(None, prefix=base_dir) + self.filelist.prune(build.build_base) + self.filelist.prune(base_dir) sep = re.escape(os.sep) self.filelist.exclude_pattern(r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep, is_regex=1) -- cgit v1.2.1 From ed5f934e0a49253d645b66dad65fd5b616133d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles=20Bouchard-L=C3=A9gar=C3=A9?= Date: Mon, 7 Nov 2016 22:07:29 -0500 Subject: Also suppress warning for a single file missing --- setuptools/command/egg_info.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 6cc8f4c4..6f8fd874 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -554,10 +554,17 @@ class manifest_maker(sdist): msg = "writing manifest file '%s'" % self.manifest self.execute(write_file, (self.manifest, files), msg) - def warn(self, msg): # suppress missing-file warnings from sdist - if not msg.startswith("standard file not found:"): + def warn(self, msg): + if not self._should_suppress_warning(msg): sdist.warn(self, msg) + @staticmethod + def _should_suppress_warning(msg): + """ + suppress missing-file warnings from sdist + """ + return re.match(r"standard file .*not found", msg) + def add_defaults(self): sdist.add_defaults(self) self.filelist.append(self.template) -- cgit v1.2.1 From 23aba916e1070d3cf9723af85a6ce07c89053931 Mon Sep 17 00:00:00 2001 From: Tim Heap Date: Mon, 21 Nov 2016 01:44:22 +0200 Subject: Fix #849 global-exclude globbing After #764, `global-exclude .pyc` no longer excluded `.pyc` files. This fixes that regression, and adds a test for this behaviour. --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 6cc8f4c4..c4555b3e 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -457,7 +457,7 @@ class FileList(_FileList): """ if self.allfiles is None: self.findall() - match = translate_pattern(os.path.join('**', pattern)) + match = translate_pattern(os.path.join('**', '*' + pattern)) found = [f for f in self.allfiles if match.match(f)] self.extend(found) return bool(found) @@ -466,7 +466,7 @@ class FileList(_FileList): """ Exclude all files anywhere that match the pattern. """ - match = translate_pattern(os.path.join('**', pattern)) + match = translate_pattern(os.path.join('**', '*' + pattern)) return self._remove_files(match.match) def append(self, item): -- 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/egg_info.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8a06e496..40cea9bf 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -158,9 +158,7 @@ class egg_info(Command): build tag. Install these keys in a deterministic order to avoid arbitrary reordering on subsequent builds. """ - # python 2.6 compatibility - odict = getattr(collections, 'OrderedDict', dict) - egg_info = odict() + egg_info = collections.OrderedDict() # follow the order these keys would have been added # when PYTHONHASHSEED=0 egg_info['tag_build'] = self.tags() -- cgit v1.2.1 From 980c2c5afd20fb9f7e50cb8ec0c42abc664da352 Mon Sep 17 00:00:00 2001 From: Tim Heap Date: Thu, 15 Dec 2016 10:11:37 +1100 Subject: Revert "Fix #849 global-exclude globbing" This reverts commit 23aba916e1070d3cf9723af85a6ce07c89053931. --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8a06e496..6f8fd874 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -457,7 +457,7 @@ class FileList(_FileList): """ if self.allfiles is None: self.findall() - match = translate_pattern(os.path.join('**', '*' + pattern)) + match = translate_pattern(os.path.join('**', pattern)) found = [f for f in self.allfiles if match.match(f)] self.extend(found) return bool(found) @@ -466,7 +466,7 @@ class FileList(_FileList): """ Exclude all files anywhere that match the pattern. """ - match = translate_pattern(os.path.join('**', '*' + pattern)) + match = translate_pattern(os.path.join('**', pattern)) return self._remove_files(match.match) def append(self, item): -- cgit v1.2.1 From 249f870f2c6fb60734e9db34e44f7e44cd35c914 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Jan 2017 10:08:00 -0500 Subject: Drop support for 'tag_svn_version' distribution option. Fixes #619. --- setuptools/command/egg_info.py | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 6f8fd874..98a87300 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -32,11 +32,6 @@ from setuptools.glob import glob from pkg_resources.extern import packaging -try: - from setuptools_svn import svn_utils -except ImportError: - pass - def translate_pattern(glob): """ @@ -147,7 +142,6 @@ class egg_info(Command): self.egg_base = None self.egg_info = None self.tag_build = None - self.tag_svn_revision = 0 self.tag_date = 0 self.broken_egg_info = False self.vtags = None @@ -165,7 +159,6 @@ class egg_info(Command): # when PYTHONHASHSEED=0 egg_info['tag_build'] = self.tags() egg_info['tag_date'] = 0 - egg_info['tag_svn_revision'] = 0 edit_config(filename, dict(egg_info=egg_info)) def finalize_options(self): @@ -282,22 +275,10 @@ class egg_info(Command): version = '' if self.tag_build: version += self.tag_build - if self.tag_svn_revision: - warnings.warn( - "tag_svn_revision is deprecated and will not be honored " - "in a future release" - ) - version += '-r%s' % self.get_svn_revision() if self.tag_date: version += time.strftime("-%Y%m%d") return version - @staticmethod - def get_svn_revision(): - if 'svn_utils' not in globals(): - return "0" - return str(svn_utils.SvnInfo.load(os.curdir).get_revision()) - def find_sources(self): """Generate SOURCES.txt manifest file""" manifest_filename = os.path.join(self.egg_info, "SOURCES.txt") -- 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/egg_info.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 98a87300..2bc57b18 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -16,8 +16,8 @@ import warnings import time import collections -from setuptools.extern import six -from setuptools.extern.six.moves import map +import six +from six.moves import map from setuptools import Command from setuptools.command.sdist import sdist @@ -30,7 +30,7 @@ from pkg_resources import ( import setuptools.unicode_utils as unicode_utils from setuptools.glob import glob -from pkg_resources.extern import packaging +import packaging def translate_pattern(glob): -- cgit v1.2.1 From dc8683bd8e8600680a7581fd3a2d34ba8f1fa0ab Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 2 Jan 2017 09:29:42 -0500 Subject: More aggressively remove references to 'tag_svn_revision' option in egg_info. Ref #619. --- setuptools/command/egg_info.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 98a87300..e3578074 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -121,18 +121,13 @@ class egg_info(Command): user_options = [ ('egg-base=', 'e', "directory containing .egg-info directories" " (default: top of the source tree)"), - ('tag-svn-revision', 'r', - "Add subversion revision ID to version number"), ('tag-date', 'd', "Add date stamp (e.g. 20050528) to version number"), ('tag-build=', 'b', "Specify explicit tag to add to version number"), - ('no-svn-revision', 'R', - "Don't add subversion revision ID [default]"), ('no-date', 'D', "Don't include date stamp [default]"), ] - boolean_options = ['tag-date', 'tag-svn-revision'] + boolean_options = ['tag-date'] negative_opt = { - 'no-svn-revision': 'tag-svn-revision', 'no-date': 'tag-date', } @@ -148,8 +143,8 @@ class egg_info(Command): def save_version_info(self, filename): """ - Materialize the values of svn_revision and date into the - build tag. Install these keys in a deterministic order + Materialize the value of date into the + build tag. Install build keys in a deterministic order to avoid arbitrary reordering on subsequent builds. """ # python 2.6 compatibility -- cgit v1.2.1 From b848627d17328cab9bdce4fabd314c76d5f7d96e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 2 Jan 2017 09:56:47 -0500 Subject: Add a no-op property for 'tag_svn_revision' to suppress errors when distutils attempts to detect and set these values based on settings in setup.cfg as found in sdists built by earlier versions of setuptools. Ref #619. --- setuptools/command/egg_info.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index e3578074..ca6a4348 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -141,6 +141,18 @@ class egg_info(Command): self.broken_egg_info = False self.vtags = None + #################################### + # allow the 'tag_svn_revision' to be detected and + # set, supporting sdists built on older Setuptools. + @property + def tag_svn_revision(self): + pass + + @tag_svn_revision.setter + def tag_svn_revision(self, value): + pass + #################################### + def save_version_info(self, filename): """ Materialize the value of date into the -- cgit v1.2.1 From 56274b32724933cd2016488c4e667e86d30572ef Mon Sep 17 00:00:00 2001 From: Hatem Nassrat Date: Mon, 23 Jan 2017 18:07:21 +0000 Subject: fixes #935 - allows for glob syntax in graft --- setuptools/command/egg_info.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 5ab54dc7..62bf00aa 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -429,7 +429,9 @@ class FileList(_FileList): def graft(self, dir): """Include all files from 'dir/'.""" - found = distutils.filelist.findall(dir) + found = [] + for match_dir in glob(dir): + found += distutils.filelist.findall(match_dir) self.extend(found) return bool(found) -- cgit v1.2.1 From 9cb83c3711d737fa3bff56f55e4def8267bae83c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 23 Jan 2017 17:01:33 -0500 Subject: Prefer list comprehension to init/append loop. Ref #936. --- setuptools/command/egg_info.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 62bf00aa..1a6ea9cb 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -429,9 +429,11 @@ class FileList(_FileList): def graft(self, dir): """Include all files from 'dir/'.""" - found = [] - for match_dir in glob(dir): - found += distutils.filelist.findall(match_dir) + found = [ + item + for match_dir in glob(dir) + for item in distutils.filelist.findall(match_dir) + ] self.extend(found) return bool(found) -- 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/egg_info.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 1a6ea9cb..a32c42f8 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -16,8 +16,8 @@ import warnings import time import collections -import six -from six.moves import map +from setuptools.extern import six +from setuptools.extern.six.moves import map from setuptools import Command from setuptools.command.sdist import sdist @@ -30,7 +30,7 @@ from pkg_resources import ( import setuptools.unicode_utils as unicode_utils from setuptools.glob import glob -import packaging +from pkg_resources.extern import packaging def translate_pattern(glob): -- cgit v1.2.1 From 1955e5b0df67cc1aa389b8c655199958a6fcc6a0 Mon Sep 17 00:00:00 2001 From: Stefano Miccoli Date: Thu, 13 Apr 2017 22:57:56 +0200 Subject: addresses #436 --- setuptools/command/egg_info.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 1a6ea9cb..21bbfb72 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -564,8 +564,6 @@ class manifest_maker(sdist): rcfiles = list(walk_revctrl()) if rcfiles: self.filelist.extend(rcfiles) - elif os.path.exists(self.manifest): - self.read_manifest() ei_cmd = self.get_finalized_command('egg_info') self.filelist.graft(ei_cmd.egg_info) -- cgit v1.2.1 From 1163c86b3b62258f28964c2aee8483631a85c892 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 18 Apr 2017 17:52:44 -0500 Subject: Revert "addresses #436". Fixes #1016. This reverts commit 1955e5b0df67cc1aa389b8c655199958a6fcc6a0. --- setuptools/command/egg_info.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 21bbfb72..1a6ea9cb 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -564,6 +564,8 @@ class manifest_maker(sdist): rcfiles = list(walk_revctrl()) if rcfiles: self.filelist.extend(rcfiles) + elif os.path.exists(self.manifest): + self.read_manifest() ei_cmd = self.get_finalized_command('egg_info') self.filelist.graft(ei_cmd.egg_info) -- cgit v1.2.1 From f1a9711815acab7e2d9c77b86b43117f72c5c78f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 18 Apr 2017 18:32:40 -0500 Subject: Pass flags programmatically, avoiding deprecating trailing pattern flags syntax revealed in #1015. --- setuptools/command/egg_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 1a6ea9cb..151e495b 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -112,7 +112,8 @@ def translate_pattern(glob): if not last_chunk: pat += sep - return re.compile(pat + r'\Z(?ms)') + pat += r'\Z' + return re.compile(pat, flags=re.MULTILINE|re.DOTALL) class egg_info(Command): -- cgit v1.2.1 From 4fc60ed1e47f725a833dd63656ceec981a58e1a0 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Sat, 30 Jul 2016 08:15:53 -0700 Subject: Add new long_description_content_type kwarg This is used to populate the new `Description-Content-Type` field. `Description-Content-Type` is described at https://github.com/pypa/python-packaging-user-guide/pull/258 --- setuptools/command/egg_info.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 6c00b0b7..a183d15d 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -599,6 +599,10 @@ def write_pkg_info(cmd, basename, filename): metadata = cmd.distribution.metadata metadata.version, oldver = cmd.egg_version, metadata.version metadata.name, oldname = cmd.egg_name, metadata.name + metadata.long_description_content_type = getattr( + cmd.distribution, + 'long_description_content_type' + ) try: # write unescaped data to PKG-INFO, so older pkg_resources # can still parse it -- cgit v1.2.1 From 553e21e12ca2ebe6ab0f597e69594b71271faecc Mon Sep 17 00:00:00 2001 From: Henk-Jaap Wagenaar Date: Tue, 21 Nov 2017 22:16:53 +0000 Subject: Add setup.cfg support for long_description_content_type (in line with docs). --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a1d41b27..27e10eeb 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -598,7 +598,7 @@ def write_pkg_info(cmd, basename, filename): metadata.version, oldver = cmd.egg_version, metadata.version metadata.name, oldname = cmd.egg_name, metadata.name metadata.long_description_content_type = getattr( - cmd.distribution, + cmd.distribution.metadata, 'long_description_content_type' ) try: -- cgit v1.2.1 From 00de710988226c3189bd6abb13cfa87c7d97de5b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 25 Nov 2017 08:25:09 -0500 Subject: Fix NameError --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a1d41b27..103c5f20 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -640,7 +640,7 @@ def write_requirements(cmd, basename, filename): def write_setup_requirements(cmd, basename, filename): - data = StringIO() + data = io.StringIO() _write_requirements(data, cmd.distribution.setup_requires) cmd.write_or_delete_file("setup-requirements", filename, data.getvalue()) -- cgit v1.2.1 From 780a6f161ed4ce1026f5279c53c196d3bfdcec37 Mon Sep 17 00:00:00 2001 From: Henk-Jaap Wagenaar Date: Sat, 25 Nov 2017 18:55:58 +0000 Subject: Rework how to handle long_description_content_type --- setuptools/command/egg_info.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 27e10eeb..d3725a2f 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -597,10 +597,7 @@ def write_pkg_info(cmd, basename, filename): metadata = cmd.distribution.metadata metadata.version, oldver = cmd.egg_version, metadata.version metadata.name, oldname = cmd.egg_name, metadata.name - metadata.long_description_content_type = getattr( - cmd.distribution.metadata, - 'long_description_content_type' - ) + try: # write unescaped data to PKG-INFO, so older pkg_resources # can still parse it -- cgit v1.2.1 From 929acc4e551448a68411968fb50336ad51ed4d3c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 17 Mar 2018 14:10:32 -0400 Subject: Setuptools now vendors its own direct dependencies (packaging, six, pyparsing). Ref #1296. --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index befa0904..f3e604d3 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -30,7 +30,7 @@ from pkg_resources import ( import setuptools.unicode_utils as unicode_utils from setuptools.glob import glob -from pkg_resources.extern import packaging +from setuptools.extern import packaging def translate_pattern(glob): -- cgit v1.2.1 From e9bdeda02a1be80d295aa8e4b068e4844141512b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 13 Jul 2018 00:02:14 -0400 Subject: Extract name/version functionality from egg_info to be re-used by a dist-info command. Ref #1386. --- setuptools/command/egg_info.py | 61 ++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 26 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index f3e604d3..5fd6c888 100755 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -116,7 +116,33 @@ def translate_pattern(glob): return re.compile(pat, flags=re.MULTILINE|re.DOTALL) -class egg_info(Command): +class InfoCommon: + tag_build = None + tag_date = None + + @property + def name(self): + return safe_name(self.distribution.get_name()) + + def tagged_version(self): + version = self.distribution.get_version() + # egg_info may be called more than once for a distribution, + # in which case the version string already contains all tags. + if self.vtags and version.endswith(self.vtags): + return safe_version(version) + return safe_version(version + self.vtags) + + def tags(self): + version = '' + if self.tag_build: + version += self.tag_build + if self.tag_date: + version += time.strftime("-%Y%m%d") + return version + vtags = property(tags) + + +class egg_info(InfoCommon, Command): description = "create a distribution's .egg-info directory" user_options = [ @@ -133,14 +159,9 @@ class egg_info(Command): } def initialize_options(self): - self.egg_name = None - self.egg_version = None self.egg_base = None self.egg_info = None - self.tag_build = None - self.tag_date = 0 self.broken_egg_info = False - self.vtags = None #################################### # allow the 'tag_svn_revision' to be detected and @@ -167,11 +188,15 @@ class egg_info(Command): egg_info['tag_date'] = 0 edit_config(filename, dict(egg_info=egg_info)) - def finalize_options(self): - self.egg_name = safe_name(self.distribution.get_name()) - self.vtags = self.tags() - self.egg_version = self.tagged_version() + @property + def egg_name(self): + return self.name + + @property + def egg_version(self): + return self.tagged_version() + def finalize_options(self): parsed_version = parse_version(self.egg_version) try: @@ -254,14 +279,6 @@ class egg_info(Command): if not self.dry_run: os.unlink(filename) - def tagged_version(self): - version = self.distribution.get_version() - # egg_info may be called more than once for a distribution, - # in which case the version string already contains all tags. - if self.vtags and version.endswith(self.vtags): - return safe_version(version) - return safe_version(version + self.vtags) - def run(self): self.mkpath(self.egg_info) installer = self.distribution.fetch_build_egg @@ -277,14 +294,6 @@ class egg_info(Command): self.find_sources() - def tags(self): - version = '' - if self.tag_build: - version += self.tag_build - if self.tag_date: - version += time.strftime("-%Y%m%d") - return version - def find_sources(self): """Generate SOURCES.txt manifest file""" manifest_filename = os.path.join(self.egg_info, "SOURCES.txt") -- 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/egg_info.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 setuptools/command/egg_info.py (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py old mode 100755 new mode 100644 -- cgit v1.2.1 From 47874756915a9a757f81d87f32ef5bfa2a333a26 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 13 Jul 2018 15:59:55 +0100 Subject: egg_info: Touch 'egg-info' directory 'tox' determines whether a package should be rebuilt by comparing the timestamp of the package's 'egg-info' directory and its 'setup.py' or 'setup.cfg' files [1][2]. Unfortunately this checks the 'egg-info' directory itself, which is not updated, unlike the contents of that directory. This means that 'tox' will always rebuild the package once one of the two setup files has been updated. While this is clearly a bug in 'tox' that should be fixed separately, there is merit in using this as a heuristic so enable it. [1] https://github.com/tox-dev/tox/blob/3.1.0/src/tox/venv.py#L253-L257 [2] https://github.com/tox-dev/tox/blob/3.1.0/src/tox/venv.py#L221-L244 Signed-off-by: Stephen Finucane --- setuptools/command/egg_info.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 5fd6c888..a3cd35dc 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -281,6 +281,7 @@ class egg_info(InfoCommon, Command): def run(self): self.mkpath(self.egg_info) + os.utime(self.egg_info, None) installer = self.distribution.fetch_build_egg for ep in iter_entry_points('egg_info.writers'): ep.require(installer=installer) -- cgit v1.2.1 From 337c008c33ab5799911cc7a8f4e8ff93e715a73b Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 21 Aug 2018 01:54:51 +0200 Subject: setuptools: fix regression with `egg_info` command Ensure version is tagged only once. --- setuptools/command/egg_info.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 5fd6c888..74350cbd 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -160,7 +160,9 @@ class egg_info(InfoCommon, Command): def initialize_options(self): self.egg_base = None + self.egg_name = None self.egg_info = None + self.egg_version = None self.broken_egg_info = False #################################### @@ -188,15 +190,13 @@ class egg_info(InfoCommon, Command): egg_info['tag_date'] = 0 edit_config(filename, dict(egg_info=egg_info)) - @property - def egg_name(self): - return self.name - - @property - def egg_version(self): - return self.tagged_version() - def finalize_options(self): + # Note: we need to capture the current value returned + # by `self.tagged_version()`, so we can later update + # `self.distribution.metadata.version` without + # repercussions. + self.egg_name = self.name + self.egg_version = self.tagged_version() parsed_version = parse_version(self.egg_version) try: -- 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/egg_info.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index bd116e1f..93100ab9 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -568,6 +568,7 @@ class manifest_maker(sdist): def add_defaults(self): sdist.add_defaults(self) + self.check_license() self.filelist.append(self.template) self.filelist.append(self.manifest) rcfiles = list(walk_revctrl()) -- cgit v1.2.1 From 5854b0eba03dd257e30efff68f1632bdec5f0416 Mon Sep 17 00:00:00 2001 From: Junhan Huang Date: Sat, 27 Oct 2018 16:26:51 -0400 Subject: Add custom deprecation warning classes `DeprecationWarning` is not visible by default in the latest versions of CPython, so this switches the deprecation warnings in setuptools and pkg_resources over to custom classes derived from `Warning` instead. Fixes issue github issue #159 Co-authored-by: Junhan Huang Co-authored-by: Marton Pono --- setuptools/command/egg_info.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index bd116e1f..e1022d31 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -31,7 +31,7 @@ import setuptools.unicode_utils as unicode_utils from setuptools.glob import glob from setuptools.extern import packaging - +from setuptools import SetuptoolsDeprecationWarning def translate_pattern(glob): """ @@ -696,7 +696,7 @@ def get_pkg_info_revision(): Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision. """ - warnings.warn("get_pkg_info_revision is deprecated.", DeprecationWarning) + warnings.warn("get_pkg_info_revision is deprecated.", EggInfoDeprecationWarning) if os.path.exists('PKG-INFO'): with io.open('PKG-INFO') as f: for line in f: @@ -704,3 +704,7 @@ def get_pkg_info_revision(): if match: return int(match.group(1)) return 0 + + +class EggInfoDeprecationWarning(SetuptoolsDeprecationWarning): + """Class for warning about deprecations in eggInfo in setupTools. Not ignored by default, unlike DeprecationWarning.""" -- cgit v1.2.1 From fcfe6ef3b7a49f68a9d732558ad80a7afe98aaa9 Mon Sep 17 00:00:00 2001 From: Shashank Singh Date: Sun, 28 Oct 2018 12:47:43 -0400 Subject: Add setup.py to egg-info by default Fixes GH issue #1506 --- setuptools/command/egg_info.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index e1022d31..d9fe3da3 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -575,6 +575,12 @@ class manifest_maker(sdist): self.filelist.extend(rcfiles) elif os.path.exists(self.manifest): self.read_manifest() + + if os.path.exists("setup.py"): + # setup.py should be included by default, even if it's not + # the script called to create the sdist + self.filelist.append("setup.py") + ei_cmd = self.get_finalized_command('egg_info') self.filelist.graft(ei_cmd.egg_info) -- 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/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 5d8f451e..a5c5a2fc 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -266,7 +266,7 @@ class egg_info(InfoCommon, Command): to the file. """ log.info("writing %s to %s", what, filename) - if six.PY3: + if not six.PY2: data = data.encode("utf-8") if not self.dry_run: f = open(filename, 'wb') -- cgit v1.2.1 From 3d4d8b9dde61b87271861b8c7ebeb168ac4fa72b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 19 Jan 2020 12:46:30 -0500 Subject: =?UTF-8?q?=F0=9F=91=B9=20Feed=20the=20hobgoblins=20(delint).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setuptools/command/egg_info.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index a5c5a2fc..7fa89541 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -33,6 +33,7 @@ from setuptools.glob import glob from setuptools.extern import packaging from setuptools import SetuptoolsDeprecationWarning + def translate_pattern(glob): """ Translate a file path glob like '*.txt' in to a regular expression. @@ -113,7 +114,7 @@ def translate_pattern(glob): pat += sep pat += r'\Z' - return re.compile(pat, flags=re.MULTILINE|re.DOTALL) + return re.compile(pat, flags=re.MULTILINE | re.DOTALL) class InfoCommon: @@ -637,7 +638,9 @@ def warn_depends_obsolete(cmd, basename, filename): def _write_requirements(stream, reqs): lines = yield_lines(reqs or ()) - append_cr = lambda line: line + '\n' + + def append_cr(line): + return line + '\n' lines = map(append_cr, lines) stream.writelines(lines) @@ -703,7 +706,8 @@ def get_pkg_info_revision(): Get a -r### off of PKG-INFO Version in case this is an sdist of a subversion revision. """ - warnings.warn("get_pkg_info_revision is deprecated.", EggInfoDeprecationWarning) + warnings.warn( + "get_pkg_info_revision is deprecated.", EggInfoDeprecationWarning) if os.path.exists('PKG-INFO'): with io.open('PKG-INFO') as f: for line in f: @@ -714,4 +718,4 @@ def get_pkg_info_revision(): class EggInfoDeprecationWarning(SetuptoolsDeprecationWarning): - """Class for warning about deprecations in eggInfo in setupTools. Not ignored by default, unlike DeprecationWarning.""" + """Deprecated behavior warning for EggInfo, bypassing suppression.""" -- cgit v1.2.1 From a9eb9e73def8ca6c469e59f1b008746e368ad4c1 Mon Sep 17 00:00:00 2001 From: Ram Rachum Date: Tue, 16 Jun 2020 13:31:12 +0300 Subject: Fix exception causes all over the codebase --- setuptools/command/egg_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 7fa89541..0855207c 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -208,11 +208,11 @@ class egg_info(InfoCommon, Command): list( parse_requirements(spec % (self.egg_name, self.egg_version)) ) - except ValueError: + except ValueError as e: raise distutils.errors.DistutilsOptionError( "Invalid distribution name or version syntax: %s-%s" % (self.egg_name, self.egg_version) - ) + ) from e if self.egg_base is None: dirs = self.distribution.package_dir -- 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/egg_info.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 0855207c..c957154a 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -16,9 +16,6 @@ import warnings import time import collections -from setuptools.extern import six -from setuptools.extern.six.moves import map - from setuptools import Command from setuptools.command.sdist import sdist from setuptools.command.sdist import walk_revctrl @@ -267,8 +264,7 @@ class egg_info(InfoCommon, Command): to the file. """ log.info("writing %s to %s", what, filename) - if not six.PY2: - data = data.encode("utf-8") + data = data.encode("utf-8") if not self.dry_run: f = open(filename, 'wb') f.write(data) @@ -647,7 +643,7 @@ def _write_requirements(stream, reqs): def write_requirements(cmd, basename, filename): dist = cmd.distribution - data = six.StringIO() + data = io.StringIO() _write_requirements(data, dist.install_requires) extras_require = dist.extras_require or {} for extra in sorted(extras_require): @@ -687,12 +683,12 @@ def write_arg(cmd, basename, filename, force=False): def write_entries(cmd, basename, filename): ep = cmd.distribution.entry_points - if isinstance(ep, six.string_types) or ep is None: + if isinstance(ep, str) or ep is None: data = ep elif ep is not None: data = [] for section, contents in sorted(ep.items()): - if not isinstance(contents, six.string_types): + if not isinstance(contents, str): contents = EntryPoint.parse_group(section, contents) contents = '\n'.join(sorted(map(str, contents.values()))) data.append('[%s]\n%s\n\n' % (section, contents)) -- cgit v1.2.1 From f67c1b099d24a37a0c65bf08f88cb46e261d2a61 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 6 Oct 2020 20:03:04 -0400 Subject: Extract method for maybe_tag. --- setuptools/command/egg_info.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index c957154a..0b7ad677 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -123,12 +123,17 @@ class InfoCommon: return safe_name(self.distribution.get_name()) def tagged_version(self): - version = self.distribution.get_version() - # egg_info may be called more than once for a distribution, - # in which case the version string already contains all tags. - if self.vtags and version.endswith(self.vtags): - return safe_version(version) - return safe_version(version + self.vtags) + return safe_version(self._maybe_tag(self.distribution.get_version())) + + def _maybe_tag(self, version): + """ + egg_info may be called more than once for a distribution, + in which case the version string already contains all tags. + """ + return ( + version if self.vtags and version.endswith(self.vtags) + else version + self.vtags + ) def tags(self): version = '' -- cgit v1.2.1 From 28b54b140cee8b33748833372ca6dbd7e305d94d Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 31 Dec 2020 17:56:00 +0100 Subject: Simplify `egg_info.FileList.process_template_line` --- setuptools/command/egg_info.py | 127 +++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 61 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 0b7ad677..8e34e4a2 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -8,6 +8,7 @@ from distutils.util import convert_path from distutils import log import distutils.errors import distutils.filelist +import functools import os import re import sys @@ -332,70 +333,74 @@ class FileList(_FileList): # patterns, (dir and patterns), or (dir_pattern). (action, patterns, dir, dir_pattern) = self._parse_template_line(line) + action_map = { + 'include': self.include, + 'exclude': self.exclude, + 'global-include': self.global_include, + 'global-exclude': self.global_exclude, + 'recursive-include': functools.partial( + self.recursive_include, dir, + ), + 'recursive-exclude': functools.partial( + self.recursive_exclude, dir, + ), + 'graft': self.graft, + 'prune': self.prune, + } + log_map = { + 'include': "warning: no files found matching '%s'", + 'exclude': ( + "warning: no previously-included files found " + "matching '%s'" + ), + 'global-include': ( + "warning: no files found matching '%s' " + "anywhere in distribution" + ), + 'global-exclude': ( + "warning: no previously-included files matching " + "'%s' found anywhere in distribution" + ), + 'recursive-include': ( + "warning: no files found matching '%s' " + "under directory '%s'" + ), + 'recursive-exclude': ( + "warning: no previously-included files matching " + "'%s' found under directory '%s'" + ), + 'graft': "warning: no directories found matching '%s'", + 'prune': "no previously-included directories found matching '%s'", + } + + try: + process_action = action_map[action] + except KeyError: + raise DistutilsInternalError( + "this cannot happen: invalid action '{action!s}'". + format(action=action), + ) + # OK, now we know that the action is valid and we have the # right number of words on the line for that action -- so we # can proceed with minimal error-checking. - if action == 'include': - self.debug_print("include " + ' '.join(patterns)) - for pattern in patterns: - if not self.include(pattern): - log.warn("warning: no files found matching '%s'", pattern) - - elif action == 'exclude': - self.debug_print("exclude " + ' '.join(patterns)) - for pattern in patterns: - if not self.exclude(pattern): - log.warn(("warning: no previously-included files " - "found matching '%s'"), pattern) - - elif action == 'global-include': - self.debug_print("global-include " + ' '.join(patterns)) - for pattern in patterns: - if not self.global_include(pattern): - log.warn(("warning: no files found matching '%s' " - "anywhere in distribution"), pattern) - - elif action == 'global-exclude': - self.debug_print("global-exclude " + ' '.join(patterns)) - for pattern in patterns: - if not self.global_exclude(pattern): - log.warn(("warning: no previously-included files matching " - "'%s' found anywhere in distribution"), - pattern) - - elif action == 'recursive-include': - self.debug_print("recursive-include %s %s" % - (dir, ' '.join(patterns))) - for pattern in patterns: - if not self.recursive_include(dir, pattern): - log.warn(("warning: no files found matching '%s' " - "under directory '%s'"), - pattern, dir) - - elif action == 'recursive-exclude': - self.debug_print("recursive-exclude %s %s" % - (dir, ' '.join(patterns))) - for pattern in patterns: - if not self.recursive_exclude(dir, pattern): - log.warn(("warning: no previously-included files matching " - "'%s' found under directory '%s'"), - pattern, dir) - - elif action == 'graft': - self.debug_print("graft " + dir_pattern) - if not self.graft(dir_pattern): - log.warn("warning: no directories found matching '%s'", - dir_pattern) - - elif action == 'prune': - self.debug_print("prune " + dir_pattern) - if not self.prune(dir_pattern): - log.warn(("no previously-included directories found " - "matching '%s'"), dir_pattern) - - else: - raise DistutilsInternalError( - "this cannot happen: invalid action '%s'" % action) + + action_is_recursive = action.startswith('recursive-') + if action in {'graft', 'prune'}: + patterns = [dir_pattern] + extra_log_args = (dir, ) if action_is_recursive else () + log_tmpl = log_map[action] + + self.debug_print( + ' '.join( + [action] + + ([dir] if action_is_recursive else []) + + patterns, + ) + ) + for pattern in patterns: + if not process_action(pattern): + log.warn(log_tmpl, pattern, *extra_log_args) def _remove_files(self, predicate): """ -- cgit v1.2.1 From fc891f5cf6d93ad533e2afb5e15a2952408ab358 Mon Sep 17 00:00:00 2001 From: Sviatoslav Sydorenko Date: Thu, 31 Dec 2020 13:08:18 +0100 Subject: Apply noqa C901 comments to overly complex code --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8e34e4a2..1f120b67 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -32,7 +32,7 @@ from setuptools.extern import packaging from setuptools import SetuptoolsDeprecationWarning -def translate_pattern(glob): +def translate_pattern(glob): # noqa: C901 # is too complex (14) # FIXME """ Translate a file path glob like '*.txt' in to a regular expression. This differs from fnmatch.translate which allows wildcards to match -- cgit v1.2.1 From ed07f8b124f75b43e27e5d636484898476a0be4f Mon Sep 17 00:00:00 2001 From: Dustin Ingram Date: Fri, 15 Jan 2021 14:19:14 -0600 Subject: Correctly handle normalized tags --- setuptools/command/egg_info.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 0b7ad677..066c2488 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -130,10 +130,12 @@ class InfoCommon: egg_info may be called more than once for a distribution, in which case the version string already contains all tags. """ - return ( - version if self.vtags and version.endswith(self.vtags) - else version + self.vtags - ) + # Remove the tags if they exist. The tags maybe have been normalized + # (e.g. turning .dev into .dev0) so we can't just compare strings + base_version = parse_version(version).base_version + + # Add the tags + return base_version + self.vtags def tags(self): version = '' -- cgit v1.2.1 From 5156278555fa20234db59f81097bee8cd7b5aaf4 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 16 Jan 2021 22:05:43 -0500 Subject: Revert "Merge pull request #2533 from pypa/fix/2529" This reverts commit ef457b2e4eb215ab9d730afbd61a10ed3b118d3c, reversing changes made to d2b1f7ebd6ebd57b4a50bc6660e93b31129bacb4. --- setuptools/command/egg_info.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index bb472036..1f120b67 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -131,12 +131,10 @@ class InfoCommon: egg_info may be called more than once for a distribution, in which case the version string already contains all tags. """ - # Remove the tags if they exist. The tags maybe have been normalized - # (e.g. turning .dev into .dev0) so we can't just compare strings - base_version = parse_version(version).base_version - - # Add the tags - return base_version + self.vtags + return ( + version if self.vtags and version.endswith(self.vtags) + else version + self.vtags + ) def tags(self): version = '' -- 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/egg_info.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 1f120b67..26ff9a4c 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -539,6 +539,7 @@ class manifest_maker(sdist): if not os.path.exists(self.manifest): self.write_manifest() # it must exist so it'll get in the list self.add_defaults() + self.add_license_files() if os.path.exists(self.template): self.read_template() self.prune_file_list() @@ -575,7 +576,6 @@ class manifest_maker(sdist): def add_defaults(self): sdist.add_defaults(self) - self.check_license() self.filelist.append(self.template) self.filelist.append(self.manifest) rcfiles = list(walk_revctrl()) @@ -592,6 +592,13 @@ class manifest_maker(sdist): ei_cmd = self.get_finalized_command('egg_info') self.filelist.graft(ei_cmd.egg_info) + def add_license_files(self): + license_files = self.distribution.metadata.license_files_computed + for lf in license_files: + log.info("adding license file '%s'", lf) + pass + self.filelist.extend(license_files) + def prune_file_list(self): build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() -- cgit v1.2.1 From b16725ac388b6a0bab6c0ff79d809559589be248 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Thu, 20 May 2021 01:24:01 +0200 Subject: Remove license_files_computed field --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 26ff9a4c..67259c7c 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -593,7 +593,7 @@ class manifest_maker(sdist): self.filelist.graft(ei_cmd.egg_info) def add_license_files(self): - license_files = self.distribution.metadata.license_files_computed + license_files = self.distribution.metadata.license_files or [] for lf in license_files: log.info("adding license file '%s'", lf) pass -- cgit v1.2.1 From 482e8e7687e3272ca2d0b1d5d73b92c3219f4576 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Sat, 17 Apr 2021 21:33:23 +0200 Subject: Overwrite exlude from MANIFEST with license_files option * needed for 'License-File' metadata, as this is written before MANIFEST is read --- setuptools/command/egg_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 67259c7c..18b81340 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -539,9 +539,9 @@ class manifest_maker(sdist): if not os.path.exists(self.manifest): self.write_manifest() # it must exist so it'll get in the list self.add_defaults() - self.add_license_files() if os.path.exists(self.template): self.read_template() + self.add_license_files() self.prune_file_list() self.filelist.sort() self.filelist.remove_duplicates() -- 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/egg_info.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 18b81340..ff009861 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -608,6 +608,17 @@ class manifest_maker(sdist): self.filelist.exclude_pattern(r'(^|' + sep + r')(RCS|CVS|\.svn)' + sep, is_regex=1) + def _safe_data_files(self, build_py): + """ + The parent class implementation of this method (``sdist``) will try to + include data files, which might cause recursion problems, when + ``include_package_data=True``. + + Therefore we have to avoid triggering any attempt of analyzing/building + the manifest again. + """ + return build_py.get_data_files_without_manifest() + def write_file(filename, contents): """Create a file with the specified name and write 'contents' (a -- cgit v1.2.1 From 2d38be3259311220d069996b3a906f171dfddafc Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 2 Nov 2021 20:54:51 -0400 Subject: Reformat docstring and rewrite in imperative voice. --- setuptools/command/egg_info.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index ff009861..4165c35e 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -610,12 +610,13 @@ class manifest_maker(sdist): def _safe_data_files(self, build_py): """ - The parent class implementation of this method (``sdist``) will try to - include data files, which might cause recursion problems, when + The parent class implementation of this method + (``sdist``) will try to include data files, which + might cause recursion problems when ``include_package_data=True``. - Therefore we have to avoid triggering any attempt of analyzing/building - the manifest again. + Therefore, avoid triggering any attempt of + analyzing/building the manifest again. """ return build_py.get_data_files_without_manifest() -- cgit v1.2.1 From 08235e88d10179c89ed80a4dd9bf2d18c76b478d Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 4 Nov 2021 12:30:37 +0000 Subject: Handle custom build_py inheriting from distutils According to #2849, some projects, including important data-science packages rely on `distutils` when creating custom commands, instead of extending the ones provided by setuptools. This change should accomodate this use case, while also warning the users to migrate. --- setuptools/command/egg_info.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 4165c35e..8ae27d87 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -618,7 +618,15 @@ class manifest_maker(sdist): Therefore, avoid triggering any attempt of analyzing/building the manifest again. """ - return build_py.get_data_files_without_manifest() + if hasattr(build_py, 'get_data_files_without_manifest'): + return build_py.get_data_files_without_manifest() + + log.warn( + "Custom 'build_py' does not implement " + "'get_data_files_without_manifest'.\nPlease extend command classes" + " from setuptools instead of distutils." + ) + return build_py.get_data_files() def write_file(filename, contents): -- cgit v1.2.1 From e2220331136c3a60b8d70a6b4eaad05816c9b637 Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Fri, 5 Nov 2021 14:14:29 +0000 Subject: Use warning instead of log for distutils command As discussed in #2855, using an actual warning instead of the logger allow users to control what gets displayed via warning filters. --- setuptools/command/egg_info.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'setuptools/command/egg_info.py') diff --git a/setuptools/command/egg_info.py b/setuptools/command/egg_info.py index 8ae27d87..f2210292 100644 --- a/setuptools/command/egg_info.py +++ b/setuptools/command/egg_info.py @@ -621,10 +621,11 @@ class manifest_maker(sdist): if hasattr(build_py, 'get_data_files_without_manifest'): return build_py.get_data_files_without_manifest() - log.warn( + warnings.warn( "Custom 'build_py' does not implement " "'get_data_files_without_manifest'.\nPlease extend command classes" - " from setuptools instead of distutils." + " from setuptools instead of distutils.", + SetuptoolsDeprecationWarning ) return build_py.get_data_files() -- cgit v1.2.1