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