From b4aecb449c912f0b405c687c763b9976c4cd884d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 25 Jul 2011 17:51:23 -0400 Subject: Fix issue where easy_install fails on Python 3 on windows installer. Fixes #212 --HG-- branch : distribute extra : rebase_source : 1920a8d261fa7918d9d3813a104cf2ed11878c7c --- setuptools/command/easy_install.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 58e7ab39..c1bae1c0 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1425,7 +1425,16 @@ def extract_wininst_cfg(dist_filename): f.seek(prepended-(12+cfglen)) cfg = ConfigParser.RawConfigParser({'version':'','target_version':''}) try: - cfg.readfp(StringIO.StringIO(f.read(cfglen).split(chr(0),1)[0])) + part = f.read(cfglen) + # part is in bytes, but we need to read up to the first null + # byte. + null_byte = bytes([0]) if sys.version_info >= (2,6) else chr(0) + config, = part.split(null_byte, 1) + # Now the config is in bytes, but on Python 3, it must be + # unicode for the RawConfigParser, so decode it. Is this the + # right encoding? + config = config.decode('ascii') + cfg.readfp(StringIO.StringIO(config)) except ConfigParser.Error: return None if not cfg.has_section('metadata') or not cfg.has_section('Setup'): -- cgit v1.2.3 From 9b09f6d159a7d5f4ffeaf9de4710ee869258fed7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 1 Aug 2011 04:38:03 -0400 Subject: Corrected ValueError introduced in the last commit due to incorrect use of arg unpacking --HG-- branch : distribute extra : rebase_source : 0ebd905145e32bf072c00bc663dde8716ad4b88a --- setuptools/command/easy_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index c1bae1c0..f44e8d4a 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1429,7 +1429,7 @@ def extract_wininst_cfg(dist_filename): # part is in bytes, but we need to read up to the first null # byte. null_byte = bytes([0]) if sys.version_info >= (2,6) else chr(0) - config, = part.split(null_byte, 1) + config = part.split(null_byte, 1)[0] # Now the config is in bytes, but on Python 3, it must be # unicode for the RawConfigParser, so decode it. Is this the # right encoding? -- cgit v1.2.3 From edaefa4982e0aac7b07048c4761446ed66fec524 Mon Sep 17 00:00:00 2001 From: Alex Clark Date: Sun, 14 Aug 2011 19:18:17 -0400 Subject: Remove extraneous 2nd argument in call to open_url, apparently intended to issue a warning (looks like open_url takes an optional `warning` argument, but I couldn't get that to work either). Fixes #135. This fix is better than the status quo, but probably not as good as issuing a warning instead of failure. --HG-- branch : distribute extra : rebase_source : 39889bf4dd21abbd57207bfafe6f8bad68b1e46f --- setuptools/package_index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index f064b110..c9e3d637 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -198,7 +198,7 @@ class PackageIndex(Environment): return self.info("Reading %s", url) - f = self.open_url(url, "Download error: %s -- Some packages may not be found!") + f = self.open_url(url) if f is None: return self.fetched_urls[url] = self.fetched_urls[f.url] = True -- cgit v1.2.3 From e6a12bbf1a51bb572145fd46715e2a20e54bfc52 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 17 Aug 2011 03:44:27 -0400 Subject: Include url in warning when processing URL. Fixes #135. --HG-- branch : distribute extra : rebase_source : 1241e1cb548adad562fcf61ce33538712a64aaed --- setuptools/package_index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index f064b110..1dccabcb 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -198,7 +198,7 @@ class PackageIndex(Environment): return self.info("Reading %s", url) - f = self.open_url(url, "Download error: %s -- Some packages may not be found!") + f = self.open_url(url, "Download error on %s: %%s -- Some packages may not be found!" % url) if f is None: return self.fetched_urls[url] = self.fetched_urls[f.url] = True -- cgit v1.2.3 From 2e6300e37739b614e8b4286a9c6f534305c1c005 Mon Sep 17 00:00:00 2001 From: Tarek Ziade Date: Sat, 20 Aug 2011 11:52:00 +0200 Subject: don't use ternary operator - fixes #225 --HG-- branch : distribute extra : rebase_source : ecff177a6be463bfc55c40deec0a3f1e2804e895 --- setuptools/command/easy_install.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index f44e8d4a..263b429c 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1428,7 +1428,10 @@ def extract_wininst_cfg(dist_filename): part = f.read(cfglen) # part is in bytes, but we need to read up to the first null # byte. - null_byte = bytes([0]) if sys.version_info >= (2,6) else chr(0) + if sys.version_info >= (2,6): + null_byte = bytes([0]) + else: + chr(0) config = part.split(null_byte, 1)[0] # Now the config is in bytes, but on Python 3, it must be # unicode for the RawConfigParser, so decode it. Is this the -- cgit v1.2.3 From 05564db286ce0b50ea5296adea3e462793dfcbe1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 20 Aug 2011 07:51:48 -0600 Subject: Fix NameError on Python 2.4, 2.5; reference #225 --HG-- branch : distribute extra : rebase_source : b2c739a08485c49b0735f5f7544f354b46ad1d12 --- setuptools/command/easy_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 263b429c..853753c1 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1431,7 +1431,7 @@ def extract_wininst_cfg(dist_filename): if sys.version_info >= (2,6): null_byte = bytes([0]) else: - chr(0) + null_byte = chr(0) config = part.split(null_byte, 1)[0] # Now the config is in bytes, but on Python 3, it must be # unicode for the RawConfigParser, so decode it. Is this the -- cgit v1.2.3 From b568b2ffb5d4e5c767452fce2353adec70d93a00 Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Tue, 30 Aug 2011 12:34:37 -0400 Subject: First stab at a fix. The hack that allows it to work is that it allows the easy_install command to take a '-' argument which simply means 'don't run', so that arguments can be passed to the easy_install command from the comannd line without running it. --HG-- branch : distribute extra : rebase_source : 6eff3586cbcf36e846b3419218979d03079d1bcf --- setuptools/command/easy_install.py | 22 +++++++++++++++++++++- setuptools/dist.py | 3 ++- setuptools/package_index.py | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 853753c1..3f1b4228 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -267,7 +267,8 @@ class easy_install(Command): ) else: self.all_site_dirs.append(normalize_path(d)) - if not self.editable: self.check_site_dir() + if not self.editable and self.args != ['-']: + self.check_site_dir() self.index_url = self.index_url or "http://pypi.python.org/simple" self.shadow_path = self.all_site_dirs[:] for path_item in self.install_dir, normalize_path(self.script_dir): @@ -338,6 +339,11 @@ class easy_install(Command): 'install_scripts', 'install_data',]) def run(self): + if self.args == ['-']: + # A single dash as an argument means 'do nothing' and is just a way + # to pass arguments to the easy_install command without running it + return + if self.verbose != self.distribution.verbose: log.set_verbosity(self.verbose) try: @@ -1079,6 +1085,20 @@ See the setuptools documentation for the "develop" command for more info. ) try: args.append(dist_dir) + ei_opts = self.distribution.get_option_dict('easy_install').copy() + keep = ( + 'find_links', 'site_dirs', 'index_url', 'optimize', + 'site_dirs', 'allow_hosts' + ) + for key in ei_opts.keys(): + if key not in keep: + del ei_opts[key] + if ei_opts: + args.append('easy_install') + for key, val in ei_opts.iteritems(): + args.append('--%s=%s' % (key.replace('_', '-'), val[1])) + args.append('-') + self.run_setup(setup_script, setup_base, args) all_eggs = Environment([dist_dir]) eggs = [] diff --git a/setuptools/dist.py b/setuptools/dist.py index 0ad18122..204dcdfa 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -269,8 +269,9 @@ class Distribution(_Distribution): cmd.package_index.to_scan = [] except AttributeError: from setuptools.command.easy_install import easy_install - dist = self.__class__({'script_args':['easy_install']}) + dist = self.__class__() dist.parse_config_files() + dist.parse_command_line() opts = dist.get_option_dict('easy_install') keep = ( 'find_links', 'site_dirs', 'index_url', 'optimize', diff --git a/setuptools/package_index.py b/setuptools/package_index.py index bb0ae129..1dccabcb 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -842,4 +842,4 @@ def local_open(url): -# this line is a kludge to keep the trailing blank lines for pje's editor \ No newline at end of file +# this line is a kludge to keep the trailing blank lines for pje's editor -- cgit v1.2.3 From 0d6b0fdd59f5fb29c06ed335fc7597951c5f277f Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Tue, 30 Aug 2011 13:03:25 -0400 Subject: Fix unintended addition of newline --HG-- branch : distribute extra : rebase_source : 9ba9d12380a73ae3a0908a0015b887dbe26bd7ae --- setuptools/package_index.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 1dccabcb..bb0ae129 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -842,4 +842,4 @@ def local_open(url): -# this line is a kludge to keep the trailing blank lines for pje's editor +# this line is a kludge to keep the trailing blank lines for pje's editor \ No newline at end of file -- cgit v1.2.3 From 4593c7e5cdc0e467a1c1957a0c864db804c4147a Mon Sep 17 00:00:00 2001 From: guyroz Date: Fri, 16 Sep 2011 23:10:06 +0300 Subject: Issue #237: fixing test on Python2.3 Added an _assertIn method (copied from a more recent version of unittest) and replaced the calls to assertTrue, which does not exist in Python 2.3 --HG-- branch : distribute extra : rebase_source : a8ba9e47fdcbc2dbee8e801b5d1d5d84c989266f --- setuptools/tests/test_resources.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py index c10ca210..227ecfdf 100644 --- a/setuptools/tests/test_resources.py +++ b/setuptools/tests/test_resources.py @@ -8,6 +8,16 @@ try: frozenset except NameError: from sets import ImmutableSet as frozenset +def safe_repr(obj, short=False): + """ copied from Python2.7""" + try: + result = repr(obj) + except Exception: + result = object.__repr__(obj) + if not short or len(result) < _MAX_LENGTH: + return result + return result[:_MAX_LENGTH] + ' [truncated]...' + class Metadata(EmptyProvider): """Mock object to return metadata as if from an on-disk distribution""" @@ -580,6 +590,13 @@ class NamespaceTests(TestCase): pkg_resources._namespace_packages = self._ns_pkgs.copy() sys.path = self._prev_sys_path[:] + def _assertIn(self, member, container): + """ assertIn and assertTrue does not exist in Python2.3""" + if member not in container: + standardMsg = '%s not found in %s' % (safe_repr(member), + safe_repr(container)) + self.fail(self._formatMessage(msg, standardMsg)) + def test_two_levels_deep(self): """ Test nested namespace packages @@ -603,13 +620,13 @@ class NamespaceTests(TestCase): pkg2_init.write(ns_str) pkg2_init.close() import pkg1 - self.assertTrue("pkg1" in pkg_resources._namespace_packages.keys()) + self._assertIn("pkg1", pkg_resources._namespace_packages.keys()) try: import pkg1.pkg2 except ImportError, e: self.fail("Distribute tried to import the parent namespace package") # check the _namespace_packages dict - self.assertTrue("pkg1.pkg2" in pkg_resources._namespace_packages.keys()) + self._assertIn("pkg1.pkg2", pkg_resources._namespace_packages.keys()) self.assertEqual(pkg_resources._namespace_packages["pkg1"], ["pkg1.pkg2"]) # check the __path__ attribute contains both paths self.assertEqual(pkg1.pkg2.__path__, [ -- cgit v1.2.3 From c0032c0de589c7f8f633314cae891bbb2191dbce Mon Sep 17 00:00:00 2001 From: guyroz Date: Sat, 17 Sep 2011 16:20:05 +0300 Subject: Issue #208: fixing parse_version and post-release tags including tests --HG-- branch : distribute extra : rebase_source : f953ba35614c338161249d6d74c7cda08acdf32b --- setuptools/tests/test_resources.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py index 227ecfdf..3e0309f1 100644 --- a/setuptools/tests/test_resources.py +++ b/setuptools/tests/test_resources.py @@ -477,14 +477,13 @@ class ParseTests(TestCase): p1, p2 = parse_version(s1),parse_version(s2) self.assertEqual(p1,p2, (s1,s2,p1,p2)) - c('1.2-rc1', '1.2rc1') c('0.4', '0.4.0') c('0.4.0.0', '0.4.0') c('0.4.0-0', '0.4-0') c('0pl1', '0.0pl1') c('0pre1', '0.0c1') c('0.0.0preview1', '0c1') - c('0.0c1', '0-rc1') + c('0.0c1', '0rc1') c('1.2a1', '1.2.a.1'); c('1.2...a', '1.2a') def testVersionOrdering(self): @@ -493,11 +492,14 @@ class ParseTests(TestCase): self.assert_(p1 Date: Sat, 17 Sep 2011 16:24:50 +0300 Subject: Issue #207: updated executables for 32bit and 64bit --HG-- branch : distribute extra : rebase_source : feb8ad4f829140739feeba915b835dbd26ab1b80 --- setuptools/cli-32.exe | Bin 0 -> 69632 bytes setuptools/cli-64.exe | Bin 0 -> 75264 bytes setuptools/cli.exe | Bin 7168 -> 69632 bytes setuptools/gui-32.exe | Bin 0 -> 65536 bytes setuptools/gui-64.exe | Bin 0 -> 75264 bytes setuptools/gui.exe | Bin 7168 -> 7168 bytes 6 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 setuptools/cli-32.exe create mode 100644 setuptools/cli-64.exe create mode 100644 setuptools/gui-32.exe create mode 100644 setuptools/gui-64.exe (limited to 'setuptools') diff --git a/setuptools/cli-32.exe b/setuptools/cli-32.exe new file mode 100644 index 00000000..9b7717b7 Binary files /dev/null and b/setuptools/cli-32.exe differ diff --git a/setuptools/cli-64.exe b/setuptools/cli-64.exe new file mode 100644 index 00000000..265585af Binary files /dev/null and b/setuptools/cli-64.exe differ diff --git a/setuptools/cli.exe b/setuptools/cli.exe index 8906ff77..9b7717b7 100644 Binary files a/setuptools/cli.exe and b/setuptools/cli.exe differ diff --git a/setuptools/gui-32.exe b/setuptools/gui-32.exe new file mode 100644 index 00000000..3f64af7d Binary files /dev/null and b/setuptools/gui-32.exe differ diff --git a/setuptools/gui-64.exe b/setuptools/gui-64.exe new file mode 100644 index 00000000..3ab4378e Binary files /dev/null and b/setuptools/gui-64.exe differ diff --git a/setuptools/gui.exe b/setuptools/gui.exe index 474838d5..8906ff77 100644 Binary files a/setuptools/gui.exe and b/setuptools/gui.exe differ -- cgit v1.2.3 From dff9e6b6bc0bd04180d00df52eb74340fa3df580 Mon Sep 17 00:00:00 2001 From: guyroz Date: Sat, 17 Sep 2011 16:27:04 +0300 Subject: Issue #238: using 65bit wrappers on Python64bit on windows --HG-- branch : distribute extra : rebase_source : c0f80f1633017229ec77f4cc1d7c56e86aba3a84 --- setuptools/command/easy_install.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 853753c1..4700fe0e 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -42,6 +42,10 @@ __all__ = [ import site HAS_USER_SITE = not sys.version < "2.6" and site.ENABLE_USER_SITE +import struct +def is_64bit(): + return struct.calcsize("P") == 8 + def samefile(p1,p2): if hasattr(os.path,'samefile') and ( os.path.exists(p1) and os.path.exists(p2) @@ -1781,7 +1785,10 @@ def get_script_args(dist, executable=sys_executable, wininst=False): ext, launcher = '-script.py', 'cli.exe' old = ['.py','.pyc','.pyo'] new_header = re.sub('(?i)pythonw.exe','python.exe',header) - + if is_64bit(): + launcher = launcher.replace(".", "-64.") + else: + launcher = launcher.replace(".", "-32.") if os.path.exists(new_header[2:-1]) or sys.platform!='win32': hdr = new_header else: -- cgit v1.2.3 From 8b25dd9f9edc2f2506efb5a471f2facdf4082a31 Mon Sep 17 00:00:00 2001 From: guyroz Date: Mon, 19 Sep 2011 23:41:21 +0300 Subject: Fixing regression tests on Windows: #241, #240, #239 --HG-- branch : distribute extra : rebase_source : fb5248f9bd280ccc075c1e93dd74379bf06d10f7 --- setuptools/tests/test_easy_install.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 85616605..1ae0ba70 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -67,7 +67,7 @@ class TestEasyInstallTest(unittest.TestCase): old_platform = sys.platform try: - name, script = get_script_args(dist).next() + name, script = get_script_args(dist).next()[0:2] finally: sys.platform = old_platform @@ -141,9 +141,13 @@ class TestPTHFileWriter(unittest.TestCase): self.assert_(pth.dirty) def test_add_from_site_is_ignored(self): - pth = PthDistributions('does-not_exist', ['/test/location/does-not-have-to-exist']) + if os.name != 'nt': + location = '/test/location/does-not-have-to-exist' + else: + location = 'c:\\does_not_exist' + pth = PthDistributions('does-not_exist', [location, ]) self.assert_(not pth.dirty) - pth.add(PRDistribution('/test/location/does-not-have-to-exist')) + pth.add(PRDistribution(location)) self.assert_(not pth.dirty) @@ -221,7 +225,7 @@ class TestUserInstallTest(unittest.TestCase): sys.path.append(target) old_ppath = os.environ.get('PYTHONPATH') - os.environ['PYTHONPATH'] = ':'.join(sys.path) + os.environ['PYTHONPATH'] = os.path.pathsep.join(sys.path) try: dist = Distribution() dist.script_name = 'setup.py' @@ -234,8 +238,13 @@ class TestUserInstallTest(unittest.TestCase): self.assertEquals(res.location, new_location) finally: sys.path.remove(target) - shutil.rmtree(new_location) - shutil.rmtree(target) + for basedir in [new_location, target, ]: + if not os.path.exists(basedir) or not os.path.isdir(basedir): + continue + try: + shutil.rmtree(basedir) + except: + pass if old_ppath is not None: os.environ['PYTHONPATH'] = old_ppath else: -- cgit v1.2.3 From 3b8de2876b38e5b2afc4210e6d37c5b90fecb8a4 Mon Sep 17 00:00:00 2001 From: guyroz Date: Tue, 20 Sep 2011 00:05:59 +0300 Subject: fixing regression -- generator syntax on python3 --HG-- branch : distribute extra : rebase_source : 3708d2ca5f9a8fc2398204dbcb3febb6d61e134b --- setuptools/tests/test_easy_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 1ae0ba70..4150ad10 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -67,7 +67,7 @@ class TestEasyInstallTest(unittest.TestCase): old_platform = sys.platform try: - name, script = get_script_args(dist).next()[0:2] + name, script = [i for i in get_script_args(dist).next()][0:2] finally: sys.platform = old_platform -- cgit v1.2.3 From 51e06f7936437e869dd4ad29f052435e3d814e61 Mon Sep 17 00:00:00 2001 From: guyroz Date: Tue, 20 Sep 2011 10:07:23 +0300 Subject: copying gui-32.exe to gui.exe --HG-- branch : distribute extra : rebase_source : 36d39326b09155e123f2ea69c8a2ab493e761126 --- setuptools/gui.exe | Bin 7168 -> 65536 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'setuptools') diff --git a/setuptools/gui.exe b/setuptools/gui.exe index 8906ff77..3f64af7d 100644 Binary files a/setuptools/gui.exe and b/setuptools/gui.exe differ -- cgit v1.2.3 From 4f5c1303ca73fdb1860bf00ee9a37a2c1b6fe294 Mon Sep 17 00:00:00 2001 From: guyroz Date: Tue, 20 Sep 2011 16:40:58 +0300 Subject: Issue #244 raises ValueError in upload and register commands if using a section without a repository value --HG-- branch : distribute extra : rebase_source : e57437a8ac03832ed8170c902996423a27235856 --- setuptools/command/__init__.py | 5 --- setuptools/command/register.py | 60 ++++++++++++++++++++++++++++++++ setuptools/command/upload.py | 78 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 136 insertions(+), 7 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/__init__.py b/setuptools/command/__init__.py index 152406b3..a601e2d3 100644 --- a/setuptools/command/__init__.py +++ b/setuptools/command/__init__.py @@ -8,13 +8,8 @@ __all__ = [ from setuptools.command import install_scripts import sys -if sys.version>='2.5': - # In Python 2.5 and above, distutils includes its own upload command - __all__.remove('upload') - from distutils.command.bdist import bdist - if 'egg' not in bdist.format_commands: bdist.format_command['egg'] = ('bdist_egg', "Python .egg file") bdist.format_commands.append('egg') diff --git a/setuptools/command/register.py b/setuptools/command/register.py index 3b2e0859..874401a5 100755 --- a/setuptools/command/register.py +++ b/setuptools/command/register.py @@ -1,4 +1,6 @@ from distutils.command.register import register as _register +from ConfigParser import ConfigParser +import os class register(_register): __doc__ = _register.__doc__ @@ -6,5 +8,63 @@ class register(_register): def run(self): # Make sure that we are using valid current name/version info self.run_command('egg_info') + self._section_name = self.repository _register.run(self) + def _read_pypirc(self): + """Reads the .pypirc file.""" + rc = self._get_rc_file() + if os.path.exists(rc): + repository = self.repository + config = ConfigParser() + config.read(rc) + sections = config.sections() + if 'distutils' in sections: + # let's get the list of servers + index_servers = config.get('distutils', 'index-servers') + _servers = [server.strip() for server in + index_servers.split('\n') + if server.strip() != ''] + if _servers == []: + # nothing set, let's try to get the default pypi + if 'pypi' in sections: + _servers = ['pypi'] + else: + # the file is not properly defined, returning + # an empty dict + return {} + for server in _servers: + current = {'server': server} + current['username'] = config.get(server, 'username') + + # optional params + for key, default in (('repository', + None), + ('realm', self.DEFAULT_REALM), + ('password', None)): + if config.has_option(server, key): + current[key] = config.get(server, key) + else: + current[key] = default + if (current['server'] == repository or + current['repository'] == repository): + return current + elif 'server-login' in sections: + # old format + server = 'server-login' + if config.has_option(server, 'repository'): + repository = config.get(server, 'repository') + else: + repository = None + return {'username': config.get(server, 'username'), + 'password': config.get(server, 'password'), + 'repository': repository, + 'server': server, + 'realm': self.DEFAULT_REALM} + + return {} + + def _set_config(self): + _register._set_config(self) + if self.repository is None: + raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index 1f49745e..042fcbb5 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -2,6 +2,7 @@ Implements the Distutils 'upload' subcommand (upload package to PyPI).""" + from distutils.errors import * from distutils.core import Command from distutils.spawn import spawn @@ -11,6 +12,7 @@ try: except ImportError: from md5 import md5 import os +import sys import socket import platform import ConfigParser @@ -19,7 +21,7 @@ import base64 import urlparse import cStringIO as StringIO -class upload(Command): +class _upload(Command): description = "upload binary package to PyPI" @@ -65,7 +67,7 @@ class upload(Command): if not self.password: self.password = config.get('server-login', 'password') if not self.repository: - self.repository = self.DEFAULT_REPOSITORY + raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) def run(self): if not self.distribution.dist_files: @@ -181,3 +183,75 @@ class upload(Command): log.ERROR) if self.show_response: print '-'*75, r.read(), '-'*75 + +if sys.version >= "2.5": + from distutils.command.upload import upload as distutils_upload + class upload(distutils_upload): + + def run(self): + self._section_name = self.repository + distutils_upload.run(self) + + def _read_pypirc(self): + """Reads the .pypirc file.""" + self._section_name = self.repository + rc = self._get_rc_file() + if os.path.exists(rc): + repository = self.repository + config = ConfigParser.ConfigParser() + config.read(rc) + sections = config.sections() + if 'distutils' in sections: + # let's get the list of servers + index_servers = config.get('distutils', 'index-servers') + _servers = [server.strip() for server in + index_servers.split('\n') + if server.strip() != ''] + if _servers == []: + # nothing set, let's try to get the default pypi + if 'pypi' in sections: + _servers = ['pypi'] + else: + # the file is not properly defined, returning + # an empty dict + return {} + for server in _servers: + current = {'server': server} + current['username'] = config.get(server, 'username') + + # optional params + for key, default in (('repository', + None), + ('realm', self.DEFAULT_REALM), + ('password', None)): + if config.has_option(server, key): + current[key] = config.get(server, key) + else: + current[key] = default + if (current['server'] == repository or + current['repository'] == repository): + return current + elif 'server-login' in sections: + # old format + server = 'server-login' + if config.has_option(server, 'repository'): + repository = config.get(server, 'repository') + else: + repository = None + return {'username': config.get(server, 'username'), + 'password': config.get(server, 'password'), + 'repository': repository, + 'server': server, + 'realm': self.DEFAULT_REALM} + + return {} + + def finalize_options(self): + distutils_upload.finalize_options(self) + if not self.repository: + raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) + + +else: + upload = _upload + -- cgit v1.2.3 From d36c067b3247bf7dc3102051b088fe744ac74ae0 Mon Sep 17 00:00:00 2001 From: guyroz Date: Thu, 22 Sep 2011 20:50:45 +0300 Subject: Issue #246 --HG-- branch : distribute extra : rebase_source : e14172505ff8938f00f51de4f29a8fb2834ac933 --- setuptools/command/upload.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index 042fcbb5..1b708943 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -228,8 +228,10 @@ if sys.version >= "2.5": current[key] = config.get(server, key) else: current[key] = default + # Issue #246, handling url ambiguity if (current['server'] == repository or - current['repository'] == repository): + current['repository'] == repository or + (current['repository'] == "http://www.python.org/pypi" and repository == self.DEFAULT_REPOSITORY)): return current elif 'server-login' in sections: # old format -- cgit v1.2.3 From 694a9231f495a82cf62340f9b98eb4fd7272ecf3 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Tue, 4 Oct 2011 11:01:49 -0400 Subject: Added options to exclude 2to3 fixers. Fixes #249 --HG-- branch : distribute extra : rebase_source : 2033bcdd4c2e78e0e03796f1f9cf6d6e9a59fc21 --- setuptools/command/build_py.py | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index a01e2843..d53960fe 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -28,13 +28,8 @@ try: if not files: return log.info("Fixing "+" ".join(files)) - if not self.fixer_names: - self.fixer_names = [] - for p in setuptools.lib2to3_fixer_packages: - self.fixer_names.extend(get_fixers_from_package(p)) - if self.distribution.use_2to3_fixers is not None: - for p in self.distribution.use_2to3_fixers: - self.fixer_names.extend(get_fixers_from_package(p)) + self.__build_fixer_names() + self.__exclude_fixers() if doctests: if setuptools.run_2to3_on_doctests: r = DistutilsRefactoringTool(self.fixer_names) @@ -42,6 +37,25 @@ try: else: _Mixin2to3.run_2to3(self, files) + def __build_fixer_names(self): + if self.fixer_names: return + self.fixer_names = [] + for p in setuptools.lib2to3_fixer_packages: + self.fixer_names.extend(get_fixers_from_package(p)) + if self.distribution.use_2to3_fixers is not None: + for p in self.distribution.use_2to3_fixers: + self.fixer_names.extend(get_fixers_from_package(p)) + + def __exclude_fixers(self): + excluded_fixers = getattr(self, 'exclude_fixers', []) + if self.distribution.use_2to3_exclude_fixers is not None: + excluded_fixers.extend(self.distribution.use_2to3_exclude_fixers) + for fixer_name in excluded_fixers: + if fixer_name not in self.fixer_names: + log.warn("Excluded fixer %s not found", fixer_name) + continue + self.fixer_names.remove(fixer_name) + except ImportError: class Mixin2to3: def run_2to3(self, files, doctests=True): -- cgit v1.2.3 From 257f23372a797ede9e14ae3e62c8319896943857 Mon Sep 17 00:00:00 2001 From: "Guy Rozendorn (guyr@infinidat.com)" Date: Fri, 7 Oct 2011 18:55:31 +0200 Subject: Revert 8d1cb51a01b6 because of issue #250 --HG-- branch : distribute extra : rebase_source : 842a0d796e6e3cd5ecf312dd5c3ff2bb35d601a5 --- setuptools/command/upload.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index 1b708943..f2e0b2e1 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -228,10 +228,7 @@ if sys.version >= "2.5": current[key] = config.get(server, key) else: current[key] = default - # Issue #246, handling url ambiguity - if (current['server'] == repository or - current['repository'] == repository or - (current['repository'] == "http://www.python.org/pypi" and repository == self.DEFAULT_REPOSITORY)): + if (current['server'] == repository: return current elif 'server-login' in sections: # old format -- cgit v1.2.3 From d5df4531433b2031186ed2a8b335892b3600912b Mon Sep 17 00:00:00 2001 From: "Guy Rozendorn (guyr@infinidat.com)" Date: Fri, 7 Oct 2011 19:08:55 +0200 Subject: Reverting 1a1ab844f03e due to issue 250 --HG-- branch : distribute extra : rebase_source : 0dca5e604c96429f07c4d7786d3a0991c42c129d --- setuptools/command/__init__.py | 4 +++ setuptools/command/register.py | 60 --------------------------------- setuptools/command/upload.py | 76 ++---------------------------------------- 3 files changed, 6 insertions(+), 134 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/__init__.py b/setuptools/command/__init__.py index a601e2d3..b063fa19 100644 --- a/setuptools/command/__init__.py +++ b/setuptools/command/__init__.py @@ -8,6 +8,10 @@ __all__ = [ from setuptools.command import install_scripts import sys +if sys.version>='2.5': + # In Python 2.5 and above, distutils includes its own upload command + __all__.remove('upload') + from distutils.command.bdist import bdist if 'egg' not in bdist.format_commands: diff --git a/setuptools/command/register.py b/setuptools/command/register.py index 874401a5..3b2e0859 100755 --- a/setuptools/command/register.py +++ b/setuptools/command/register.py @@ -1,6 +1,4 @@ from distutils.command.register import register as _register -from ConfigParser import ConfigParser -import os class register(_register): __doc__ = _register.__doc__ @@ -8,63 +6,5 @@ class register(_register): def run(self): # Make sure that we are using valid current name/version info self.run_command('egg_info') - self._section_name = self.repository _register.run(self) - def _read_pypirc(self): - """Reads the .pypirc file.""" - rc = self._get_rc_file() - if os.path.exists(rc): - repository = self.repository - config = ConfigParser() - config.read(rc) - sections = config.sections() - if 'distutils' in sections: - # let's get the list of servers - index_servers = config.get('distutils', 'index-servers') - _servers = [server.strip() for server in - index_servers.split('\n') - if server.strip() != ''] - if _servers == []: - # nothing set, let's try to get the default pypi - if 'pypi' in sections: - _servers = ['pypi'] - else: - # the file is not properly defined, returning - # an empty dict - return {} - for server in _servers: - current = {'server': server} - current['username'] = config.get(server, 'username') - - # optional params - for key, default in (('repository', - None), - ('realm', self.DEFAULT_REALM), - ('password', None)): - if config.has_option(server, key): - current[key] = config.get(server, key) - else: - current[key] = default - if (current['server'] == repository or - current['repository'] == repository): - return current - elif 'server-login' in sections: - # old format - server = 'server-login' - if config.has_option(server, 'repository'): - repository = config.get(server, 'repository') - else: - repository = None - return {'username': config.get(server, 'username'), - 'password': config.get(server, 'password'), - 'repository': repository, - 'server': server, - 'realm': self.DEFAULT_REALM} - - return {} - - def _set_config(self): - _register._set_config(self) - if self.repository is None: - raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index f2e0b2e1..4bd6021d 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -2,7 +2,6 @@ Implements the Distutils 'upload' subcommand (upload package to PyPI).""" - from distutils.errors import * from distutils.core import Command from distutils.spawn import spawn @@ -12,7 +11,6 @@ try: except ImportError: from md5 import md5 import os -import sys import socket import platform import ConfigParser @@ -21,7 +19,7 @@ import base64 import urlparse import cStringIO as StringIO -class _upload(Command): +class upload(Command): description = "upload binary package to PyPI" @@ -67,7 +65,7 @@ class _upload(Command): if not self.password: self.password = config.get('server-login', 'password') if not self.repository: - raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) + self.repository = self.DEFAULT_REPOSITORY def run(self): if not self.distribution.dist_files: @@ -184,73 +182,3 @@ class _upload(Command): if self.show_response: print '-'*75, r.read(), '-'*75 -if sys.version >= "2.5": - from distutils.command.upload import upload as distutils_upload - class upload(distutils_upload): - - def run(self): - self._section_name = self.repository - distutils_upload.run(self) - - def _read_pypirc(self): - """Reads the .pypirc file.""" - self._section_name = self.repository - rc = self._get_rc_file() - if os.path.exists(rc): - repository = self.repository - config = ConfigParser.ConfigParser() - config.read(rc) - sections = config.sections() - if 'distutils' in sections: - # let's get the list of servers - index_servers = config.get('distutils', 'index-servers') - _servers = [server.strip() for server in - index_servers.split('\n') - if server.strip() != ''] - if _servers == []: - # nothing set, let's try to get the default pypi - if 'pypi' in sections: - _servers = ['pypi'] - else: - # the file is not properly defined, returning - # an empty dict - return {} - for server in _servers: - current = {'server': server} - current['username'] = config.get(server, 'username') - - # optional params - for key, default in (('repository', - None), - ('realm', self.DEFAULT_REALM), - ('password', None)): - if config.has_option(server, key): - current[key] = config.get(server, key) - else: - current[key] = default - if (current['server'] == repository: - return current - elif 'server-login' in sections: - # old format - server = 'server-login' - if config.has_option(server, 'repository'): - repository = config.get(server, 'repository') - else: - repository = None - return {'username': config.get(server, 'username'), - 'password': config.get(server, 'password'), - 'repository': repository, - 'server': server, - 'realm': self.DEFAULT_REALM} - - return {} - - def finalize_options(self): - distutils_upload.finalize_options(self) - if not self.repository: - raise ValueError('%s is missing a repository value in .pypirc' % self._section_name) - - -else: - upload = _upload - -- cgit v1.2.3 From bbe00513be4b20a82eb844dab52c15ca5e8e7113 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 1 Dec 2011 12:55:33 -0500 Subject: Fix issue #262 - package_index.open_with_auth no longer throws LookupError on Python 3. --HG-- branch : distribute extra : rebase_source : ae4a0886ff89d3679f495f51171f94d3770e5d47 --- setuptools/package_index.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index bb0ae129..d0896feb 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -1,5 +1,6 @@ """PyPI and direct package downloading""" import sys, os.path, re, urlparse, urllib, urllib2, shutil, random, socket, cStringIO +import base64 import httplib from pkg_resources import * from distutils import log @@ -756,6 +757,22 @@ def socket_timeout(timeout=15): return _socket_timeout return _socket_timeout +def _encode_auth(auth): + """ + A function compatible with Python 2.3-3.3 that will encode + auth from a URL suitable for an HTTP header. + >>> _encode_auth('username%3Apassword') + u'dXNlcm5hbWU6cGFzc3dvcmQ=' + """ + auth_s = urllib2.unquote(auth) + # convert to bytes + auth_bytes = auth_s.encode() + # use the legacy interface for Python 2.3 support + encoded_bytes = base64.encodestring(auth_bytes) + # convert back to a string + encoded = encoded_bytes.decode() + # strip the trailing carriage return + return encoded.rstrip() def open_with_auth(url): """Open a urllib2 request, handling HTTP authentication""" @@ -768,7 +785,7 @@ def open_with_auth(url): auth = None if auth: - auth = "Basic " + urllib2.unquote(auth).encode('base64').strip() + auth = "Basic " + _encode_auth(auth) new_url = urlparse.urlunparse((scheme,host,path,params,query,frag)) request = urllib2.Request(new_url) request.add_header("Authorization", auth) -- cgit v1.2.3 From 5e53787185059a78874e2f730c431ec611b0b8e7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 20 Jan 2012 14:11:03 -0500 Subject: Remove grody hack for later versions of Python where it is no longer necessary. Fixes #269. --HG-- branch : distribute extra : rebase_source : c4f18c8760303a2228baf5b88ec1f59a865999a5 --- setuptools/command/sdist.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 3442fe4b..c49839cd 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -199,15 +199,25 @@ class sdist(_sdist): build_scripts = self.get_finalized_command('build_scripts') self.filelist.extend(build_scripts.get_source_files()) - def read_template(self): + def __read_template_hack(self): + # This grody hack closes the template file (MANIFEST.in) if an + # exception occurs during read_template. + # Doing so prevents an error when easy_install attempts to delete the + # file. try: _sdist.read_template(self) except: - # grody hack to close the template file (MANIFEST.in) - # this prevents easy_install's attempt at deleting the file from - # dying and thus masking the real error sys.exc_info()[2].tb_next.tb_frame.f_locals['template'].close() raise + # Beginning with Python 2.7.2, 3.1.4, and 3.2.1, this leaky file handle + # has been fixed, so only override the method if we're using an earlier + # Python. + if ( + sys.version_info < (2,7,2) + or (3,0) <= sys.version_info < (3,1,4) + or (3,2) <= sys.version_info < (3,2,1) + ): + read_template = __read_template_hack def check_readme(self): alts = ("README", "README.txt") -- cgit v1.2.3 From d7907a5c969ad05970e458cc7b69b522dda46164 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 6 Feb 2012 22:34:53 -0500 Subject: Fix #272 - TypeError when namespace_package is unicode --HG-- branch : distribute extra : rebase_source : 5bb6bc394dbe2834977b853af85241ae0a472de6 --- setuptools/command/install_egg_info.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'setuptools') diff --git a/setuptools/command/install_egg_info.py b/setuptools/command/install_egg_info.py index dd95552e..f44b34b5 100755 --- a/setuptools/command/install_egg_info.py +++ b/setuptools/command/install_egg_info.py @@ -89,6 +89,8 @@ class install_egg_info(Command): if not self.dry_run: f = open(filename,'wt') for pkg in nsp: + # ensure pkg is not a unicode string under Python 2.7 + pkg = str(pkg) pth = tuple(pkg.split('.')) trailer = '\n' if '.' in pkg: -- cgit v1.2.3 From f4a592c1240bbc3f0b1d0d08e261874857954225 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 8 Feb 2012 13:33:09 -0500 Subject: Now load legacy scripts wrappers from templates in the package, which get converted to Python 3 syntax when built on Python 3. Fixes #273. --HG-- branch : distribute extra : rebase_source : 900842f8a9e70d347296f7b076c6113ead6f7318 --- setuptools/command/easy_install.py | 36 ++++++++++++++++++++---------------- setuptools/script template (dev).py | 6 ++++++ setuptools/script template.py | 4 ++++ 3 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 setuptools/script template (dev).py create mode 100644 setuptools/script template.py (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 4700fe0e..a51d88f5 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -731,22 +731,26 @@ Please make the appropriate changes for your system and try again. spec = str(dist.as_requirement()) is_script = is_python_script(script_text, script_name) - if is_script and dev_path: - script_text = get_script_header(script_text) + ( - "# EASY-INSTALL-DEV-SCRIPT: %(spec)r,%(script_name)r\n" - "__requires__ = %(spec)r\n" - "from pkg_resources import require; require(%(spec)r)\n" - "del require\n" - "__file__ = %(dev_path)r\n" - "execfile(__file__)\n" - ) % locals() - elif is_script: - script_text = get_script_header(script_text) + ( - "# EASY-INSTALL-SCRIPT: %(spec)r,%(script_name)r\n" - "__requires__ = %(spec)r\n" - "import pkg_resources\n" - "pkg_resources.run_script(%(spec)r, %(script_name)r)\n" - ) % locals() + def get_template(filename): + """ + There are a couple of template scripts in the package. This + function loads one of them and prepares it for use. + + These templates use triple-quotes to escape variable + substitutions so the scripts get the 2to3 treatment when build + on Python 3. The templates cannot use triple-quotes naturally. + """ + raw_bytes = resource_string('setuptools', template_name) + template_str = raw_bytes.decode('utf-8') + clean_template = template_str.replace('"""', '') + return clean_template + + if is_script: + template_name = 'script template.py' + if dev_path: + template_name = template_name.replace('.py', ' (dev).py') + script_text = (get_script_header(script_text) + + get_template(template_name) % locals()) self.write_script(script_name, _to_ascii(script_text), 'b') def write_script(self, script_name, contents, mode="t", blockers=()): diff --git a/setuptools/script template (dev).py b/setuptools/script template (dev).py new file mode 100644 index 00000000..6dd9dd45 --- /dev/null +++ b/setuptools/script template (dev).py @@ -0,0 +1,6 @@ +# EASY-INSTALL-DEV-SCRIPT: %(spec)r,%(script_name)r +__requires__ = """%(spec)r""" +from pkg_resources import require; require("""%(spec)r""") +del require +__file__ = """%(dev_path)r""" +execfile(__file__) diff --git a/setuptools/script template.py b/setuptools/script template.py new file mode 100644 index 00000000..8dd5d510 --- /dev/null +++ b/setuptools/script template.py @@ -0,0 +1,4 @@ +# EASY-INSTALL-SCRIPT: %(spec)r,%(script_name)r +__requires__ = """%(spec)r""" +import pkg_resources +pkg_resources.run_script("""%(spec)r""", """%(script_name)r""") -- cgit v1.2.3 From f6cb3d29d919ff6b9313b8a3281c66cfb368c29b Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Mon, 13 Feb 2012 16:22:33 -0500 Subject: This allows the sdist command to ensure that any files listed in package_data are included in the dist, regardless of whether it's under version control, as is the case with distutil's sdist. Setting include_package_data=True disables this functionality. --HG-- branch : distribute extra : rebase_source : 2cae1675c638dc12fd556368074c6b5c691c6f58 --- setuptools/command/sdist.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'setuptools') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index c49839cd..484f8276 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -186,6 +186,14 @@ class sdist(_sdist): if self.distribution.has_pure_modules(): build_py = self.get_finalized_command('build_py') self.filelist.extend(build_py.get_source_files()) + # This functionality is incompatible with include_package_data, and + # will in fact create an infinite recursion if include_package_data + # is True. Use of include_package_data will imply that + # distutils-style automatic handling of package_data is disabled + if not self.distribution.include_package_data: + for _, src_dir, _, filenames in build_py.data_files: + self.filelist.extend([os.path.join(src_dir, filename) + for filename in filenames]) if self.distribution.has_ext_modules(): build_ext = self.get_finalized_command('build_ext') -- cgit v1.2.3 From ed9ebca5b0c012c6b44adad4efa475f1cccd460d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 10 Mar 2012 19:03:23 -0800 Subject: Indent with spaces --HG-- branch : distribute extra : rebase_source : 799441b639f6f9c55fe25745e793ac29419f0293 --- setuptools/extension.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'setuptools') diff --git a/setuptools/extension.py b/setuptools/extension.py index 980ee0a7..b5a0702b 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -5,12 +5,12 @@ _Extension = _get_unpatched(_Extension) # Prefer Cython to Pyrex pyrex_impls = 'Cython.Distutils.build_ext', 'Pyrex.Distutils.build_ext' for pyrex_impl in pyrex_impls: - try: - # from (pyrex_impl) import build_ext - build_ext = __import__(pyrex_impl, fromlist=['build_ext']).build_ext - break - except: - pass + try: + # from (pyrex_impl) import build_ext + build_ext = __import__(pyrex_impl, fromlist=['build_ext']).build_ext + break + except: + pass have_pyrex = 'build_ext' in globals() @@ -18,7 +18,7 @@ class Extension(_Extension): """Extension that uses '.c' files in place of '.pyx' files""" if not have_pyrex: - # convert .pyx extensions to .c + # convert .pyx extensions to .c def __init__(self,*args,**kw): _Extension.__init__(self,*args,**kw) sources = [] -- cgit v1.2.3 From 5e47a200c412793a2878e3df57f29e854e2e9356 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 10 Mar 2012 19:21:15 -0800 Subject: Reorganized imports --HG-- branch : distribute extra : rebase_source : 3c54aa84f71220021b92f890359546b4ff41e5f6 --- setuptools/extension.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'setuptools') diff --git a/setuptools/extension.py b/setuptools/extension.py index b5a0702b..e87494ad 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -1,6 +1,10 @@ -from distutils.core import Extension as _Extension +import sys +import distutils.core +import distutils.extension + from setuptools.dist import _get_unpatched -_Extension = _get_unpatched(_Extension) + +_Extension = _get_unpatched(distutils.core.Extension) # Prefer Cython to Pyrex pyrex_impls = 'Cython.Distutils.build_ext', 'Pyrex.Distutils.build_ext' @@ -19,12 +23,12 @@ class Extension(_Extension): if not have_pyrex: # convert .pyx extensions to .c - def __init__(self,*args,**kw): - _Extension.__init__(self,*args,**kw) + def __init__(self, *args, **kw): + _Extension.__init__(self, *args, **kw) sources = [] for s in self.sources: if s.endswith('.pyx'): - sources.append(s[:-3]+'c') + sources.append(s[:-3] + 'c') else: sources.append(s) self.sources = sources @@ -32,9 +36,7 @@ class Extension(_Extension): class Library(Extension): """Just like a regular Extension, but built as a library instead""" -import sys, distutils.core, distutils.extension distutils.core.Extension = Extension distutils.extension.Extension = Extension if 'distutils.command.build_ext' in sys.modules: sys.modules['distutils.command.build_ext'].Extension = Extension - -- cgit v1.2.3 From 9f5991b303d87d49479381b971652950f0cfdac1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 10 Mar 2012 22:17:12 -0800 Subject: Refactored Extension class so that __init__ is always called, but patched behavior is still selected by has_pyrex. --HG-- branch : distribute extra : rebase_source : d5670bf4bc6606d828b4ec7be055e26a7d4a9730 --- setuptools/extension.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'setuptools') diff --git a/setuptools/extension.py b/setuptools/extension.py index e87494ad..db563305 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -21,17 +21,15 @@ have_pyrex = 'build_ext' in globals() class Extension(_Extension): """Extension that uses '.c' files in place of '.pyx' files""" - if not have_pyrex: - # convert .pyx extensions to .c - def __init__(self, *args, **kw): - _Extension.__init__(self, *args, **kw) - sources = [] - for s in self.sources: - if s.endswith('.pyx'): - sources.append(s[:-3] + 'c') - else: - sources.append(s) - self.sources = sources + def __init__(self, *args, **kw): + _Extension.__init__(self, *args, **kw) + if not have_pyrex: + self._convert_pyx_sources_to_c() + + def _convert_pyx_sources_to_c(self): + "convert .pyx extensions to .c" + self.sources = [source[:-3] + 'c' for source in self.sources + if source.endswith('.pyx')] class Library(Extension): """Just like a regular Extension, but built as a library instead""" -- cgit v1.2.3 From 8633ffe737039044e955a6e5bd52ac08a0d83b37 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 10 Mar 2012 22:31:45 -0800 Subject: Converted have_pyrex into a function --HG-- branch : distribute extra : rebase_source : b676ea404118a121400f2fd1b67095ab4521b7a0 --- setuptools/extension.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'setuptools') diff --git a/setuptools/extension.py b/setuptools/extension.py index db563305..eb8b836c 100644 --- a/setuptools/extension.py +++ b/setuptools/extension.py @@ -6,16 +6,19 @@ from setuptools.dist import _get_unpatched _Extension = _get_unpatched(distutils.core.Extension) -# Prefer Cython to Pyrex -pyrex_impls = 'Cython.Distutils.build_ext', 'Pyrex.Distutils.build_ext' -for pyrex_impl in pyrex_impls: - try: - # from (pyrex_impl) import build_ext - build_ext = __import__(pyrex_impl, fromlist=['build_ext']).build_ext - break - except: - pass -have_pyrex = 'build_ext' in globals() +def have_pyrex(): + """ + Return True if Cython or Pyrex can be imported. + """ + pyrex_impls = 'Cython.Distutils.build_ext', 'Pyrex.Distutils.build_ext' + for pyrex_impl in pyrex_impls: + try: + # from (pyrex_impl) import build_ext + __import__(pyrex_impl, fromlist=['build_ext']).build_ext + return True + except Exception: + pass + return False class Extension(_Extension): @@ -23,13 +26,16 @@ class Extension(_Extension): def __init__(self, *args, **kw): _Extension.__init__(self, *args, **kw) - if not have_pyrex: + if not have_pyrex(): self._convert_pyx_sources_to_c() def _convert_pyx_sources_to_c(self): "convert .pyx extensions to .c" - self.sources = [source[:-3] + 'c' for source in self.sources - if source.endswith('.pyx')] + def pyx_to_c(source): + if source.endswith('.pyx'): + source = source[:-4] + '.c' + return source + self.sources = map(pyx_to_c, self.sources) class Library(Extension): """Just like a regular Extension, but built as a library instead""" -- cgit v1.2.3 From 39f910e2e4b68cf11ecd2cf12c697aacce451d3d Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Fri, 23 Mar 2012 13:50:04 -0400 Subject: Include symlinks when extracting source dist. Fixes #183. --HG-- branch : distribute extra : rebase_source : c0d44c559d3433e4e4ceddaff5467c2d82dd7688 --- setuptools/archive_util.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'setuptools') diff --git a/setuptools/archive_util.py b/setuptools/archive_util.py index ab786f3d..5787753f 100755 --- a/setuptools/archive_util.py +++ b/setuptools/archive_util.py @@ -180,19 +180,22 @@ def unpack_tarfile(filename, extract_dir, progress_filter=default_filter): try: tarobj.chown = lambda *args: None # don't do any chowning! for member in tarobj: - if member.isfile() or member.isdir(): - name = member.name - # don't extract absolute paths or ones with .. in them - if not name.startswith('/') and '..' not in name: - dst = os.path.join(extract_dir, *name.split('/')) - dst = progress_filter(name, dst) - if dst: - if dst.endswith(os.sep): - dst = dst[:-1] - try: - tarobj._extract_member(member,dst) # XXX Ugh - except tarfile.ExtractError: - pass # chown/chmod/mkfifo/mknode/makedev failed + name = member.name + # don't extract absolute paths or ones with .. in them + if not name.startswith('/') and '..' not in name: + prelim_dst = os.path.join(extract_dir, *name.split('/')) + final_dst = progress_filter(name, prelim_dst) + # If progress_filter returns None, then we do not extract + # this file + # TODO: Do we really need to limit to just these file types? + # tarobj.extract() will handle all files on all platforms, + # turning file types that aren't allowed on that platform into + # regular files. + if final_dst and (member.isfile() or member.isdir() or + member.islnk() or member.issym()): + tarobj.extract(member, extract_dir) + if final_dst != prelim_dst: + shutil.move(prelim_dst, final_dst) return True finally: tarobj.close() -- cgit v1.2.3 From be66b979ea6371d92a555c5fea28faa3e2b719bc Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 29 Mar 2012 23:36:28 -0400 Subject: Another attempt at a fix that uses setopt instead of hacking easy_install --HG-- branch : distribute extra : rebase_source : 907488d2ba609dbca39cd14c021c5cfb4f353a38 --- setuptools/command/easy_install.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index d200dac1..ef82808b 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -271,8 +271,7 @@ class easy_install(Command): ) else: self.all_site_dirs.append(normalize_path(d)) - if not self.editable and self.args != ['-']: - self.check_site_dir() + if not self.editable: self.check_site_dir() self.index_url = self.index_url or "http://pypi.python.org/simple" self.shadow_path = self.all_site_dirs[:] for path_item in self.install_dir, normalize_path(self.script_dir): @@ -343,11 +342,6 @@ class easy_install(Command): 'install_scripts', 'install_data',]) def run(self): - if self.args == ['-']: - # A single dash as an argument means 'do nothing' and is just a way - # to pass arguments to the easy_install command without running it - return - if self.verbose != self.distribution.verbose: log.set_verbosity(self.verbose) try: @@ -1102,10 +1096,14 @@ See the setuptools documentation for the "develop" command for more info. if key not in keep: del ei_opts[key] if ei_opts: - args.append('easy_install') for key, val in ei_opts.iteritems(): - args.append('--%s=%s' % (key.replace('_', '-'), val[1])) - args.append('-') + args.append('setopt') + args.append('--command') + args.append('easy_install') + args.append('--option') + args.append(key.replace('_', '-')) + args.append('--set-value') + args.append(val[1]) self.run_setup(setup_script, setup_base, args) all_eggs = Environment([dist_dir]) -- cgit v1.2.3 From 23622dbdb01a2427ba8c40ffb9820793a6d21817 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 29 Mar 2012 23:57:57 -0400 Subject: Put the setopt directives before bdist_egg --HG-- branch : distribute extra : rebase_source : 23f656d6eb2ade3aa51f285a8bc288eab432819a --- setuptools/command/easy_install.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index ef82808b..4ff57648 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1081,29 +1081,27 @@ See the setuptools documentation for the "develop" command for more info. raise DistutilsError("Setup script exited with %s" % (v.args[0],)) def build_and_install(self, setup_script, setup_base): - args = ['bdist_egg', '--dist-dir'] + args = [] + + # first pass along any install directives using setopt + ei_opts = self.distribution.get_option_dict('easy_install').copy() + install_directives = ( + 'find_links', 'site_dirs', 'index_url', 'optimize', + 'site_dirs', 'allow_hosts' + ) + for key, val in ei_opts.iteritems(): + if key not in install_directives: continue + args.extend(['setopt', '--command', 'easy_install', + '--option', key.replace('_', '-'), + '--set-value', val[1]]) + + args.extend(['bdist_egg', '--dist-dir']) + dist_dir = tempfile.mkdtemp( prefix='egg-dist-tmp-', dir=os.path.dirname(setup_script) ) try: args.append(dist_dir) - ei_opts = self.distribution.get_option_dict('easy_install').copy() - keep = ( - 'find_links', 'site_dirs', 'index_url', 'optimize', - 'site_dirs', 'allow_hosts' - ) - for key in ei_opts.keys(): - if key not in keep: - del ei_opts[key] - if ei_opts: - for key, val in ei_opts.iteritems(): - args.append('setopt') - args.append('--command') - args.append('easy_install') - args.append('--option') - args.append(key.replace('_', '-')) - args.append('--set-value') - args.append(val[1]) self.run_setup(setup_script, setup_base, args) all_eggs = Environment([dist_dir]) -- cgit v1.2.3 From d388348dbca2972ed9cf6b2a9eff3b264f0e58b7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 30 Mar 2012 09:08:23 -0400 Subject: Yet another approach - invoking setopt directly prior to invoking a new setup process. This approach works (compared to the previous setopt approach which did not). --HG-- branch : distribute extra : rebase_source : 4d28ae98e67d8bc1f2f98aee93d7a69000f10239 --- setuptools/command/easy_install.py | 42 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 4ff57648..dfd9f7ff 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -21,6 +21,7 @@ from distutils.sysconfig import get_python_lib, get_config_vars from distutils.errors import DistutilsArgError, DistutilsOptionError, \ DistutilsError, DistutilsPlatformError from distutils.command.install import INSTALL_SCHEMES, SCHEME_KEYS +from setuptools.command import setopt from setuptools.archive_util import unpack_archive from setuptools.package_index import PackageIndex from setuptools.package_index import URL_SCHEME @@ -1081,26 +1082,13 @@ See the setuptools documentation for the "develop" command for more info. raise DistutilsError("Setup script exited with %s" % (v.args[0],)) def build_and_install(self, setup_script, setup_base): - args = [] - - # first pass along any install directives using setopt - ei_opts = self.distribution.get_option_dict('easy_install').copy() - install_directives = ( - 'find_links', 'site_dirs', 'index_url', 'optimize', - 'site_dirs', 'allow_hosts' - ) - for key, val in ei_opts.iteritems(): - if key not in install_directives: continue - args.extend(['setopt', '--command', 'easy_install', - '--option', key.replace('_', '-'), - '--set-value', val[1]]) - - args.extend(['bdist_egg', '--dist-dir']) + args = ['bdist_egg', '--dist-dir'] dist_dir = tempfile.mkdtemp( prefix='egg-dist-tmp-', dir=os.path.dirname(setup_script) ) try: + self._set_fetcher_options(os.path.dirname(setup_script)) args.append(dist_dir) self.run_setup(setup_script, setup_base, args) @@ -1117,6 +1105,30 @@ See the setuptools documentation for the "develop" command for more info. rmtree(dist_dir) log.set_verbosity(self.verbose) # restore our log verbosity + def _set_fetcher_options(self, base): + """ + When easy_install is about to run bdist_egg on a source dist, that + source dist might have 'setup_requires' directives, requiring + additional fetching. Ensure the fetcher options given to easy_install + are available to that command as well. + """ + # find the fetch options from easy_install and write them out + # to the setup.cfg file. + ei_opts = self.distribution.get_option_dict('easy_install').copy() + fetch_directives = ( + 'find_links', 'site_dirs', 'index_url', 'optimize', + 'site_dirs', 'allow_hosts', + ) + fetch_options = {} + for key, val in ei_opts.iteritems(): + if key not in fetch_directives: continue + fetch_options[key.replace('_', '-')] = val[1] + # create a settings dictionary suitable for `edit_config` + settings = dict(easy_install=fetch_options) + cfg_filename = os.path.join(base, 'setup.cfg') + setopt.edit_config(cfg_filename, settings) + + def update_pth(self,dist): if self.pth_file is None: return -- cgit v1.2.3 From c2ee921caa6757e4b8e34687cf758cf7859a0737 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 30 Mar 2012 09:10:44 -0400 Subject: Backout changes to dist.py from 488cc8a13f66 --HG-- branch : distribute extra : rebase_source : 2aeb4f273f05dd10b26a530c40dabfcb57861d37 --- setuptools/dist.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/dist.py b/setuptools/dist.py index 204dcdfa..0ad18122 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -269,9 +269,8 @@ class Distribution(_Distribution): cmd.package_index.to_scan = [] except AttributeError: from setuptools.command.easy_install import easy_install - dist = self.__class__() + dist = self.__class__({'script_args':['easy_install']}) dist.parse_config_files() - dist.parse_command_line() opts = dist.get_option_dict('easy_install') keep = ( 'find_links', 'site_dirs', 'index_url', 'optimize', -- cgit v1.2.3 From 5ac3e0119a483c7d9bb43148d2b6f16c546913ff Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Apr 2012 09:15:44 -0400 Subject: Reorganized imports --HG-- branch : distribute extra : rebase_source : b348504ee7341fc2928a786167f33baa136e2b93 --- setuptools/tests/__init__.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py index 9af44a88..fec3854d 100644 --- a/setuptools/tests/__init__.py +++ b/setuptools/tests/__init__.py @@ -1,19 +1,21 @@ """Tests for the 'setuptools' package""" -from unittest import TestSuite, TestCase, makeSuite, defaultTestLoader -import distutils.core, distutils.cmd +import sys +import os +import doctest +import distutils.core +import distutils.cmd from distutils.errors import DistutilsOptionError, DistutilsPlatformError from distutils.errors import DistutilsSetupError -import setuptools, setuptools.dist -from setuptools import Feature from distutils.core import Extension -extract_constant, get_module_constant = None, None -from setuptools.depends import * -from distutils.version import StrictVersion, LooseVersion -from distutils.util import convert_path -import sys, os.path +from distutils.version import LooseVersion + +import unittest + +import setuptools.dist +from setuptools import Feature +from setuptools.depends import Require, find_module, get_module_constant, extract_constant def additional_tests(): - import doctest, unittest suite = unittest.TestSuite(( doctest.DocFileSuite( os.path.join('tests', 'api_tests.txt'), @@ -40,7 +42,7 @@ def makeSetup(**args): -class DependsTests(TestCase): +class DependsTests(unittest.TestCase): def testExtractConst(self): if not extract_constant: return # skip on non-bytecode platforms @@ -122,7 +124,7 @@ class DependsTests(TestCase): self.assert_(req.is_current(paths)) -class DistroTests(TestCase): +class DistroTests(unittest.TestCase): def setUp(self): self.e1 = Extension('bar.ext',['bar.c']) @@ -245,7 +247,7 @@ class DistroTests(TestCase): -class FeatureTests(TestCase): +class FeatureTests(unittest.TestCase): def setUp(self): self.req = Require('Distutils','1.0.3','distutils') @@ -327,7 +329,7 @@ class FeatureTests(TestCase): SystemExit, makeSetup, features = {'x':Feature('x', remove='y')} ) -class TestCommandTests(TestCase): +class TestCommandTests(unittest.TestCase): def testTestIsCommand(self): test_cmd = makeSetup().get_command_obj('test') -- cgit v1.2.3 From 61942ccf83167298cbd933f1594d59a32f5cf349 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Apr 2012 09:25:00 -0400 Subject: Cleaned up excess whitespace --HG-- branch : distribute extra : rebase_source : 722c3a4c556ba4415c633e74e34fb45f76d8653d --- setuptools/tests/__init__.py | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py index fec3854d..7a3d6eb5 100644 --- a/setuptools/tests/__init__.py +++ b/setuptools/tests/__init__.py @@ -40,15 +40,13 @@ def makeSetup(**args): distutils.core_setup_stop_after = None - - class DependsTests(unittest.TestCase): def testExtractConst(self): if not extract_constant: return # skip on non-bytecode platforms def f1(): - global x,y,z + global x, y, z x = "test" y = z @@ -64,11 +62,11 @@ class DependsTests(unittest.TestCase): # recognized name, not assigned self.assertEqual(extract_constant(f1.func_code,'z', -1), None) - def testFindModule(self): self.assertRaises(ImportError, find_module, 'no-such.-thing') self.assertRaises(ImportError, find_module, 'setuptools.non-existent') - f,p,i = find_module('setuptools.tests'); f.close() + f,p,i = find_module('setuptools.tests') + f.close() def testModuleExtract(self): if not get_module_constant: return # skip on non-bytecode platforms @@ -137,11 +135,9 @@ class DistroTests(unittest.TestCase): package_dir = {}, ) - def testDistroType(self): self.assert_(isinstance(self.dist,setuptools.dist.Distribution)) - def testExcludePackage(self): self.dist.exclude_package('a') self.assertEqual(self.dist.packages, ['b','c']) @@ -159,12 +155,6 @@ class DistroTests(unittest.TestCase): # test removals from unspecified options makeSetup().exclude_package('x') - - - - - - def testIncludeExclude(self): # remove an extension self.dist.exclude(ext_modules=[self.e1]) @@ -203,9 +193,6 @@ class DistroTests(unittest.TestCase): self.dist.exclude_package('c') self.assert_(not self.dist.has_contents_for('c')) - - - def testInvalidIncludeExclude(self): self.assertRaises(DistutilsSetupError, self.dist.include, nonexistent_option='x' @@ -234,19 +221,6 @@ class DistroTests(unittest.TestCase): ) - - - - - - - - - - - - - class FeatureTests(unittest.TestCase): def setUp(self): @@ -365,8 +339,3 @@ class TestCommandTests(unittest.TestCase): ts5 = makeSetup().get_command_obj('test') ts5.ensure_finalized() self.assertEqual(ts5.test_suite, None) - - - - - -- cgit v1.2.3 From 83a86217e2f1cf1259d4b1921b840a449f0dd32b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Apr 2012 09:26:13 -0400 Subject: Reorganized imports and cleaned up whitespace --HG-- branch : distribute extra : rebase_source : 288c7531df0ab929030445973ecf6386a3e437b1 --- setuptools/tests/test_easy_install.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 4150ad10..dce5501d 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -1,9 +1,12 @@ """Easy install Tests """ import sys -import os, shutil, tempfile, unittest +import os +import shutil +import tempfile +import unittest import site -from StringIO import StringIO + from setuptools.command.easy_install import easy_install, get_script_args, main from setuptools.command.easy_install import PthDistributions from setuptools.command import easy_install as easy_install_pkg @@ -11,7 +14,8 @@ from setuptools.dist import Distribution from pkg_resources import Distribution as PRDistribution try: - import multiprocessing + # import multiprocessing solely for the purpose of testing its existence + __import__('multiprocessing') import logging _LOG = logging.getLogger('test_easy_install') logging.basicConfig(level=logging.INFO, stream=sys.stderr) @@ -110,7 +114,7 @@ class TestEasyInstallTest(unittest.TestCase): # the project level dist = Distribution() cmd = easy_install(dist) - cmd.check_pth_processing = lambda : True + cmd.check_pth_processing = lambda: True cmd.no_find_links = True cmd.find_links = ['link1', 'link2'] cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok') @@ -120,7 +124,7 @@ class TestEasyInstallTest(unittest.TestCase): # let's try without it (default behavior) cmd = easy_install(dist) - cmd.check_pth_processing = lambda : True + cmd.check_pth_processing = lambda: True cmd.find_links = ['link1', 'link2'] cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok') cmd.args = ['ok'] @@ -173,7 +177,7 @@ class TestUserInstallTest(unittest.TestCase): def tearDown(self): os.chdir(self.old_cwd) shutil.rmtree(self.dir) - if sys.version >= "2.6": + if sys.version >= "2.6": shutil.rmtree(site.USER_BASE) shutil.rmtree(site.USER_SITE) site.USER_BASE = self.old_base @@ -249,4 +253,3 @@ class TestUserInstallTest(unittest.TestCase): os.environ['PYTHONPATH'] = old_ppath else: del os.environ['PYTHONPATH'] - -- cgit v1.2.3 From 1ed3a1602e14450433663f5923972a73686379fd Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Apr 2012 10:56:03 -0400 Subject: Cleaned up simulated index server, expanding documentation. --HG-- branch : distribute extra : rebase_source : b479cf805b766fa35c8e76c30c7725e93f56e6a2 --- setuptools/tests/server.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py index f4aaaa1c..2dcbe5af 100644 --- a/setuptools/tests/server.py +++ b/setuptools/tests/server.py @@ -2,7 +2,7 @@ """ import urllib2 import sys -from threading import Thread +import threading from BaseHTTPServer import HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler @@ -17,29 +17,36 @@ class IndexServer(HTTPServer): # The index files should be located in setuptools/tests/indexes s.stop() """ - def __init__(self): - HTTPServer.__init__(self, ('', 0), SimpleHTTPRequestHandler) + def __init__(self, server_address=('', 0), + RequestHandlerClass=SimpleHTTPRequestHandler, + bind_and_activate=True): + HTTPServer.__init__(self, server_address, RequestHandlerClass, + bind_and_activate) self._run = True def serve(self): - while True: + while self._run: self.handle_request() - if not self._run: break def start(self): - self.thread = Thread(target=self.serve) + self.thread = threading.Thread(target=self.serve) self.thread.start() def stop(self): - """self.shutdown is not supported on python < 2.6""" + "Stop the server" + + # self.shutdown is not supported on python < 2.6, so just + # set _run to false, and make a request, causing it to + # terminate. self._run = False + url = 'http://127.0.0.1:%(server_port)s/' % vars(self) try: - if sys.version > '2.6': - urllib2.urlopen('http://127.0.0.1:%s/' % self.server_port, - None, 5) + if sys.version_info >= (2, 6): + urllib2.urlopen(url, timeout=5) else: - urllib2.urlopen('http://127.0.0.1:%s/' % self.server_port) + urllib2.urlopen(url) except urllib2.URLError: + # ignore any errors; all that's important is the request pass self.thread.join() -- cgit v1.2.3 From fdc210e463688befd23e1a0e3ad1a599a891019d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Apr 2012 11:26:34 -0400 Subject: Started work on a Mock server that doesn't require a file system to back it. --HG-- branch : distribute extra : rebase_source : feac8d802a8f574124fffab8c6c22d218b61987c --- setuptools/tests/server.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'setuptools') diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py index 2dcbe5af..870d3c8e 100644 --- a/setuptools/tests/server.py +++ b/setuptools/tests/server.py @@ -3,6 +3,7 @@ import urllib2 import sys import threading +import BaseHTTPServer from BaseHTTPServer import HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler @@ -53,3 +54,19 @@ class IndexServer(HTTPServer): def base_url(self): port = self.server_port return 'http://127.0.0.1:%s/setuptools/tests/indexes/' % port + +class RequestRecorder(BaseHTTPServer.BaseHTTPRequestHandler): + def do_GET(self): + requests = vars(self.server).setdefault('requests', []) + requests.append(self) + self.send_response(200, 'OK') + +class MockServer(HTTPServer): + """ + A simple HTTP Server that records the requests made to it. + """ + def __init__(self, server_address=('', 0), + RequestHandlerClass=RequestRecorder, + bind_and_activate=True): + HTTPServer.__init__(self, server_address, RequestHandlerClass, + bind_and_activate) -- cgit v1.2.3 From ea977c0c8db023626f40f9b7c159549846f14a47 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 1 Apr 2012 15:28:56 -0400 Subject: Add test to capture issue 227 --HG-- branch : distribute extra : rebase_source : 6a829eb08499c0b7a83dd653fb039b8695620fb0 --- setuptools/tests/server.py | 9 +++++++ setuptools/tests/test_easy_install.py | 51 +++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) (limited to 'setuptools') diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py index 870d3c8e..e04dcca5 100644 --- a/setuptools/tests/server.py +++ b/setuptools/tests/server.py @@ -70,3 +70,12 @@ class MockServer(HTTPServer): bind_and_activate=True): HTTPServer.__init__(self, server_address, RequestHandlerClass, bind_and_activate) + self.threads = [] + + def handle_request_in_thread(self): + self.threads.append(threading.Thread(target = self.handle_request)) + # todo: ensure that threads are closed. + + def url(self): + return 'http://localhost:%(server_port)s/' % vars(self) + url = property(url) diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index dce5501d..6dcb1cbd 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -6,12 +6,14 @@ import shutil import tempfile import unittest import site +import contextlib from setuptools.command.easy_install import easy_install, get_script_args, main from setuptools.command.easy_install import PthDistributions from setuptools.command import easy_install as easy_install_pkg from setuptools.dist import Distribution from pkg_resources import Distribution as PRDistribution +import setuptools.tests.server try: # import multiprocessing solely for the purpose of testing its existence @@ -253,3 +255,52 @@ class TestUserInstallTest(unittest.TestCase): os.environ['PYTHONPATH'] = old_ppath else: del os.environ['PYTHONPATH'] + + +class TestSetupRequires(unittest.TestCase): + + def test_setup_requires_honors_fetch_params(self): + """ + When easy_install installs a source distribution which specifies + setup_requires, it should honor the fetch parameters (such as + allow-hosts, index-url, and find-links). + """ + # set up a server which will simulate an alternate package index. + p_index = setuptools.tests.server.MockServer() + p_index.handle_request_in_thread() + # create an sdist that has a build-time dependency. + dist_file = self.create_sdist() + with tempdir_context() as temp_install_dir: + with environment_context(PYTHONPATH=temp_install_dir): + ei_params = ['--index-url', p_index.url, + '--allow-hosts', 'localhost', + '--exclude-scripts', '--install-dir', temp_install_dir, + dist_file] + easy_install_pkg.main(ei_params) + self.assertTrue(os.listdir(temp_install_dir)) + self.assertEqual(len(p_index.requests), 1) + self.assertEqual(p_index.requests[0].path, 'x') + + def create_sdist(self): + # for now, just use a known dist + return ('http://pypi.python.org/packages/source/j/jaraco.util/' + 'jaraco.util-5.3.zip') + +@contextlib.contextmanager +def tempdir_context(): + temp_dir = tempfile.mkdtemp() + try: + yield temp_dir + finally: + shutil.rmtree(temp_dir) + +@contextlib.contextmanager +def environment_context(**updates): + old_env = os.environ.copy() + os.environ.update(updates) + try: + yield + finally: + for key in updates: + del os.environ[key] + os.environ.update(old_env) -- cgit v1.2.3 From b06c48c01625706c398e6ef6db343cbb192c184e Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 7 Apr 2012 11:24:05 -0400 Subject: Expanded TestSetupRequires so it actually stages the installation of an sdist with a setup_requires. --HG-- branch : distribute extra : rebase_source : 4266165d9e75e9e19551a3bf646820f309f631df --- setuptools/tests/test_easy_install.py | 95 +++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 14 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 6dcb1cbd..aff2688a 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -7,6 +7,7 @@ import tempfile import unittest import site import contextlib +import textwrap from setuptools.command.easy_install import easy_install, get_script_args, main from setuptools.command.easy_install import PthDistributions @@ -269,29 +270,95 @@ class TestSetupRequires(unittest.TestCase): p_index = setuptools.tests.server.MockServer() p_index.handle_request_in_thread() # create an sdist that has a build-time dependency. - dist_file = self.create_sdist() - with tempdir_context() as temp_install_dir: - with environment_context(PYTHONPATH=temp_install_dir): - ei_params = ['--index-url', p_index.url, - '--allow-hosts', 'localhost', - '--exclude-scripts', '--install-dir', temp_install_dir, - dist_file] - easy_install_pkg.main(ei_params) - self.assertTrue(os.listdir(temp_install_dir)) + with TestSetupRequires.create_sdist() as dist_file: + with tempdir_context() as temp_install_dir: + with environment_context(PYTHONPATH=temp_install_dir): + ei_params = ['--index-url', p_index.url, + '--allow-hosts', 'localhost', + '--exclude-scripts', '--install-dir', temp_install_dir, + dist_file] + # attempt to install the dist. It will fail because + # our fake server can't actually supply the dependency + try: + easy_install_pkg.main(ei_params) + except Exception: + pass + #self.assertTrue(os.listdir(temp_install_dir)) self.assertEqual(len(p_index.requests), 1) self.assertEqual(p_index.requests[0].path, 'x') - def create_sdist(self): - # for now, just use a known dist - return ('http://pypi.python.org/packages/source/j/jaraco.util/' - 'jaraco.util-5.3.zip') + @staticmethod + @contextlib.contextmanager + def create_sdist(): + """ + Return an sdist generated by self.generate_dist() + + We don't generate it dynamically, because we don't want the test suite + to have to connect to the network for the setup_requires declaration + just to build the sdist. + """ + with tempdir_context() as d: + dist_path = os.path.join(d, 'distribute-test-fetcher-1.0.tar.gz') + with open(dist_path, 'wb') as dist: + dist.write(""" + H4sICLBagE8C/2Rpc3RcZGlzdHJpYnV0ZS10ZXN0LWZldGNoZXItMS4wLnRhcgDtmNtvmzAUh/Ns + Kf+DlZduUkmBYJAi5WHaXd2SqlG7h6pCNJwQa9xmm2j57+eQaqGpktKt0F3O9wI+XCJy/JmfCLlU + gt8UCgwFUhlzULMFCMPqmyedJ8LUeJ5XbjW723LfsjzHNBmzXV23HJuxDmWdFiikCgSlT/KQ1Yf7 + SwgP9H97zF8f82+P9SGKDJ7Os5Om+m/brutg///4/oeQQxpCOlv5MU+/yr76rvb8Na7rHui/te0/ + 0/PEdvWgQ03sf+OQDvI/81v+n52+Nz6O301qqHHI/4HFdvwfePp09L8FPoMKwkAFxiUIybN0SHXn + u2QcJDCkeyZHl9w9eVokSSBWQ3oxPh1Pvoy75EOWgJEHEVRqrwq1yMS9ggFJwONK+ROfQSqrV74B + ORM8V+Uv/qyexYGaZyKplFDndv2fTi7OX7+d7nnt1/ffdHb8dxgboP9tIEEVeT9fkdqLPXnMtCC/ + lCEfvkpluR/DEuKH5h7SoP81u/D4/M8cC/3H/I88q/81430tNWrn//L7HxswC/3H/I/5/zn932TD + 2Txq2H/r3vd/13QZ+t8GVzrM+eswd90lKoj8m4LHIR3RzUivDKAH5mYkl6kvYMnX6m+qqNy/73++ + avr9b3ne3fyv/Tdt9L8NeJJnQtGy1SrLYkm2u/1y9wWhmlQHglFvz2zpHZfnLDepYNTTk+e2VN5B + LxrfCi5A6kXj6mgRlTc/uj4mL3H5QBAEQRAEaZsfEynDsQAoAAA= + """.decode('base64')) + yield dist_path + + @classmethod + def generate_sdist(cls): + """ + generate the sdist suitable for create_sdist + """ + with tempdir_context(cd=os.chdir): + with open('setup.py', 'wb') as setup_script: + setup_script.write(textwrap.dedent(""" + import setuptools + setuptools.setup( + name="distribute-test-fetcher", + version="1.0", + setup_requires = ['hgtools'], + ) + """).lstrip()) + with argv_context(['setup.py', 'sdist', '-q', '--formats', 'gztar']): + setuptools.setup( + name="distribute-test-fetcher", + version = "1.0", + setup_requires = ['hgtools'], + ) + filename = 'distribute-test-fetcher-1.0.tar.gz' + dist = os.path.join('dist', filename) + assert os.path.isfile(dist) + with open(dist, 'rb') as dist_f: + print("=====================") + print(dist_f.read().encode('base64')) + +@contextlib.contextmanager +def argv_context(repl): + old_argv = sys.argv[:] + sys.argv[:] = repl + yield + sys.argv[:] = old_argv @contextlib.contextmanager -def tempdir_context(): +def tempdir_context(cd=lambda dir:None): temp_dir = tempfile.mkdtemp() + orig_dir = os.getcwd() try: + cd(temp_dir) yield temp_dir finally: + cd(orig_dir) shutil.rmtree(temp_dir) @contextlib.contextmanager -- cgit v1.2.3 From b73fcba7ff7721c1db0a057337863cdbab58ff81 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 7 Apr 2012 11:36:25 -0400 Subject: We expect easy_install to raise a SystemExit --HG-- branch : distribute extra : rebase_source : 74b6b4091c9719daab6f240f8c05b24183fc1b12 --- setuptools/tests/test_easy_install.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index aff2688a..e78b59aa 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -277,12 +277,10 @@ class TestSetupRequires(unittest.TestCase): '--allow-hosts', 'localhost', '--exclude-scripts', '--install-dir', temp_install_dir, dist_file] - # attempt to install the dist. It will fail because + # attempt to install the dist. It should fail because # our fake server can't actually supply the dependency - try: - easy_install_pkg.main(ei_params) - except Exception: - pass + self.assertRaises(SystemExit, + easy_install_pkg.main, ei_params) #self.assertTrue(os.listdir(temp_install_dir)) self.assertEqual(len(p_index.requests), 1) self.assertEqual(p_index.requests[0].path, 'x') -- cgit v1.2.3 From 5112a1e998a49093f2531fa17fbbb21b6fcdb9d2 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 7 Apr 2012 11:43:14 -0400 Subject: Create the sdist using tarfile and the code is much simpler --HG-- branch : distribute extra : rebase_source : f913f69988ddac8b6c27fb72d24728d18073fdb9 --- setuptools/tests/test_easy_install.py | 56 +++++------------------------------ 1 file changed, 8 insertions(+), 48 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index e78b59aa..54e3cdf9 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -8,6 +8,7 @@ import unittest import site import contextlib import textwrap +import tarfile from setuptools.command.easy_install import easy_install, get_script_args, main from setuptools.command.easy_install import PthDistributions @@ -289,64 +290,23 @@ class TestSetupRequires(unittest.TestCase): @contextlib.contextmanager def create_sdist(): """ - Return an sdist generated by self.generate_dist() - - We don't generate it dynamically, because we don't want the test suite - to have to connect to the network for the setup_requires declaration - just to build the sdist. + Return an sdist with a setup_requires dependency (of something that + doesn't exist) """ with tempdir_context() as d: - dist_path = os.path.join(d, 'distribute-test-fetcher-1.0.tar.gz') - with open(dist_path, 'wb') as dist: - dist.write(""" - H4sICLBagE8C/2Rpc3RcZGlzdHJpYnV0ZS10ZXN0LWZldGNoZXItMS4wLnRhcgDtmNtvmzAUh/Ns - Kf+DlZduUkmBYJAi5WHaXd2SqlG7h6pCNJwQa9xmm2j57+eQaqGpktKt0F3O9wI+XCJy/JmfCLlU - gt8UCgwFUhlzULMFCMPqmyedJ8LUeJ5XbjW723LfsjzHNBmzXV23HJuxDmWdFiikCgSlT/KQ1Yf7 - SwgP9H97zF8f82+P9SGKDJ7Os5Om+m/brutg///4/oeQQxpCOlv5MU+/yr76rvb8Na7rHui/te0/ - 0/PEdvWgQ03sf+OQDvI/81v+n52+Nz6O301qqHHI/4HFdvwfePp09L8FPoMKwkAFxiUIybN0SHXn - u2QcJDCkeyZHl9w9eVokSSBWQ3oxPh1Pvoy75EOWgJEHEVRqrwq1yMS9ggFJwONK+ROfQSqrV74B - ORM8V+Uv/qyexYGaZyKplFDndv2fTi7OX7+d7nnt1/ffdHb8dxgboP9tIEEVeT9fkdqLPXnMtCC/ - lCEfvkpluR/DEuKH5h7SoP81u/D4/M8cC/3H/I88q/81430tNWrn//L7HxswC/3H/I/5/zn932TD - 2Txq2H/r3vd/13QZ+t8GVzrM+eswd90lKoj8m4LHIR3RzUivDKAH5mYkl6kvYMnX6m+qqNy/73++ - avr9b3ne3fyv/Tdt9L8NeJJnQtGy1SrLYkm2u/1y9wWhmlQHglFvz2zpHZfnLDepYNTTk+e2VN5B - LxrfCi5A6kXj6mgRlTc/uj4mL3H5QBAEQRAEaZsfEynDsQAoAAA= - """.decode('base64')) - yield dist_path - - @classmethod - def generate_sdist(cls): - """ - generate the sdist suitable for create_sdist - """ - with tempdir_context(cd=os.chdir): with open('setup.py', 'wb') as setup_script: setup_script.write(textwrap.dedent(""" import setuptools setuptools.setup( name="distribute-test-fetcher", version="1.0", - setup_requires = ['hgtools'], + setup_requires = ['does-not-exist'], ) """).lstrip()) - with argv_context(['setup.py', 'sdist', '-q', '--formats', 'gztar']): - setuptools.setup( - name="distribute-test-fetcher", - version = "1.0", - setup_requires = ['hgtools'], - ) - filename = 'distribute-test-fetcher-1.0.tar.gz' - dist = os.path.join('dist', filename) - assert os.path.isfile(dist) - with open(dist, 'rb') as dist_f: - print("=====================") - print(dist_f.read().encode('base64')) - -@contextlib.contextmanager -def argv_context(repl): - old_argv = sys.argv[:] - sys.argv[:] = repl - yield - sys.argv[:] = old_argv + dist_path = os.path.join(d, 'distribute-test-fetcher-1.0.tar.gz') + with tarfile.open(dist_path, 'w:gz') as dist: + dist.add('setup.py') + yield dist_path @contextlib.contextmanager def tempdir_context(cd=lambda dir:None): -- cgit v1.2.3 From dea4120fdc2cd90d9d68d3ffbc6e2118aadde125 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 7 Apr 2012 12:16:56 -0400 Subject: Improved the MockServer so it now more effectively handles multiple requests (as any index server really must). Test now more accurately captures the working scenario. --HG-- branch : distribute extra : rebase_source : 8ee0afdd95219047e4700b85356792f6128b1fd8 --- setuptools/tests/server.py | 10 +++++----- setuptools/tests/test_easy_install.py | 10 ++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py index e04dcca5..8e06cc1d 100644 --- a/setuptools/tests/server.py +++ b/setuptools/tests/server.py @@ -61,7 +61,7 @@ class RequestRecorder(BaseHTTPServer.BaseHTTPRequestHandler): requests.append(self) self.send_response(200, 'OK') -class MockServer(HTTPServer): +class MockServer(HTTPServer, threading.Thread): """ A simple HTTP Server that records the requests made to it. """ @@ -70,11 +70,11 @@ class MockServer(HTTPServer): bind_and_activate=True): HTTPServer.__init__(self, server_address, RequestHandlerClass, bind_and_activate) - self.threads = [] + threading.Thread.__init__(self) + self.daemon = True - def handle_request_in_thread(self): - self.threads.append(threading.Thread(target = self.handle_request)) - # todo: ensure that threads are closed. + def run(self): + self.serve_forever() def url(self): return 'http://localhost:%(server_port)s/' % vars(self) diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 54e3cdf9..87d24bb7 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -9,6 +9,7 @@ import site import contextlib import textwrap import tarfile +import urlparse from setuptools.command.easy_install import easy_install, get_script_args, main from setuptools.command.easy_install import PthDistributions @@ -269,13 +270,14 @@ class TestSetupRequires(unittest.TestCase): """ # set up a server which will simulate an alternate package index. p_index = setuptools.tests.server.MockServer() - p_index.handle_request_in_thread() + p_index.start() + p_index_loc = urlparse.urlparse(p_index.url).netloc # create an sdist that has a build-time dependency. with TestSetupRequires.create_sdist() as dist_file: with tempdir_context() as temp_install_dir: with environment_context(PYTHONPATH=temp_install_dir): ei_params = ['--index-url', p_index.url, - '--allow-hosts', 'localhost', + '--allow-hosts', p_index_loc, '--exclude-scripts', '--install-dir', temp_install_dir, dist_file] # attempt to install the dist. It should fail because @@ -283,8 +285,8 @@ class TestSetupRequires(unittest.TestCase): self.assertRaises(SystemExit, easy_install_pkg.main, ei_params) #self.assertTrue(os.listdir(temp_install_dir)) - self.assertEqual(len(p_index.requests), 1) - self.assertEqual(p_index.requests[0].path, 'x') + self.assertEqual(len(p_index.requests), 2) + self.assertEqual(p_index.requests[0].path, '/does-not-exist/') @staticmethod @contextlib.contextmanager -- cgit v1.2.3 From 1a9a961d96c1f9c11719356d6f375cdfc17e7e6d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 7 Apr 2012 12:40:19 -0400 Subject: Test now constructs the tarfile completely in memory (avoiding accidentally writing over our own setup.py) --HG-- branch : distribute extra : rebase_source : ad8ec142238405edeee6dce51c05d382e53d1299 --- setuptools/tests/test_easy_install.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 87d24bb7..3f38d50f 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -10,6 +10,7 @@ import contextlib import textwrap import tarfile import urlparse +import StringIO from setuptools.command.easy_install import easy_install, get_script_args, main from setuptools.command.easy_install import PthDistributions @@ -296,18 +297,19 @@ class TestSetupRequires(unittest.TestCase): doesn't exist) """ with tempdir_context() as d: - with open('setup.py', 'wb') as setup_script: - setup_script.write(textwrap.dedent(""" - import setuptools - setuptools.setup( - name="distribute-test-fetcher", - version="1.0", - setup_requires = ['does-not-exist'], - ) - """).lstrip()) + setup_py = tarfile.TarInfo(name="setup.py") + setup_py_bytes = StringIO.StringIO(textwrap.dedent(""" + import setuptools + setuptools.setup( + name="distribute-test-fetcher", + version="1.0", + setup_requires = ['does-not-exist'], + ) + """).lstrip()) + setup_py.size = len(setup_py_bytes.buf) dist_path = os.path.join(d, 'distribute-test-fetcher-1.0.tar.gz') with tarfile.open(dist_path, 'w:gz') as dist: - dist.add('setup.py') + dist.addfile(setup_py, fileobj=setup_py_bytes) yield dist_path @contextlib.contextmanager -- cgit v1.2.3 From bf87c16fce3253d13370f9aa5a99473e646e439a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 7 Apr 2012 13:26:44 -0400 Subject: Set the argv context so that easy_install.main invokes the command as if it had been run from the command-line --HG-- branch : distribute extra : rebase_source : 4916aebae87b1d83dc27b494715c89dce1ce1e12 --- setuptools/tests/test_easy_install.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 3f38d50f..bec03ab5 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -281,11 +281,11 @@ class TestSetupRequires(unittest.TestCase): '--allow-hosts', p_index_loc, '--exclude-scripts', '--install-dir', temp_install_dir, dist_file] - # attempt to install the dist. It should fail because - # our fake server can't actually supply the dependency - self.assertRaises(SystemExit, - easy_install_pkg.main, ei_params) - #self.assertTrue(os.listdir(temp_install_dir)) + with argv_context(['easy_install']): + # attempt to install the dist. It should fail because + # it doesn't exist. + self.assertRaises(SystemExit, + easy_install_pkg.main, ei_params) self.assertEqual(len(p_index.requests), 2) self.assertEqual(p_index.requests[0].path, '/does-not-exist/') @@ -333,3 +333,10 @@ def environment_context(**updates): for key in updates: del os.environ[key] os.environ.update(old_env) + +@contextlib.contextmanager +def argv_context(repl): + old_argv = sys.argv[:] + sys.argv[:] = repl + yield + sys.argv[:] = old_argv -- cgit v1.2.3 From ed8d0afca6d513359e16b9e9acf409dd430b50de Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 7 Apr 2012 13:43:29 -0400 Subject: Added another context to reset the _setup_stop_context --HG-- branch : distribute extra : rebase_source : b31f921755cea6d2559c9f24f42b737aa80198e7 --- setuptools/tests/test_easy_install.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index bec03ab5..c5fb4d9d 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -11,6 +11,7 @@ import textwrap import tarfile import urlparse import StringIO +import distutils.core from setuptools.command.easy_install import easy_install, get_script_args, main from setuptools.command.easy_install import PthDistributions @@ -281,11 +282,12 @@ class TestSetupRequires(unittest.TestCase): '--allow-hosts', p_index_loc, '--exclude-scripts', '--install-dir', temp_install_dir, dist_file] - with argv_context(['easy_install']): - # attempt to install the dist. It should fail because - # it doesn't exist. - self.assertRaises(SystemExit, - easy_install_pkg.main, ei_params) + with reset_setup_stop_context(): + with argv_context(['easy_install']): + # attempt to install the dist. It should fail because + # it doesn't exist. + self.assertRaises(SystemExit, + easy_install_pkg.main, ei_params) self.assertEqual(len(p_index.requests), 2) self.assertEqual(p_index.requests[0].path, '/does-not-exist/') @@ -340,3 +342,16 @@ def argv_context(repl): sys.argv[:] = repl yield sys.argv[:] = old_argv + +@contextlib.contextmanager +def reset_setup_stop_context(): + """ + When the distribute tests are run using setup.py test, and then + one wants to invoke another setup() command (such as easy_install) + within those tests, it's necessary to reset the global variable + in distutils.core so that the setup() command will run naturally. + """ + setup_stop_after = distutils.core._setup_stop_after + distutils.core._setup_stop_after = None + yield + distutils.core._setup_stop_after = setup_stop_after -- cgit v1.2.3 From 2d43eef466ba091d132cd3da740770c686d19444 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 7 Apr 2012 13:51:20 -0400 Subject: Make sure to un-monkey-patch the Distribution class when running test_no_setup_cfg. Otherwise, it breaks other tests (notably the new test_setup_requires_honors_fetch_params). --HG-- branch : distribute extra : rebase_source : f54d67ea495c18ff1dc74d12ff96797e64abe5e1 --- setuptools/tests/test_easy_install.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index c5fb4d9d..d89c8ae3 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -103,7 +103,7 @@ class TestEasyInstallTest(unittest.TestCase): opts = self.command_options if 'easy_install' in opts: assert 'find_links' not in opts['easy_install'], msg - return self._old_parse_command_line + return self._old_parse_command_line() Distribution._old_parse_command_line = Distribution.parse_command_line Distribution.parse_command_line = _parse_command_line @@ -115,6 +115,7 @@ class TestEasyInstallTest(unittest.TestCase): finally: os.chdir(old_wd) shutil.rmtree(dir) + Distribution.parse_command_line = Distribution._old_parse_command_line def test_no_find_links(self): # new option '--no-find-links', that blocks find-links added at -- cgit v1.2.3 From 6f830000f642af576434c52c7d229584ee0fdbd1 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 7 Apr 2012 13:52:20 -0400 Subject: Add requests to the instance, so it's always available even if no requests were made. --HG-- branch : distribute extra : rebase_source : b4bf42ec3470eda7ccef8e05aaf1944b450cf5e9 --- setuptools/tests/server.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools') diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py index 8e06cc1d..8a149d36 100644 --- a/setuptools/tests/server.py +++ b/setuptools/tests/server.py @@ -72,6 +72,7 @@ class MockServer(HTTPServer, threading.Thread): bind_and_activate) threading.Thread.__init__(self) self.daemon = True + self.requests = [] def run(self): self.serve_forever() -- cgit v1.2.3 From 4de50ce1877161a6a5ea332c40bcbfafa5dc2994 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 8 Apr 2012 00:04:35 +0000 Subject: Converted new tests in test_easy_install to use call-back functions instead of with statements for Python2.4 compatibility. --HG-- branch : distribute extra : rebase_source : e7edcca83dc29038a6832501a0a8251f4f3856a6 --- setuptools/tests/test_easy_install.py | 83 +++++++++++++++++++++++------------ 1 file changed, 54 insertions(+), 29 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index d89c8ae3..5cf136df 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -275,31 +275,43 @@ class TestSetupRequires(unittest.TestCase): p_index = setuptools.tests.server.MockServer() p_index.start() p_index_loc = urlparse.urlparse(p_index.url).netloc - # create an sdist that has a build-time dependency. - with TestSetupRequires.create_sdist() as dist_file: - with tempdir_context() as temp_install_dir: - with environment_context(PYTHONPATH=temp_install_dir): + + # I realize this is all-but-impossible to read, because it was + # ported from some well-factored, safe code using 'with'. If you + # need to maintain this code, consider making the changes in + # the parent revision (of this comment) and then port the changes + # back for Python 2.4 (or deprecate Python 2.4). + + def install(dist_file): + def install_at(temp_install_dir): + def install_env(): ei_params = ['--index-url', p_index.url, '--allow-hosts', p_index_loc, '--exclude-scripts', '--install-dir', temp_install_dir, dist_file] - with reset_setup_stop_context(): - with argv_context(['easy_install']): + def install_clean_reset(): + def install_clean_argv(): # attempt to install the dist. It should fail because # it doesn't exist. self.assertRaises(SystemExit, easy_install_pkg.main, ei_params) + argv_context(install_clean_argv, ['easy_install']) + reset_setup_stop_context(install_clean_reset) + environment_context(install_env, PYTHONPATH=temp_install_dir) + tempdir_context(install_at) + + # create an sdist that has a build-time dependency. + self.create_sdist(install) + self.assertEqual(len(p_index.requests), 2) self.assertEqual(p_index.requests[0].path, '/does-not-exist/') - @staticmethod - @contextlib.contextmanager - def create_sdist(): + def create_sdist(self, installer): """ - Return an sdist with a setup_requires dependency (of something that - doesn't exist) + Create an sdist with a setup_requires dependency (of something that + doesn't exist) and invoke installer on it. """ - with tempdir_context() as d: + def build_sdist(dir): setup_py = tarfile.TarInfo(name="setup.py") setup_py_bytes = StringIO.StringIO(textwrap.dedent(""" import setuptools @@ -310,42 +322,53 @@ class TestSetupRequires(unittest.TestCase): ) """).lstrip()) setup_py.size = len(setup_py_bytes.buf) - dist_path = os.path.join(d, 'distribute-test-fetcher-1.0.tar.gz') - with tarfile.open(dist_path, 'w:gz') as dist: + dist_path = os.path.join(dir, 'distribute-test-fetcher-1.0.tar.gz') + dist = tarfile.open(dist_path, 'w:gz') + try: dist.addfile(setup_py, fileobj=setup_py_bytes) - yield dist_path + finally: + dist.close() + installer(dist_path) + tempdir_context(build_sdist) -@contextlib.contextmanager -def tempdir_context(cd=lambda dir:None): +def tempdir_context(f, cd=lambda dir:None): + """ + Invoke f in the context + """ temp_dir = tempfile.mkdtemp() orig_dir = os.getcwd() try: cd(temp_dir) - yield temp_dir + f(temp_dir) finally: cd(orig_dir) shutil.rmtree(temp_dir) -@contextlib.contextmanager -def environment_context(**updates): +def environment_context(f, **updates): + """ + Invoke f in the context + """ old_env = os.environ.copy() os.environ.update(updates) try: - yield + f() finally: for key in updates: del os.environ[key] os.environ.update(old_env) -@contextlib.contextmanager -def argv_context(repl): +def argv_context(f, repl): + """ + Invoke f in the context + """ old_argv = sys.argv[:] sys.argv[:] = repl - yield - sys.argv[:] = old_argv + try: + f() + finally: + sys.argv[:] = old_argv -@contextlib.contextmanager -def reset_setup_stop_context(): +def reset_setup_stop_context(f): """ When the distribute tests are run using setup.py test, and then one wants to invoke another setup() command (such as easy_install) @@ -354,5 +377,7 @@ def reset_setup_stop_context(): """ setup_stop_after = distutils.core._setup_stop_after distutils.core._setup_stop_after = None - yield - distutils.core._setup_stop_after = setup_stop_after + try: + f() + finally: + distutils.core._setup_stop_after = setup_stop_after -- cgit v1.2.3 From ad62e5caa3126d490127e486c92850afe36382a0 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 8 Apr 2012 00:11:57 +0000 Subject: Removed unused import --HG-- branch : distribute extra : rebase_source : 4bad5e1f1f1e377a8cb5ade411a8ad572f85abb6 --- setuptools/tests/test_easy_install.py | 1 - 1 file changed, 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 5cf136df..9cf3441d 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -6,7 +6,6 @@ import shutil import tempfile import unittest import site -import contextlib import textwrap import tarfile import urlparse -- cgit v1.2.3 From 94f0f93eb75b4ad956a1a1d602cfcc2405268b9d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 8 Apr 2012 00:22:47 +0000 Subject: Removed bind_and_activate parameters (not compatible with Python 2.4 --HG-- branch : distribute extra : rebase_source : bf2288bbb5fccc4aad0b8a09f5a444e0246c412e --- setuptools/tests/server.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py index 8a149d36..6b9fe6ac 100644 --- a/setuptools/tests/server.py +++ b/setuptools/tests/server.py @@ -19,10 +19,8 @@ class IndexServer(HTTPServer): s.stop() """ def __init__(self, server_address=('', 0), - RequestHandlerClass=SimpleHTTPRequestHandler, - bind_and_activate=True): - HTTPServer.__init__(self, server_address, RequestHandlerClass, - bind_and_activate) + RequestHandlerClass=SimpleHTTPRequestHandler): + HTTPServer.__init__(self, server_address, RequestHandlerClass) self._run = True def serve(self): @@ -66,10 +64,8 @@ class MockServer(HTTPServer, threading.Thread): A simple HTTP Server that records the requests made to it. """ def __init__(self, server_address=('', 0), - RequestHandlerClass=RequestRecorder, - bind_and_activate=True): - HTTPServer.__init__(self, server_address, RequestHandlerClass, - bind_and_activate) + RequestHandlerClass=RequestRecorder): + HTTPServer.__init__(self, server_address, RequestHandlerClass) threading.Thread.__init__(self) self.daemon = True self.requests = [] -- cgit v1.2.3 From 1b9b6071393b5b40921c0f6bbf95fcceed8029d4 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 8 Apr 2012 00:29:34 +0000 Subject: Fixed two issues for Python 2.4 compatibility. Tests now run again on Python 2.4 --HG-- branch : distribute extra : rebase_source : c6dc5ce8070ec42190d4d8eb6af28523d447f962 --- setuptools/tests/server.py | 2 +- setuptools/tests/test_easy_install.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py index 6b9fe6ac..7b5cacb9 100644 --- a/setuptools/tests/server.py +++ b/setuptools/tests/server.py @@ -67,7 +67,7 @@ class MockServer(HTTPServer, threading.Thread): RequestHandlerClass=RequestRecorder): HTTPServer.__init__(self, server_address, RequestHandlerClass) threading.Thread.__init__(self) - self.daemon = True + self.setDaemon(True) self.requests = [] def run(self): diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 9cf3441d..3f9b7724 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -273,7 +273,8 @@ class TestSetupRequires(unittest.TestCase): # set up a server which will simulate an alternate package index. p_index = setuptools.tests.server.MockServer() p_index.start() - p_index_loc = urlparse.urlparse(p_index.url).netloc + netloc = 1 + p_index_loc = urlparse.urlparse(p_index.url)[netloc] # I realize this is all-but-impossible to read, because it was # ported from some well-factored, safe code using 'with'. If you -- cgit v1.2.3 From abcb749df3c0d99caffa76a575f6e01b37002ea6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 9 Apr 2012 17:34:20 -0400 Subject: Fix one failing test per #277 --HG-- branch : distribute extra : rebase_source : 74d2107a0e4f5ecda5030fa8610dfd38a2bd5740 --- setuptools/tests/test_easy_install.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 3f9b7724..5577dd6a 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -321,7 +321,7 @@ class TestSetupRequires(unittest.TestCase): setup_requires = ['does-not-exist'], ) """).lstrip()) - setup_py.size = len(setup_py_bytes.buf) + setup_py.size = len(setup_py_bytes.getvalue()) dist_path = os.path.join(dir, 'distribute-test-fetcher-1.0.tar.gz') dist = tarfile.open(dist_path, 'w:gz') try: -- cgit v1.2.3 From 6d3883d96d604548dc1f6e5229c24595773b0655 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 14 Apr 2012 13:30:09 -0400 Subject: Fixed issue where some functions are excluded from the depends module on certain platforms. --HG-- branch : distribute extra : rebase_source : d689792420ad98950659e80782b4353da3560403 --- setuptools/tests/__init__.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py index fec3854d..db563766 100644 --- a/setuptools/tests/__init__.py +++ b/setuptools/tests/__init__.py @@ -12,8 +12,9 @@ from distutils.version import LooseVersion import unittest import setuptools.dist +import setuptools.depends as dep from setuptools import Feature -from setuptools.depends import Require, find_module, get_module_constant, extract_constant +from setuptools.depends import Require def additional_tests(): suite = unittest.TestSuite(( @@ -45,7 +46,9 @@ def makeSetup(**args): class DependsTests(unittest.TestCase): def testExtractConst(self): - if not extract_constant: return # skip on non-bytecode platforms + if not hasattr(dep, 'extract_constant'): + # skip on non-bytecode platforms + return def f1(): global x,y,z @@ -53,38 +56,43 @@ class DependsTests(unittest.TestCase): y = z # unrecognized name - self.assertEqual(extract_constant(f1.func_code,'q', -1), None) + self.assertEqual(dep.extract_constant(f1.func_code,'q', -1), None) # constant assigned - self.assertEqual(extract_constant(f1.func_code,'x', -1), "test") + self.assertEqual(dep.extract_constant(f1.func_code,'x', -1), "test") # expression assigned - self.assertEqual(extract_constant(f1.func_code,'y', -1), -1) + self.assertEqual(dep.extract_constant(f1.func_code,'y', -1), -1) # recognized name, not assigned - self.assertEqual(extract_constant(f1.func_code,'z', -1), None) + self.assertEqual(dep.extract_constant(f1.func_code,'z', -1), None) def testFindModule(self): - self.assertRaises(ImportError, find_module, 'no-such.-thing') - self.assertRaises(ImportError, find_module, 'setuptools.non-existent') - f,p,i = find_module('setuptools.tests'); f.close() + self.assertRaises(ImportError, dep.find_module, 'no-such.-thing') + self.assertRaises(ImportError, dep.find_module, 'setuptools.non-existent') + f,p,i = dep.find_module('setuptools.tests'); f.close() def testModuleExtract(self): - if not get_module_constant: return # skip on non-bytecode platforms + if not hasattr(dep, 'get_module_constant'): + # skip on non-bytecode platforms + return + from email import __version__ self.assertEqual( - get_module_constant('email','__version__'), __version__ + dep.get_module_constant('email','__version__'), __version__ ) self.assertEqual( - get_module_constant('sys','version'), sys.version + dep.get_module_constant('sys','version'), sys.version ) self.assertEqual( - get_module_constant('setuptools.tests','__doc__'),__doc__ + dep.get_module_constant('setuptools.tests','__doc__'),__doc__ ) def testRequire(self): - if not extract_constant: return # skip on non-bytecode platforms + if not hasattr(dep, 'extract_constant'): + # skip on non-bytecode platformsh + return req = Require('Email','1.0.3','email') -- cgit v1.2.3 From 4c40b36f11a8b4a8025e5ab15d39403c6d4ca88a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 14 Apr 2012 18:17:54 +0000 Subject: Fixed test failures in the doctests on Python 3. --HG-- branch : distribute extra : rebase_source : e3c57d5c2650be765d7e152e191f7c7a0e7c578d --- setuptools/tests/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py index fec3854d..78ac920f 100644 --- a/setuptools/tests/__init__.py +++ b/setuptools/tests/__init__.py @@ -1,6 +1,7 @@ """Tests for the 'setuptools' package""" import sys import os +import unittest import doctest import distutils.core import distutils.cmd @@ -9,13 +10,12 @@ from distutils.errors import DistutilsSetupError from distutils.core import Extension from distutils.version import LooseVersion -import unittest - import setuptools.dist from setuptools import Feature from setuptools.depends import Require, find_module, get_module_constant, extract_constant def additional_tests(): + import doctest, unittest suite = unittest.TestSuite(( doctest.DocFileSuite( os.path.join('tests', 'api_tests.txt'), -- cgit v1.2.3 From 856ff28c515c35ad35db6661d0b74579f59c3e4c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 14 Apr 2012 18:31:52 +0000 Subject: Ensure that the setup.py is generated as bytes on Python 2 and 3 so that the tarfile module will accept it. --HG-- branch : distribute extra : rebase_source : 07afe24875bff3a4892319e02ae66be0d3725c8e --- setuptools/tests/test_easy_install.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 5577dd6a..cf2f91d6 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -313,14 +313,19 @@ class TestSetupRequires(unittest.TestCase): """ def build_sdist(dir): setup_py = tarfile.TarInfo(name="setup.py") - setup_py_bytes = StringIO.StringIO(textwrap.dedent(""" + try: + # Python 3 (StringIO gets converted to io module) + MemFile = StringIO.BytesIO + except AttributeError: + MemFile = StringIO.StringIO + setup_py_bytes = MemFile(textwrap.dedent(""" import setuptools setuptools.setup( name="distribute-test-fetcher", version="1.0", setup_requires = ['does-not-exist'], ) - """).lstrip()) + """).lstrip().encode('utf-8')) setup_py.size = len(setup_py_bytes.getvalue()) dist_path = os.path.join(dir, 'distribute-test-fetcher-1.0.tar.gz') dist = tarfile.open(dist_path, 'w:gz') -- cgit v1.2.3 From 347b49d545fbd9e8b2ef50f0778507fce84d2b19 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 15 Apr 2012 11:41:46 -0400 Subject: Skip test when MockServer can't detect the port to which it bound. --HG-- branch : distribute extra : rebase_source : c59caee49fcfb2e0d9b507fb1a01dfb2ddcdcdc8 --- setuptools/tests/test_easy_install.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index cf2f91d6..6fd45e8b 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -275,6 +275,10 @@ class TestSetupRequires(unittest.TestCase): p_index.start() netloc = 1 p_index_loc = urlparse.urlparse(p_index.url)[netloc] + if p_index_loc.endswith(':0'): + # Some platforms (Jython) don't find a port to which to bind, + # so skip this test for them. + return # I realize this is all-but-impossible to read, because it was # ported from some well-factored, safe code using 'with'. If you -- cgit v1.2.3 From 1e64c9a55bc6e7b4560966b95c831d6ee8276295 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 15 Apr 2012 13:35:52 -0400 Subject: Split one test 'bad urls' into several different tests (for clarity). --HG-- branch : distribute extra : rebase_source : cdc7ce4fe999eb578df356ec6a2d44b65312d7d9 --- setuptools/tests/test_packageindex.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 00d44ca6..3a8808f7 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -1,15 +1,15 @@ """Package Index Tests """ -# More would be better! import sys -import os, shutil, tempfile, unittest, urllib2 +import unittest +import urllib2 import pkg_resources import setuptools.package_index from server import IndexServer class TestPackageIndex(unittest.TestCase): - def test_bad_urls(self): + def test_bad_url_bad_port(self): index = setuptools.package_index.PackageIndex() url = 'http://127.0.0.1:0/nonesuch/test_package_index' try: @@ -19,6 +19,7 @@ class TestPackageIndex(unittest.TestCase): else: self.assert_(isinstance(v,urllib2.HTTPError)) + def test_bad_url_typo(self): # issue 16 # easy_install inquant.contentmirror.plone breaks because of a typo # in its home URL @@ -34,6 +35,11 @@ class TestPackageIndex(unittest.TestCase): else: self.assert_(isinstance(v, urllib2.HTTPError)) + def test_bad_url_bad_status_line(self): + index = setuptools.package_index.PackageIndex( + hosts=('www.example.com',) + ) + def _urlopen(*args): import httplib raise httplib.BadStatusLine('line') @@ -51,6 +57,11 @@ class TestPackageIndex(unittest.TestCase): finally: urllib2.urlopen = old_urlopen + def test_bad_url_double_scheme(self): + index = setuptools.package_index.PackageIndex( + hosts=('www.example.com',) + ) + # issue 20 url = 'http://http://svn.pythonpaste.org/Paste/wphp/trunk' try: @@ -58,6 +69,10 @@ class TestPackageIndex(unittest.TestCase): except Exception, v: self.assert_('nonnumeric port' in str(v)) + def test_bad_url_screwy_href(self): + index = setuptools.package_index.PackageIndex( + hosts=('www.example.com',) + ) # issue #160 if sys.version_info[0] == 2 and sys.version_info[1] == 7: @@ -67,7 +82,6 @@ class TestPackageIndex(unittest.TestCase): 'http://www.famfamfam.com/">') index.process_index(url, page) - def test_url_ok(self): index = setuptools.package_index.PackageIndex( hosts=('www.example.com',) -- cgit v1.2.3 From 9f2aec42c42499d265215db77cc0e242711e034b Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 15 Apr 2012 13:36:30 -0400 Subject: Skip another test that fails on Jython due to port 0 binding behavior. --HG-- branch : distribute extra : rebase_source : 7cd547b51b3db433b6f3040f01b1533065af3d96 --- setuptools/tests/test_packageindex.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'setuptools') diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 3a8808f7..1319547b 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -104,6 +104,10 @@ class TestPackageIndex(unittest.TestCase): is used -> Distribute should use the link from pypi, not the external one. """ + if sys.platform.startswith('java'): + # Skip this test on jython because binding to :0 fails + return + # start an index server server = IndexServer() server.start() -- cgit v1.2.3 From 0f29131df992aff401a8157931e419570826acaa Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 15 Apr 2012 13:41:52 -0400 Subject: Allow for three requests (fixes test on Python 3.3). --HG-- branch : distribute extra : rebase_source : 42f8c571b3296488b167aaa863bdbfa771f6a9d9 --- setuptools/tests/test_easy_install.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 6fd45e8b..7c807fc3 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -307,7 +307,9 @@ class TestSetupRequires(unittest.TestCase): # create an sdist that has a build-time dependency. self.create_sdist(install) - self.assertEqual(len(p_index.requests), 2) + # there should have been two or three requests to the server + # (three happens on Python 3.3a) + self.assert_(2 <= len(p_index.requests) <= 3) self.assertEqual(p_index.requests[0].path, '/does-not-exist/') def create_sdist(self, installer): -- cgit v1.2.3 From 8b6d10f3443e8f9b8d662097d496392a4e7ed599 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 16 Apr 2012 15:30:31 -0400 Subject: Fix typo in protocol_version. Thanks aclark! --HG-- branch : distribute extra : rebase_source : ab90cfb5cae3189b8d0c71c43992bc0273a7587a --- setuptools/command/upload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/upload.py b/setuptools/command/upload.py index 4bd6021d..9f9366b5 100755 --- a/setuptools/command/upload.py +++ b/setuptools/command/upload.py @@ -92,7 +92,7 @@ class upload(Command): comment = "built on %s" % platform.platform(terse=1) data = { ':action':'file_upload', - 'protcol_version':'1', + 'protocol_version':'1', 'name':self.distribution.get_name(), 'version':self.distribution.get_version(), 'content':(basename,content), -- cgit v1.2.3 From 76f2440a4dad4038f4d3aadcd64e33e9ef22ad6e Mon Sep 17 00:00:00 2001 From: Alex Clark Date: Sun, 22 Apr 2012 21:41:29 -0400 Subject: README.rst is now a standard --HG-- branch : distribute extra : rebase_source : 261a30d0a7ec63b1ff4918d7906476a19945b288 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index c49839cd..1f88e93b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -155,7 +155,7 @@ class sdist(_sdist): dist_files.append(data) def add_defaults(self): - standards = [('README', 'README.txt'), + standards = [('README', 'README.rst', 'README.txt'), self.distribution.script_name] for fn in standards: if isinstance(fn, tuple): -- cgit v1.2.3 From 8dde28ee529c74d578e8142dfbb0a537a8bf0414 Mon Sep 17 00:00:00 2001 From: Justin Azoff Date: Sat, 12 May 2012 19:01:44 -0400 Subject: When writing out scripts, respect the users umask --HG-- branch : distribute extra : rebase_source : d4fc14bcdcd3e1a45da8bdcdef490537863ece35 --- setuptools/command/easy_install.py | 10 ++++++++-- setuptools/command/install_scripts.py | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index dfd9f7ff..49a2c41e 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -10,7 +10,7 @@ file, or visit the `EasyInstall home page`__. __ http://packages.python.org/distribute/easy_install.html """ -import sys, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random +import sys, os, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random from glob import glob from setuptools import Command, _dont_write_bytecode from setuptools.sandbox import run_setup @@ -762,12 +762,13 @@ Please make the appropriate changes for your system and try again. target = os.path.join(self.script_dir, script_name) self.add_output(target) + mask = current_umask() if not self.dry_run: ensure_directory(target) f = open(target,"w"+mode) f.write(contents) f.close() - chmod(target,0755) + chmod(target, 0777-mask) @@ -1870,6 +1871,11 @@ def rmtree(path, ignore_errors=False, onerror=auto_chmod): except os.error: onerror(os.rmdir, path, sys.exc_info()) +def current_umask(): + tmp = os.umask(022) + os.umask(tmp) + return tmp + def bootstrap(): # This function is called when setuptools*.egg is run using /bin/sh import setuptools; argv0 = os.path.dirname(setuptools.__path__[0]) diff --git a/setuptools/command/install_scripts.py b/setuptools/command/install_scripts.py index 6ce1b993..82456035 100755 --- a/setuptools/command/install_scripts.py +++ b/setuptools/command/install_scripts.py @@ -39,15 +39,16 @@ class install_scripts(_install_scripts): def write_script(self, script_name, contents, mode="t", *ignored): """Write an executable file to the scripts directory""" - from setuptools.command.easy_install import chmod + from setuptools.command.easy_install import chmod, current_umask log.info("Installing %s script to %s", script_name, self.install_dir) target = os.path.join(self.install_dir, script_name) self.outfiles.append(target) + mask = current_umask() if not self.dry_run: ensure_directory(target) f = open(target,"w"+mode) f.write(contents) f.close() - chmod(target,0755) + chmod(target, 0777-mask) -- cgit v1.2.3 From f568de0c10f5d67ef9a91b8609997dbdf4ecce3d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 18 May 2012 15:03:48 -0400 Subject: Exclude 'encodings' modules when removing modules from sys.modules. Workaround for #285. (Fixes #285) --HG-- branch : distribute extra : rebase_source : 913eaebbb0971a044d6087dc4faa2fdb4220def2 --- setuptools/sandbox.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index 8e0c09b5..ab2543d9 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -39,8 +39,14 @@ def run_setup(setup_script, args): finally: pkg_resources.__setstate__(pr_state) sys.modules.update(save_modules) - for key in list(sys.modules): - if key not in save_modules: del sys.modules[key] + # remove any modules imported within the sandbox + del_modules = [ + mod_name for mod_name in sys.modules + if mod_name not in save_modules + # exclude any encodings modules. See #285 + and not mod_name.startswith('encodings.') + ] + map(sys.modules.__delitem__, del_modules) os.chdir(old_dir) sys.path[:] = save_path sys.argv[:] = save_argv -- cgit v1.2.3 From adc4fbb184e9b410744cc1c91d4832b2235de2a7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Fri, 18 May 2012 15:43:21 -0400 Subject: Fixed failing test on Python 2.7.3 (and probably other recent patch releases) --HG-- branch : distribute extra : rebase_source : 02f36e126ad338fb224b0904cce9eca61269ea0a --- setuptools/tests/test_packageindex.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 3a8808f7..5e424dd6 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -4,6 +4,8 @@ import sys import unittest import urllib2 import pkg_resources +import httplib +import distutils.errors import setuptools.package_index from server import IndexServer @@ -66,8 +68,12 @@ class TestPackageIndex(unittest.TestCase): url = 'http://http://svn.pythonpaste.org/Paste/wphp/trunk' try: index.open_url(url) - except Exception, v: - self.assert_('nonnumeric port' in str(v)) + except distutils.errors.DistutilsError, error: + # Python 2.7.3 + self.assert_('getaddrinfo failed' in str(error)) + except httplib.InvalidURL, error: + # Python 2.7.2 and earlier + self.assert_('nonnumeric port' in str(error)) def test_bad_url_screwy_href(self): index = setuptools.package_index.PackageIndex( -- cgit v1.2.3 From 311fb781f87f8885d9a94343b4b7e9731bc0c9e7 Mon Sep 17 00:00:00 2001 From: Marc Abramowitz Date: Tue, 26 Jun 2012 15:15:27 -0700 Subject: Add tests and fix for marshal.load of pyc files on Python 3.3 Fixes https://bitbucket.org/tarek/distribute/issue/283/bdist_egg-issues-with-python-330ax --HG-- branch : distribute extra : rebase_source : ec6f2611d3f8a54b7e11cfadf9d03fdcdef39639 --- setuptools/command/bdist_egg.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 68ca15c7..0ee9c55b 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -426,7 +426,11 @@ def scan_module(egg_dir, base, name, stubs): pkg = base[len(egg_dir)+1:].replace(os.sep,'.') module = pkg+(pkg and '.' or '')+os.path.splitext(name)[0] f = open(filename,'rb'); f.read(8) # skip magic & date - code = marshal.load(f); f.close() + try: + code = marshal.load(f); f.close() + except ValueError: + f.seek(0); f.read(12) # skip magic & date & file size; file size added in Python 3.3 + code = marshal.load(f); f.close() safe = True symbols = dict.fromkeys(iter_symbols(code)) for bad in ['__file__', '__path__']: -- cgit v1.2.3 From b73bf20cea512d0d95a29db4fd9ed837130c54fc Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Sat, 7 Jul 2012 23:24:20 -0400 Subject: test .dist-info distributions --HG-- branch : distribute extra : rebase_source : ea6870d73aa69f2deacc50beb2e257d3c21073e4 --- setuptools/tests/test_dist_info.py | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 setuptools/tests/test_dist_info.py (limited to 'setuptools') diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py new file mode 100644 index 00000000..c40886d3 --- /dev/null +++ b/setuptools/tests/test_dist_info.py @@ -0,0 +1,55 @@ +"""Test .dist-info style distributions. +""" +import os, shutil, tempfile, unittest +import pkg_resources +from pkg_resources import Requirement + +class TestDistInfo(unittest.TestCase): + + def test_distinfo(self): + dists = {} + for d in pkg_resources.find_distributions(self.tmpdir): + dists[d.project_name] = d + + unversioned = dists['UnversionedDistribution'] + versioned = dists['VersionedDistribution'] + + assert versioned.version == '2.718' # from filename + assert unversioned.version == '0.3' # from METADATA + + requires = [Requirement.parse('splort==4'), + Requirement.parse('quux>=1.1')] + + for d in (unversioned, versioned): + self.assertEquals(d.requires(), requires[:1]) + self.assertEquals(d.requires(extras=('baz',)), requires) + self.assertEquals(d.extras, ['baz']) + + def setUp(self): + self.tmpdir = tempfile.mkdtemp() + versioned = os.path.join(self.tmpdir, + 'VersionedDistribution-2.718.dist-info') + os.mkdir(versioned) + open(os.path.join(versioned, 'METADATA'), 'w+').write( +"""Metadata-Version: 1.2 +Name: VersionedDistribution +Requires-Dist: splort (4) +Provides-Extra: baz +Requires-Dist: quux (>=1.1); extra == 'baz' +""") + + unversioned = os.path.join(self.tmpdir, + 'UnversionedDistribution.dist-info') + os.mkdir(unversioned) + open(os.path.join(unversioned, 'METADATA'), 'w+').write( +"""Metadata-Version: 1.2 +Name: UnversionedDistribution +Version: 0.3 +Requires-Dist: splort (==4) +Provides-Extra: baz +Requires-Dist: quux (>=1.1); extra == 'baz' +""") + + def tearDown(self): + shutil.rmtree(self.tmpdir) + -- cgit v1.2.3 From c62d8121c4660daa4fd6132643b8e98918faf58f Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Sat, 7 Jul 2012 23:34:12 -0400 Subject: improve .dist-info test --HG-- branch : distribute extra : rebase_source : 23b6b4023d413bf1b27b114687da8736a4b38d8b --- setuptools/tests/test_dist_info.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index c40886d3..119cc68b 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -3,6 +3,11 @@ import os, shutil, tempfile, unittest import pkg_resources from pkg_resources import Requirement +try: + import markerlib + has_markerlib = True +except: + has_markerlib = False class TestDistInfo(unittest.TestCase): @@ -11,19 +16,24 @@ class TestDistInfo(unittest.TestCase): for d in pkg_resources.find_distributions(self.tmpdir): dists[d.project_name] = d + assert len(dists) == 2, dists + unversioned = dists['UnversionedDistribution'] versioned = dists['VersionedDistribution'] assert versioned.version == '2.718' # from filename assert unversioned.version == '0.3' # from METADATA - + + @unittest.skipIf(not has_markerlib, + "install markerlib to test conditional dependencies") + def test_conditional_dependencies(self): requires = [Requirement.parse('splort==4'), Requirement.parse('quux>=1.1')] - for d in (unversioned, versioned): + for d in pkg_resources.find_distributions(self.tmpdir): self.assertEquals(d.requires(), requires[:1]) self.assertEquals(d.requires(extras=('baz',)), requires) - self.assertEquals(d.extras, ['baz']) + self.assertEquals(d.extras, ['baz']) def setUp(self): self.tmpdir = tempfile.mkdtemp() -- cgit v1.2.3 From 12c0d7f3e916957294a095a8425554fe8413e42e Mon Sep 17 00:00:00 2001 From: Jim Fulton Date: Sat, 14 Jul 2012 14:25:06 -0400 Subject: Issue #283 bdist_egg issues with python 3.3.0aX --HG-- branch : distribute extra : rebase_source : 3173cb1ab5550635b8565767059701ab2649ac19 --- setuptools/command/bdist_egg.py | 2 ++ setuptools/tests/test_bdist_egg.py | 69 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 setuptools/tests/test_bdist_egg.py (limited to 'setuptools') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 68ca15c7..a9d98d3b 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -459,6 +459,8 @@ def iter_symbols(code): yield name def can_scan(): + if sys.version_info > (3, 3): + return False # Can't scan recent formats if not sys.platform.startswith('java') and sys.platform != 'cli': # CPython, PyPy, etc. return True diff --git a/setuptools/tests/test_bdist_egg.py b/setuptools/tests/test_bdist_egg.py new file mode 100644 index 00000000..7da122cc --- /dev/null +++ b/setuptools/tests/test_bdist_egg.py @@ -0,0 +1,69 @@ +"""develop tests +""" +import sys +import os, re, shutil, tempfile, unittest +import tempfile +import site +from StringIO import StringIO + +from distutils.errors import DistutilsError +from setuptools.command.bdist_egg import bdist_egg +from setuptools.command import easy_install as easy_install_pkg +from setuptools.dist import Distribution + +SETUP_PY = """\ +from setuptools import setup + +setup(name='foo', py_modules=['hi']) +""" + +class TestDevelopTest(unittest.TestCase): + + def setUp(self): + self.dir = tempfile.mkdtemp() + self.old_cwd = os.getcwd() + os.chdir(self.dir) + f = open('setup.py', 'w') + f.write(SETUP_PY) + f.close() + f = open('hi.py', 'w') + f.write('1\n') + f.close() + if sys.version >= "2.6": + self.old_base = site.USER_BASE + site.USER_BASE = tempfile.mkdtemp() + self.old_site = site.USER_SITE + site.USER_SITE = tempfile.mkdtemp() + + def tearDown(self): + os.chdir(self.old_cwd) + shutil.rmtree(self.dir) + if sys.version >= "2.6": + shutil.rmtree(site.USER_BASE) + shutil.rmtree(site.USER_SITE) + site.USER_BASE = self.old_base + site.USER_SITE = self.old_site + + def test_bdist_egg(self): + dist = Distribution(dict( + script_name='setup.py', + script_args=['bdist_egg'], + name='foo', + py_modules=['hi'] + )) + os.makedirs(os.path.join('build', 'src')) + old_stdout = sys.stdout + sys.stdout = o = StringIO() + try: + dist.parse_command_line() + dist.run_commands() + finally: + sys.stdout = old_stdout + + # let's see if we got our egg link at the right place + [content] = os.listdir('dist') + self.assertTrue(re.match('foo-0.0.0-py[23].\d.egg$', content)) + +def test_suite(): + return unittest.makeSuite(TestDevelopTest) + -- cgit v1.2.3 From cbb03edb6cf43016eed584f42506458893e4be05 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 21 Jul 2012 17:04:33 -0400 Subject: Reorganized imports --HG-- branch : distribute extra : rebase_source : 6836f95f7e0668d6bd3e34f915d16de21d4f3731 --- setuptools/command/easy_install.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 49a2c41e..f2260236 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -10,7 +10,15 @@ file, or visit the `EasyInstall home page`__. __ http://packages.python.org/distribute/easy_install.html """ -import sys, os, os.path, zipimport, shutil, tempfile, zipfile, re, stat, random +import sys +import os +import zipimport +import shutil +import tempfile +import zipfile +import re +import stat +import random from glob import glob from setuptools import Command, _dont_write_bytecode from setuptools.sandbox import run_setup -- cgit v1.2.3 From 9d94aa8feb11530c01dbc9d594f4a5f5c20740ea Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jul 2012 15:15:53 -0400 Subject: Updated imports, removed excess whitespace --HG-- branch : distribute extra : rebase_source : a2cc4dde8a9a5de8c92e277099610e507fce2973 --- setuptools/tests/test_dist_info.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index 119cc68b..fede54da 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -1,6 +1,10 @@ """Test .dist-info style distributions. """ -import os, shutil, tempfile, unittest +import os +import shutil +import tempfile +import unittest + import pkg_resources from pkg_resources import Requirement try: @@ -15,29 +19,29 @@ class TestDistInfo(unittest.TestCase): dists = {} for d in pkg_resources.find_distributions(self.tmpdir): dists[d.project_name] = d - + assert len(dists) == 2, dists - + unversioned = dists['UnversionedDistribution'] versioned = dists['VersionedDistribution'] - - assert versioned.version == '2.718' # from filename + + assert versioned.version == '2.718' # from filename assert unversioned.version == '0.3' # from METADATA - - @unittest.skipIf(not has_markerlib, - "install markerlib to test conditional dependencies") + + @unittest.skipIf(not has_markerlib, + "install markerlib to test conditional dependencies") def test_conditional_dependencies(self): - requires = [Requirement.parse('splort==4'), + requires = [Requirement.parse('splort==4'), Requirement.parse('quux>=1.1')] - + for d in pkg_resources.find_distributions(self.tmpdir): self.assertEquals(d.requires(), requires[:1]) self.assertEquals(d.requires(extras=('baz',)), requires) - self.assertEquals(d.extras, ['baz']) + self.assertEquals(d.extras, ['baz']) def setUp(self): self.tmpdir = tempfile.mkdtemp() - versioned = os.path.join(self.tmpdir, + versioned = os.path.join(self.tmpdir, 'VersionedDistribution-2.718.dist-info') os.mkdir(versioned) open(os.path.join(versioned, 'METADATA'), 'w+').write( @@ -48,7 +52,7 @@ Provides-Extra: baz Requires-Dist: quux (>=1.1); extra == 'baz' """) - unversioned = os.path.join(self.tmpdir, + unversioned = os.path.join(self.tmpdir, 'UnversionedDistribution.dist-info') os.mkdir(unversioned) open(os.path.join(unversioned, 'METADATA'), 'w+').write( @@ -62,4 +66,3 @@ Requires-Dist: quux (>=1.1); extra == 'baz' def tearDown(self): shutil.rmtree(self.tmpdir) - -- cgit v1.2.3 From 4f7bf7c846ae9761bd10a44f60c656b9741d69be Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jul 2012 15:21:02 -0400 Subject: Use DALS to avoid breaking indentation in test setup. Removed flag indicating presence of module. --HG-- branch : distribute extra : rebase_source : 48d8347f667ec05c28505bc76880dcd64dc43204 --- setuptools/tests/test_dist_info.py | 48 +++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index fede54da..318cd973 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -4,14 +4,18 @@ import os import shutil import tempfile import unittest +import textwrap -import pkg_resources -from pkg_resources import Requirement try: import markerlib - has_markerlib = True except: - has_markerlib = False + pass + +import pkg_resources + +def DALS(s): + "dedent and left-strip" + return textwrap.dedent(s).lstrip() class TestDistInfo(unittest.TestCase): @@ -28,11 +32,11 @@ class TestDistInfo(unittest.TestCase): assert versioned.version == '2.718' # from filename assert unversioned.version == '0.3' # from METADATA - @unittest.skipIf(not has_markerlib, + @unittest.skipIf('markerlib' not in globals(), "install markerlib to test conditional dependencies") def test_conditional_dependencies(self): - requires = [Requirement.parse('splort==4'), - Requirement.parse('quux>=1.1')] + requires = [pkg_resources.Requirement.parse('splort==4'), + pkg_resources.Requirement.parse('quux>=1.1')] for d in pkg_resources.find_distributions(self.tmpdir): self.assertEquals(d.requires(), requires[:1]) @@ -44,25 +48,25 @@ class TestDistInfo(unittest.TestCase): versioned = os.path.join(self.tmpdir, 'VersionedDistribution-2.718.dist-info') os.mkdir(versioned) - open(os.path.join(versioned, 'METADATA'), 'w+').write( -"""Metadata-Version: 1.2 -Name: VersionedDistribution -Requires-Dist: splort (4) -Provides-Extra: baz -Requires-Dist: quux (>=1.1); extra == 'baz' -""") + open(os.path.join(versioned, 'METADATA'), 'w+').write(DALS( + """Metadata-Version: 1.2 + Name: VersionedDistribution + Requires-Dist: splort (4) + Provides-Extra: baz + Requires-Dist: quux (>=1.1); extra == 'baz' + """)) unversioned = os.path.join(self.tmpdir, 'UnversionedDistribution.dist-info') os.mkdir(unversioned) - open(os.path.join(unversioned, 'METADATA'), 'w+').write( -"""Metadata-Version: 1.2 -Name: UnversionedDistribution -Version: 0.3 -Requires-Dist: splort (==4) -Provides-Extra: baz -Requires-Dist: quux (>=1.1); extra == 'baz' -""") + open(os.path.join(unversioned, 'METADATA'), 'w+').write(DALS( + """Metadata-Version: 1.2 + Name: UnversionedDistribution + Version: 0.3 + Requires-Dist: splort (==4) + Provides-Extra: baz + Requires-Dist: quux (>=1.1); extra == 'baz' + """)) def tearDown(self): shutil.rmtree(self.tmpdir) -- cgit v1.2.3 From 2cbbedf7be98fd3f43ab8897f68e36c18e2bef9a Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jul 2012 15:35:47 -0400 Subject: Added python 2.4-2.6 support for skipIf --HG-- branch : distribute extra : rebase_source : cac18ef7c3dbde38ceac3a0c71cfb3b5ffa56dd5 --- setuptools/tests/py26compat.py | 13 +++++++++++++ setuptools/tests/test_dist_info.py | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 setuptools/tests/py26compat.py (limited to 'setuptools') diff --git a/setuptools/tests/py26compat.py b/setuptools/tests/py26compat.py new file mode 100644 index 00000000..ddf2ceb0 --- /dev/null +++ b/setuptools/tests/py26compat.py @@ -0,0 +1,13 @@ +import unittest + +try: + # provide skipIf for Python 2.4-2.6 + skipIf = unittest.skipIf +except AttributeError: + def skipIf(condition, reason): + def skipper(func): + def skip(*args, **kwargs): + return + if condition: + return skip + return func diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index 318cd973..cf8fb0f9 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -13,6 +13,8 @@ except: import pkg_resources +from setuptools.tests.py26compat import skipIf + def DALS(s): "dedent and left-strip" return textwrap.dedent(s).lstrip() -- cgit v1.2.3 From e10bb776722f4dd1d5bcda17adcc557ea0eb8b14 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jul 2012 15:45:53 -0400 Subject: Use compatible skipIf --HG-- branch : distribute extra : rebase_source : 4964057db0c3186c1c8b9e934cf23f1b4ddcb167 --- setuptools/tests/test_dist_info.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index cf8fb0f9..68ba9e24 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -34,8 +34,8 @@ class TestDistInfo(unittest.TestCase): assert versioned.version == '2.718' # from filename assert unversioned.version == '0.3' # from METADATA - @unittest.skipIf('markerlib' not in globals(), - "install markerlib to test conditional dependencies") + @skipIf('markerlib' not in globals(), + "install markerlib to test conditional dependencies") def test_conditional_dependencies(self): requires = [pkg_resources.Requirement.parse('splort==4'), pkg_resources.Requirement.parse('quux>=1.1')] -- cgit v1.2.3 From 22366805a3a7b6292774491db04792851a341b6f Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jul 2012 15:51:14 -0400 Subject: Fix compatibility skipIf --HG-- branch : distribute extra : rebase_source : a70fd5755fad7a30c478c44e270c1dad13e66a47 --- setuptools/tests/py26compat.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools') diff --git a/setuptools/tests/py26compat.py b/setuptools/tests/py26compat.py index ddf2ceb0..d4fb891a 100644 --- a/setuptools/tests/py26compat.py +++ b/setuptools/tests/py26compat.py @@ -11,3 +11,4 @@ except AttributeError: if condition: return skip return func + return skipper -- cgit v1.2.3 From 0cb6b8bebf4f16d9187827d843f5cdd908067b09 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jul 2012 16:01:06 -0400 Subject: Expand error message to help detect why this test fails on travis --HG-- branch : distribute extra : rebase_source : 9182fc8c4544cde849fdac373b558f9078af1254 --- setuptools/tests/test_packageindex.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index f10b5ee8..776382d0 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -70,10 +70,12 @@ class TestPackageIndex(unittest.TestCase): index.open_url(url) except distutils.errors.DistutilsError, error: # Python 2.7.3 - self.assert_('getaddrinfo failed' in str(error)) + self.assertTrue('getaddrinfo failed' in str(error), "error was " + + str(error)) except httplib.InvalidURL, error: # Python 2.7.2 and earlier - self.assert_('nonnumeric port' in str(error)) + self.assertTrue('nonnumeric port' in str(error), "error was " + + str(error)) def test_bad_url_screwy_href(self): index = setuptools.package_index.PackageIndex( @@ -141,5 +143,3 @@ class TestPackageIndex(unittest.TestCase): 'reportlab-2.5.win-amd64-py2.7.exe'), ('reportlab-2.5', '2.7', 'win-amd64')) self.assertEqual(setuptools.package_index.parse_bdist_wininst( 'reportlab-2.5.win-amd64.exe'), ('reportlab-2.5', None, 'win-amd64')) - - -- cgit v1.2.3 From 6ee14089b193c7e179fc2a0472644f5684d8bef4 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jul 2012 16:26:37 -0400 Subject: Update this test again to ensure it's trapping the expected exception (DistutilsError) and ensuring that it captures the expected error messages. --HG-- branch : distribute extra : rebase_source : b66947d43758f4cbea407043dfbeffdf3aaf9b01 --- setuptools/tests/test_packageindex.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 5e424dd6..09e78bb3 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -60,6 +60,9 @@ class TestPackageIndex(unittest.TestCase): urllib2.urlopen = old_urlopen def test_bad_url_double_scheme(self): + """ + A bad URL with a double scheme should raise a DistutilsError. + """ index = setuptools.package_index.PackageIndex( hosts=('www.example.com',) ) @@ -69,11 +72,9 @@ class TestPackageIndex(unittest.TestCase): try: index.open_url(url) except distutils.errors.DistutilsError, error: - # Python 2.7.3 - self.assert_('getaddrinfo failed' in str(error)) - except httplib.InvalidURL, error: - # Python 2.7.2 and earlier - self.assert_('nonnumeric port' in str(error)) + msg = unicode(error) + assert 'nonnumeric port' in msg or 'getaddrinfo failed' in msg + raise RuntimeError("Did not raise") def test_bad_url_screwy_href(self): index = setuptools.package_index.PackageIndex( -- cgit v1.2.3 From 4b2a1a13fd5e01804b4fb281aea59407ccde43e8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sun, 22 Jul 2012 16:34:19 -0400 Subject: Don't raise when exception is caught --HG-- branch : distribute extra : rebase_source : 9da60528c7ace0a59bf1d92c6e155bba2e11ef18 --- setuptools/tests/test_packageindex.py | 1 + 1 file changed, 1 insertion(+) (limited to 'setuptools') diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 107a57b6..1b4d2fdf 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -74,6 +74,7 @@ class TestPackageIndex(unittest.TestCase): except distutils.errors.DistutilsError, error: msg = unicode(error) assert 'nonnumeric port' in msg or 'getaddrinfo failed' in msg + return raise RuntimeError("Did not raise") def test_bad_url_screwy_href(self): -- cgit v1.2.3 From 4084ebc22ff58d406b73fe25c069b5235f04c4d8 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Wed, 25 Jul 2012 05:11:56 +0200 Subject: Issue #283: Reenable scanning of *.pyc / *.pyo files on Python 3.3. Scanning of these files was fixed in commit 2479772eeea7. --HG-- branch : distribute extra : rebase_source : fcbb14f0e6efc2c42b691fa2a8920816903ede42 --- setuptools/command/bdist_egg.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index cf2d75e4..0ee9c55b 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -463,8 +463,6 @@ def iter_symbols(code): yield name def can_scan(): - if sys.version_info > (3, 3): - return False # Can't scan recent formats if not sys.platform.startswith('java') and sys.platform != 'cli': # CPython, PyPy, etc. return True -- cgit v1.2.3 From c8558d8d3b6c2cae273637ccec616489c2e7b439 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 17:29:47 +0200 Subject: Add failing test for #301. --HG-- branch : distribute extra : rebase_source : 2972e762cdab88e90c1c8b9b9a336afc641e996f --- setuptools/command/test.py | 3 +- setuptools/tests/test_test.py | 112 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 setuptools/tests/test_test.py (limited to 'setuptools') diff --git a/setuptools/command/test.py b/setuptools/command/test.py index b7aef969..59c10e84 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -141,9 +141,10 @@ class test(Command): import unittest loader_ep = EntryPoint.parse("x="+self.test_loader) loader_class = loader_ep.load(require=False) + cks = loader_class() unittest.main( None, None, [unittest.__file__]+self.test_args, - testLoader = loader_class() + testLoader = cks ) diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py new file mode 100644 index 00000000..7194399a --- /dev/null +++ b/setuptools/tests/test_test.py @@ -0,0 +1,112 @@ +"""develop tests +""" +import sys +import os, shutil, tempfile, unittest +import tempfile +import site +from StringIO import StringIO + +from distutils.errors import DistutilsError +from setuptools.command.test import test +from setuptools.command import easy_install as easy_install_pkg +from setuptools.dist import Distribution + +SETUP_PY = """\ +from setuptools import setup + +setup(name='foo') +""" + +NS_INIT = """try: + __import__('pkg_resources').declare_namespace(__name__) +except ImportError: + from pkgutil import extend_path + __path__ = extend_path(__path__, __name__) +""" +TEST_PY = """import unittest + +class TestTest(unittest.TestCase): + def test_test(self): + print "Foo" # Should fail under Python 3 unless 2to3 is used + +test_suite = unittest.makeSuite(TestTest) +""" + +class TestTestTest(unittest.TestCase): + + def setUp(self): + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + return + + # Directory structure + self.dir = tempfile.mkdtemp() + os.mkdir(os.path.join(self.dir, 'name')) + os.mkdir(os.path.join(self.dir, 'name', 'space')) + os.mkdir(os.path.join(self.dir, 'name', 'space', 'tests')) + # setup.py + setup = os.path.join(self.dir, 'setup.py') + f = open(setup, 'w') + f.write(SETUP_PY) + f.close() + self.old_cwd = os.getcwd() + # name/__init__.py + init = os.path.join(self.dir, 'name', '__init__.py') + f = open(init, 'w') + f.write(NS_INIT) + f.close() + # name/space/__init__.py + init = os.path.join(self.dir, 'name', 'space', '__init__.py') + f = open(init, 'w') + f.write('#empty\n') + f.close() + # name/space/tests/__init__.py + init = os.path.join(self.dir, 'name', 'space', 'tests', '__init__.py') + f = open(init, 'w') + f.write(TEST_PY) + f.close() + + os.chdir(self.dir) + self.old_base = site.USER_BASE + site.USER_BASE = tempfile.mkdtemp() + self.old_site = site.USER_SITE + site.USER_SITE = tempfile.mkdtemp() + + def tearDown(self): + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + return + + os.chdir(self.old_cwd) + shutil.rmtree(self.dir) + shutil.rmtree(site.USER_BASE) + shutil.rmtree(site.USER_SITE) + site.USER_BASE = self.old_base + site.USER_SITE = self.old_site + + def test_test(self): + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + return + + dist = Distribution(dict( + script_name='setup.py', + script_args=['bdist_egg'], + name='foo', + py_modules=['name'], + namespace_packages=['name'], + test_suite='name.space.tests.test_suite', + )) + dist.script_name = 'setup.py' + cmd = test(dist) + cmd.user = 1 + cmd.ensure_finalized() + cmd.install_dir = site.USER_SITE + cmd.user = 1 + old_stdout = sys.stdout + sys.stdout = StringIO() + try: + cmd.run() + except SystemExit: # The test runner calls sys.exit, stop that making an error. + pass + finally: + sys.stdout = old_stdout + +test_suite = unittest.makeSuite(TestTestTest) -- cgit v1.2.3 From 78ac59d4ab00868456155cd3f83be15f78acccf3 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 18:56:02 +0200 Subject: Once the test is correctly setup, the problem actually goes away. --HG-- branch : distribute extra : rebase_source : 8a1c310010599165aa973bb207b07616428df66b --- setuptools/tests/test_test.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 7194399a..5000f234 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -14,10 +14,15 @@ from setuptools.dist import Distribution SETUP_PY = """\ from setuptools import setup -setup(name='foo') +setup(name='foo', + packages=['name', 'name.space', 'name.space.tests'], + namespace_packages=['name'], + test_suite='name.space.tests.test_suite', +) """ -NS_INIT = """try: +NS_INIT = """ +try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path @@ -87,12 +92,11 @@ class TestTestTest(unittest.TestCase): return dist = Distribution(dict( - script_name='setup.py', - script_args=['bdist_egg'], name='foo', - py_modules=['name'], + packages=['name', 'name.space', 'name.space.tests'], namespace_packages=['name'], test_suite='name.space.tests.test_suite', + use_2to3=True, )) dist.script_name = 'setup.py' cmd = test(dist) -- cgit v1.2.3 From 61f4c9c4cbf148253c9e06f3e05757e01affeb6e Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 19:05:36 +0200 Subject: Added failing test for #299. --HG-- branch : distribute extra : rebase_source : 4a3ac76a6a49e06e1fecd1d6f4e08fa922f82f73 --- setuptools/tests/test_develop.py | 48 +++++++++++++++++++++++++++++++--------- setuptools/tests/test_test.py | 2 -- 2 files changed, 37 insertions(+), 13 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 5576d5e5..f345d8fc 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -14,33 +14,51 @@ from setuptools.dist import Distribution SETUP_PY = """\ from setuptools import setup -setup(name='foo') +setup(name='foo', + packages=['foo'], +) +""" + +INIT_PY = """print "foo" """ class TestDevelopTest(unittest.TestCase): def setUp(self): + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + return + + # Directory structure self.dir = tempfile.mkdtemp() + os.mkdir(os.path.join(self.dir, 'foo')) + # setup.py setup = os.path.join(self.dir, 'setup.py') f = open(setup, 'w') f.write(SETUP_PY) f.close() self.old_cwd = os.getcwd() + # foo/__init__.py + init = os.path.join(self.dir, 'foo', '__init__.py') + f = open(init, 'w') + f.write(INIT_PY) + f.close() + os.chdir(self.dir) - if sys.version >= "2.6": - self.old_base = site.USER_BASE - site.USER_BASE = tempfile.mkdtemp() - self.old_site = site.USER_SITE - site.USER_SITE = tempfile.mkdtemp() + self.old_base = site.USER_BASE + site.USER_BASE = tempfile.mkdtemp() + self.old_site = site.USER_SITE + site.USER_SITE = tempfile.mkdtemp() def tearDown(self): + if sys.version < "2.6" or hasattr(sys, 'real_prefix'): + return + os.chdir(self.old_cwd) shutil.rmtree(self.dir) - if sys.version >= "2.6": - shutil.rmtree(site.USER_BASE) - shutil.rmtree(site.USER_SITE) - site.USER_BASE = self.old_base - site.USER_SITE = self.old_site + shutil.rmtree(site.USER_BASE) + shutil.rmtree(site.USER_SITE) + site.USER_BASE = self.old_base + site.USER_SITE = self.old_site def test_develop(self): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): @@ -64,6 +82,14 @@ class TestDevelopTest(unittest.TestCase): content.sort() self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth']) + # Check that we are using the right code. + path = open(os.path.join(site.USER_SITE, 'UNKNOWN.egg-link'), 'rt').read().split()[0].strip() + init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip() + if sys.version < "3": + self.assertEquals(init, 'print "foo"') + else: + self.assertEquals(init, 'print("foo")') + def test_develop_with_setup_requires(self): wanted = ("Could not find suitable distribution for " diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 5000f234..87ccaf44 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -112,5 +112,3 @@ class TestTestTest(unittest.TestCase): pass finally: sys.stdout = old_stdout - -test_suite = unittest.makeSuite(TestTestTest) -- cgit v1.2.3 From 42afe54cf9e15ef655e7ed5fef9483682fcd5af2 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Tue, 21 Aug 2012 20:52:16 +0200 Subject: Added fix for the develop command, #299. --HG-- branch : distribute extra : rebase_source : ef69472e5a9ce97d9102578898e81e516f06497a --- setuptools/command/develop.py | 34 +++++++++++++++++++++++++++++----- setuptools/tests/test_develop.py | 16 +++++++++++----- setuptools/tests/test_test.py | 7 ++++--- 3 files changed, 44 insertions(+), 13 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index 93b7773c..c8bef72e 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -84,11 +84,35 @@ class develop(easy_install): " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): - # Ensure metadata is up-to-date - self.run_command('egg_info') - # Build extensions in-place - self.reinitialize_command('build_ext', inplace=1) - self.run_command('build_ext') + if getattr(self.distribution, 'use_2to3', False): + # If we run 2to3 we can not do this inplace: + + # Ensure metadata is up-to-date + self.reinitialize_command('build_py', inplace=0) + self.run_command('build_py') + bpy_cmd = self.get_finalized_command("build_py") + build_path = normalize_path(bpy_cmd.build_lib) + + # Build extensions + self.reinitialize_command('egg_info', egg_base=build_path) + self.run_command('egg_info') + + self.reinitialize_command('build_ext', inplace=0) + self.run_command('build_ext') + + # Fixup egg-link and easy-install.pth + ei_cmd = self.get_finalized_command("egg_info") + self.egg_path = build_path + self.dist.location = build_path + self.dist._provider = PathMetadata(build_path, ei_cmd.egg_info) # XXX + else: + # Without 2to3 inplace works fine: + self.run_command('egg_info') + + # Build extensions in-place + self.reinitialize_command('build_ext', inplace=1) + self.run_command('build_ext') + self.install_site_py() # ensure that target dir is site-safe if setuptools.bootstrap_install_from: self.easy_install(setuptools.bootstrap_install_from) diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index f345d8fc..fcf33c58 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -16,6 +16,7 @@ from setuptools import setup setup(name='foo', packages=['foo'], + use_2to3=True, ) """ @@ -63,7 +64,12 @@ class TestDevelopTest(unittest.TestCase): def test_develop(self): if sys.version < "2.6" or hasattr(sys, 'real_prefix'): return - dist = Distribution() + dist = Distribution( + dict(name='foo', + packages=['foo'], + use_2to3=True, + version='0.0', + )) dist.script_name = 'setup.py' cmd = develop(dist) cmd.user = 1 @@ -71,7 +77,7 @@ class TestDevelopTest(unittest.TestCase): cmd.install_dir = site.USER_SITE cmd.user = 1 old_stdout = sys.stdout - sys.stdout = StringIO() + #sys.stdout = StringIO() try: cmd.run() finally: @@ -80,17 +86,17 @@ class TestDevelopTest(unittest.TestCase): # let's see if we got our egg link at the right place content = os.listdir(site.USER_SITE) content.sort() - self.assertEquals(content, ['UNKNOWN.egg-link', 'easy-install.pth']) + self.assertEquals(content, ['easy-install.pth', 'foo.egg-link']) # Check that we are using the right code. - path = open(os.path.join(site.USER_SITE, 'UNKNOWN.egg-link'), 'rt').read().split()[0].strip() + path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip() init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip() if sys.version < "3": self.assertEquals(init, 'print "foo"') else: self.assertEquals(init, 'print("foo")') - def test_develop_with_setup_requires(self): + def notest_develop_with_setup_requires(self): wanted = ("Could not find suitable distribution for " "Requirement.parse('I-DONT-EXIST')") diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 87ccaf44..04134ec5 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -107,8 +107,9 @@ class TestTestTest(unittest.TestCase): old_stdout = sys.stdout sys.stdout = StringIO() try: - cmd.run() - except SystemExit: # The test runner calls sys.exit, stop that making an error. - pass + try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. + cmd.run() + except SystemExit: # The test runner calls sys.exit, stop that making an error. + pass finally: sys.stdout = old_stdout -- cgit v1.2.3 From e19d57773e1abb8d8f3f46417b07c1617d2d91ea Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 10:48:44 +0200 Subject: The error message changed in Python 3.3. --HG-- branch : distribute extra : rebase_source : 107ac0ce6d98f4b17f31a6f4c006b1ae2e21381b --- setuptools/tests/test_packageindex.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 1b4d2fdf..886befcb 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -73,7 +73,7 @@ class TestPackageIndex(unittest.TestCase): index.open_url(url) except distutils.errors.DistutilsError, error: msg = unicode(error) - assert 'nonnumeric port' in msg or 'getaddrinfo failed' in msg + assert 'nonnumeric port' in msg or 'getaddrinfo failed' in msg or 'Name or service not known' in msg return raise RuntimeError("Did not raise") -- cgit v1.2.3 From 9dc9fea4a5661e119f30f4cdec3ef99e46b5f919 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 12:32:11 +0200 Subject: Issue #306: Even if 2to3 is used, we build in-place under Python 2. --HG-- branch : distribute extra : rebase_source : db4a1a3059533ad0c894f12c31e3fe1c238f4292 --- setuptools/command/develop.py | 4 ++-- setuptools/command/test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/develop.py b/setuptools/command/develop.py index c8bef72e..709e349c 100755 --- a/setuptools/command/develop.py +++ b/setuptools/command/develop.py @@ -3,7 +3,7 @@ from distutils.util import convert_path, subst_vars from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log from distutils.errors import DistutilsError, DistutilsOptionError -import os, setuptools, glob +import os, sys, setuptools, glob class develop(easy_install): """Set up package for development""" @@ -84,7 +84,7 @@ class develop(easy_install): " installation directory", p, normalize_path(os.curdir)) def install_for_development(self): - if getattr(self.distribution, 'use_2to3', False): + if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date diff --git a/setuptools/command/test.py b/setuptools/command/test.py index 59c10e84..e5cb9bb5 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -81,7 +81,7 @@ class test(Command): def with_project_on_sys_path(self, func): - if getattr(self.distribution, 'use_2to3', False): + if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): # If we run 2to3 we can not do this inplace: # Ensure metadata is up-to-date -- cgit v1.2.3 From a3b6b2bba70b44b62865e6474e5a007400d62884 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 14:14:07 +0200 Subject: Issue #307: Prints the full path when .svn/entries is broken. --HG-- branch : distribute extra : rebase_source : 1836125ab8204364c8fb197d7c20c296a25f89c0 --- setuptools/command/sdist.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 1f88e93b..edb3b7f3 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -97,7 +97,7 @@ def entries_finder(dirname, filename): for match in entries_pattern.finditer(data): yield joinpath(dirname,unescape(match.group(1))) else: - log.warn("unrecognized .svn/entries format in %s", dirname) + log.warn("unrecognized .svn/entries format in %s", os.path.abspath(dirname)) finders = [ -- cgit v1.2.3 From cafaa3bd07185df0c17a19edee8820494d34267c Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 14:25:48 +0200 Subject: Merged the two lists of acceptable names of README.txt --HG-- branch : distribute extra : rebase_source : 604b23f6559c4688d1b43bc102601e0a0ed914a9 --- setuptools/command/sdist.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index edb3b7f3..16d3c37b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,6 +4,8 @@ from distutils import log import os, re, sys, pkg_resources from glob import glob +READMES = ('README', 'README.rst', 'README.txt') + entities = [ ("<","<"), (">", ">"), (""", '"'), ("'", "'"), ("&", "&") @@ -155,7 +157,7 @@ class sdist(_sdist): dist_files.append(data) def add_defaults(self): - standards = [('README', 'README.rst', 'README.txt'), + standards = [READMES, self.distribution.script_name] for fn in standards: if isinstance(fn, tuple): @@ -220,13 +222,12 @@ class sdist(_sdist): read_template = __read_template_hack def check_readme(self): - alts = ("README", "README.txt") - for f in alts: + for f in READMES: if os.path.exists(f): return else: self.warn( - "standard file not found: should have one of " +', '.join(alts) + "standard file not found: should have one of " +', '.join(READMES) ) -- cgit v1.2.3 From ec0ed85656b96812402439fa23c877fd27b99de5 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 16:36:29 +0200 Subject: Issue #313: Support for sdist subcommands (Python 2.7) --HG-- branch : distribute extra : rebase_source : 5461cca20f4c91fec21b69128f76f6e6a0df205c --- setuptools/command/sdist.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index 16d3c37b..91c4fd1b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -147,7 +147,17 @@ class sdist(_sdist): self.filelist = ei_cmd.filelist self.filelist.append(os.path.join(ei_cmd.egg_info,'SOURCES.txt')) self.check_readme() - self.check_metadata() + + # Run sub commands + for cmd_name in self.get_sub_commands(): + self.run_command(cmd_name) + + # Call check_metadata only if no 'check' command + # (distutils <= 2.6) + import distutils.command + if 'check' not in distutils.command.__all__: + self.check_metadata() + self.make_distribution() dist_files = getattr(self.distribution,'dist_files',[]) -- cgit v1.2.3 From e743dabde0d60aaeca5c9e4dc5c29ac3ac625646 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 16:41:06 +0200 Subject: Got rid of deprecated assert_ and assertEquals. --HG-- branch : distribute extra : rebase_source : 9d7032bac7db98e445ab6a46b2610c278c691c2d --- setuptools/tests/__init__.py | 64 +++++++++++++++++------------------ setuptools/tests/test_develop.py | 6 ++-- setuptools/tests/test_dist_info.py | 6 ++-- setuptools/tests/test_easy_install.py | 20 +++++------ setuptools/tests/test_packageindex.py | 18 +++++----- setuptools/tests/test_resources.py | 42 +++++++++++------------ 6 files changed, 78 insertions(+), 78 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py index 54c9902e..eec76efd 100644 --- a/setuptools/tests/__init__.py +++ b/setuptools/tests/__init__.py @@ -102,21 +102,21 @@ class DependsTests(unittest.TestCase): from email import __version__ self.assertEqual(req.get_version(), __version__) - self.assert_(req.version_ok('1.0.9')) - self.assert_(not req.version_ok('0.9.1')) - self.assert_(not req.version_ok('unknown')) + self.assertTrue(req.version_ok('1.0.9')) + self.assertTrue(not req.version_ok('0.9.1')) + self.assertTrue(not req.version_ok('unknown')) - self.assert_(req.is_present()) - self.assert_(req.is_current()) + self.assertTrue(req.is_present()) + self.assertTrue(req.is_current()) req = Require('Email 3000','03000','email',format=LooseVersion) - self.assert_(req.is_present()) - self.assert_(not req.is_current()) - self.assert_(not req.version_ok('unknown')) + self.assertTrue(req.is_present()) + self.assertTrue(not req.is_current()) + self.assertTrue(not req.version_ok('unknown')) req = Require('Do-what-I-mean','1.0','d-w-i-m') - self.assert_(not req.is_present()) - self.assert_(not req.is_current()) + self.assertTrue(not req.is_present()) + self.assertTrue(not req.is_current()) req = Require('Tests', None, 'tests', homepage="http://example.com") self.assertEqual(req.format, None) @@ -126,8 +126,8 @@ class DependsTests(unittest.TestCase): self.assertEqual(req.homepage, 'http://example.com') paths = [os.path.dirname(p) for p in __path__] - self.assert_(req.is_present(paths)) - self.assert_(req.is_current(paths)) + self.assertTrue(req.is_present(paths)) + self.assertTrue(req.is_current(paths)) class DistroTests(unittest.TestCase): @@ -144,7 +144,7 @@ class DistroTests(unittest.TestCase): ) def testDistroType(self): - self.assert_(isinstance(self.dist,setuptools.dist.Distribution)) + self.assertTrue(isinstance(self.dist,setuptools.dist.Distribution)) def testExcludePackage(self): self.dist.exclude_package('a') @@ -189,17 +189,17 @@ class DistroTests(unittest.TestCase): dist.exclude(packages=['a'], py_modules=['b'], ext_modules=[self.e2]) def testContents(self): - self.assert_(self.dist.has_contents_for('a')) + self.assertTrue(self.dist.has_contents_for('a')) self.dist.exclude_package('a') - self.assert_(not self.dist.has_contents_for('a')) + self.assertTrue(not self.dist.has_contents_for('a')) - self.assert_(self.dist.has_contents_for('b')) + self.assertTrue(self.dist.has_contents_for('b')) self.dist.exclude_package('b') - self.assert_(not self.dist.has_contents_for('b')) + self.assertTrue(not self.dist.has_contents_for('b')) - self.assert_(self.dist.has_contents_for('c')) + self.assertTrue(self.dist.has_contents_for('c')) self.dist.exclude_package('c') - self.assert_(not self.dist.has_contents_for('c')) + self.assertTrue(not self.dist.has_contents_for('c')) def testInvalidIncludeExclude(self): self.assertRaises(DistutilsSetupError, @@ -253,12 +253,12 @@ class FeatureTests(unittest.TestCase): ) def testDefaults(self): - self.assert_(not + self.assertTrue(not Feature( "test",standard=True,remove='x',available=False ).include_by_default() ) - self.assert_( + self.assertTrue( Feature("test",standard=True,remove='x').include_by_default() ) # Feature must have either kwargs, removes, or require_features @@ -272,33 +272,33 @@ class FeatureTests(unittest.TestCase): def testFeatureOptions(self): dist = self.dist - self.assert_( + self.assertTrue( ('with-dwim',None,'include DWIM') in dist.feature_options ) - self.assert_( + self.assertTrue( ('without-dwim',None,'exclude DWIM (default)') in dist.feature_options ) - self.assert_( + self.assertTrue( ('with-bar',None,'include bar (default)') in dist.feature_options ) - self.assert_( + self.assertTrue( ('without-bar',None,'exclude bar') in dist.feature_options ) self.assertEqual(dist.feature_negopt['without-foo'],'with-foo') self.assertEqual(dist.feature_negopt['without-bar'],'with-bar') self.assertEqual(dist.feature_negopt['without-dwim'],'with-dwim') - self.assert_(not 'without-baz' in dist.feature_negopt) + self.assertTrue(not 'without-baz' in dist.feature_negopt) def testUseFeatures(self): dist = self.dist self.assertEqual(dist.with_foo,1) self.assertEqual(dist.with_bar,0) self.assertEqual(dist.with_baz,1) - self.assert_(not 'bar_et' in dist.py_modules) - self.assert_(not 'pkg.bar' in dist.packages) - self.assert_('pkg.baz' in dist.packages) - self.assert_('scripts/baz_it' in dist.scripts) - self.assert_(('libfoo','foo/foofoo.c') in dist.libraries) + self.assertTrue(not 'bar_et' in dist.py_modules) + self.assertTrue(not 'pkg.bar' in dist.packages) + self.assertTrue('pkg.baz' in dist.packages) + self.assertTrue('scripts/baz_it' in dist.scripts) + self.assertTrue(('libfoo','foo/foofoo.c') in dist.libraries) self.assertEqual(dist.ext_modules,[]) self.assertEqual(dist.require_features, [self.req]) @@ -315,7 +315,7 @@ class TestCommandTests(unittest.TestCase): def testTestIsCommand(self): test_cmd = makeSetup().get_command_obj('test') - self.assert_(isinstance(test_cmd, distutils.cmd.Command)) + self.assertTrue(isinstance(test_cmd, distutils.cmd.Command)) def testLongOptSuiteWNoDefault(self): ts1 = makeSetup(script_args=['test','--test-suite=foo.tests.suite']) diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index fcf33c58..3e071dad 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -86,15 +86,15 @@ class TestDevelopTest(unittest.TestCase): # let's see if we got our egg link at the right place content = os.listdir(site.USER_SITE) content.sort() - self.assertEquals(content, ['easy-install.pth', 'foo.egg-link']) + self.assertEqual(content, ['easy-install.pth', 'foo.egg-link']) # Check that we are using the right code. path = open(os.path.join(site.USER_SITE, 'foo.egg-link'), 'rt').read().split()[0].strip() init = open(os.path.join(path, 'foo', '__init__.py'), 'rt').read().strip() if sys.version < "3": - self.assertEquals(init, 'print "foo"') + self.assertEqual(init, 'print "foo"') else: - self.assertEquals(init, 'print("foo")') + self.assertEqual(init, 'print("foo")') def notest_develop_with_setup_requires(self): diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index 68ba9e24..001c4433 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -41,9 +41,9 @@ class TestDistInfo(unittest.TestCase): pkg_resources.Requirement.parse('quux>=1.1')] for d in pkg_resources.find_distributions(self.tmpdir): - self.assertEquals(d.requires(), requires[:1]) - self.assertEquals(d.requires(extras=('baz',)), requires) - self.assertEquals(d.extras, ['baz']) + self.assertEqual(d.requires(), requires[:1]) + self.assertEqual(d.requires(extras=('baz',)), requires) + self.assertEqual(d.extras, ['baz']) def setUp(self): self.tmpdir = tempfile.mkdtemp() diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 7c807fc3..ab02e314 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -68,7 +68,7 @@ class TestEasyInstallTest(unittest.TestCase): try: cmd.install_site_py() sitepy = os.path.join(cmd.install_dir, 'site.py') - self.assert_(os.path.exists(sitepy)) + self.assertTrue(os.path.exists(sitepy)) finally: shutil.rmtree(cmd.install_dir) @@ -81,7 +81,7 @@ class TestEasyInstallTest(unittest.TestCase): finally: sys.platform = old_platform - self.assertEquals(script, WANTED) + self.assertEqual(script, WANTED) def test_no_setup_cfg(self): # makes sure easy_install as a command (main) @@ -127,7 +127,7 @@ class TestEasyInstallTest(unittest.TestCase): cmd.install_dir = os.path.join(tempfile.mkdtemp(), 'ok') cmd.args = ['ok'] cmd.ensure_finalized() - self.assertEquals(cmd.package_index.scanned_urls, {}) + self.assertEqual(cmd.package_index.scanned_urls, {}) # let's try without it (default behavior) cmd = easy_install(dist) @@ -138,7 +138,7 @@ class TestEasyInstallTest(unittest.TestCase): cmd.ensure_finalized() keys = cmd.package_index.scanned_urls.keys() keys.sort() - self.assertEquals(keys, ['link1', 'link2']) + self.assertEqual(keys, ['link1', 'link2']) class TestPTHFileWriter(unittest.TestCase): @@ -147,9 +147,9 @@ class TestPTHFileWriter(unittest.TestCase): if a distribution is in site but also the cwd ''' pth = PthDistributions('does-not_exist', [os.getcwd()]) - self.assert_(not pth.dirty) + self.assertTrue(not pth.dirty) pth.add(PRDistribution(os.getcwd())) - self.assert_(pth.dirty) + self.assertTrue(pth.dirty) def test_add_from_site_is_ignored(self): if os.name != 'nt': @@ -157,9 +157,9 @@ class TestPTHFileWriter(unittest.TestCase): else: location = 'c:\\does_not_exist' pth = PthDistributions('does-not_exist', [location, ]) - self.assert_(not pth.dirty) + self.assertTrue(not pth.dirty) pth.add(PRDistribution(location)) - self.assert_(not pth.dirty) + self.assertTrue(not pth.dirty) class TestUserInstallTest(unittest.TestCase): @@ -246,7 +246,7 @@ class TestUserInstallTest(unittest.TestCase): cmd.ensure_finalized() cmd.local_index.scan([new_location]) res = cmd.easy_install('foo') - self.assertEquals(res.location, new_location) + self.assertEqual(res.location, new_location) finally: sys.path.remove(target) for basedir in [new_location, target, ]: @@ -309,7 +309,7 @@ class TestSetupRequires(unittest.TestCase): # there should have been two or three requests to the server # (three happens on Python 3.3a) - self.assert_(2 <= len(p_index.requests) <= 3) + self.assertTrue(2 <= len(p_index.requests) <= 3) self.assertEqual(p_index.requests[0].path, '/does-not-exist/') def create_sdist(self, installer): diff --git a/setuptools/tests/test_packageindex.py b/setuptools/tests/test_packageindex.py index 886befcb..3e446b54 100644 --- a/setuptools/tests/test_packageindex.py +++ b/setuptools/tests/test_packageindex.py @@ -17,9 +17,9 @@ class TestPackageIndex(unittest.TestCase): try: v = index.open_url(url) except Exception, v: - self.assert_(url in str(v)) + self.assertTrue(url in str(v)) else: - self.assert_(isinstance(v,urllib2.HTTPError)) + self.assertTrue(isinstance(v,urllib2.HTTPError)) def test_bad_url_typo(self): # issue 16 @@ -33,9 +33,9 @@ class TestPackageIndex(unittest.TestCase): try: v = index.open_url(url) except Exception, v: - self.assert_(url in str(v)) + self.assertTrue(url in str(v)) else: - self.assert_(isinstance(v, urllib2.HTTPError)) + self.assertTrue(isinstance(v, urllib2.HTTPError)) def test_bad_url_bad_status_line(self): index = setuptools.package_index.PackageIndex( @@ -53,7 +53,7 @@ class TestPackageIndex(unittest.TestCase): try: v = index.open_url(url) except Exception, v: - self.assert_('line' in str(v)) + self.assertTrue('line' in str(v)) else: raise AssertionError('Should have raise here!') finally: @@ -95,7 +95,7 @@ class TestPackageIndex(unittest.TestCase): hosts=('www.example.com',) ) url = 'file:///tmp/test_package_index' - self.assert_(index.url_ok(url, True)) + self.assertTrue(index.url_ok(url, True)) def test_links_priority(self): """ @@ -128,11 +128,11 @@ class TestPackageIndex(unittest.TestCase): server.stop() # the distribution has been found - self.assert_('foobar' in pi) + self.assertTrue('foobar' in pi) # we have only one link, because links are compared without md5 - self.assert_(len(pi['foobar'])==1) + self.assertTrue(len(pi['foobar'])==1) # the link should be from the index - self.assert_('correct_md5' in pi['foobar'][0].location) + self.assertTrue('correct_md5' in pi['foobar'][0].location) def test_parse_bdist_wininst(self): self.assertEqual(setuptools.package_index.parse_bdist_wininst( diff --git a/setuptools/tests/test_resources.py b/setuptools/tests/test_resources.py index 3e0309f1..d08fa325 100644 --- a/setuptools/tests/test_resources.py +++ b/setuptools/tests/test_resources.py @@ -45,7 +45,7 @@ class DistroTests(TestCase): ad.add(Distribution.from_filename("FooPkg-1.2-py2.4.egg")) # Name is in there now - self.assert_(ad['FooPkg']) + self.assertTrue(ad['FooPkg']) # But only 1 package self.assertEqual(list(ad), ['foopkg']) @@ -228,7 +228,7 @@ class EntryPointTests(TestCase): self.assertEqual(ep.module_name,"setuptools.tests.test_resources") self.assertEqual(ep.attrs, ("EntryPointTests",)) self.assertEqual(ep.extras, ("x",)) - self.assert_(ep.load() is EntryPointTests) + self.assertTrue(ep.load() is EntryPointTests) self.assertEqual( str(ep), "foo = setuptools.tests.test_resources:EntryPointTests [x]" @@ -328,20 +328,20 @@ class RequirementsTests(TestCase): foo_dist = Distribution.from_filename("FooPkg-1.3_1.egg") twist11 = Distribution.from_filename("Twisted-1.1.egg") twist12 = Distribution.from_filename("Twisted-1.2.egg") - self.assert_(parse_version('1.2') in r) - self.assert_(parse_version('1.1') not in r) - self.assert_('1.2' in r) - self.assert_('1.1' not in r) - self.assert_(foo_dist not in r) - self.assert_(twist11 not in r) - self.assert_(twist12 in r) + self.assertTrue(parse_version('1.2') in r) + self.assertTrue(parse_version('1.1') not in r) + self.assertTrue('1.2' in r) + self.assertTrue('1.1' not in r) + self.assertTrue(foo_dist not in r) + self.assertTrue(twist11 not in r) + self.assertTrue(twist12 in r) def testAdvancedContains(self): r, = parse_requirements("Foo>=1.2,<=1.3,==1.9,>2.0,!=2.5,<3.0,==4.5") for v in ('1.2','1.2.2','1.3','1.9','2.0.1','2.3','2.6','3.0c1','4.5'): - self.assert_(v in r, (v,r)) + self.assertTrue(v in r, (v,r)) for v in ('1.2c1','1.3.1','1.5','1.9.1','2.0','2.5','3.0','4.0'): - self.assert_(v not in r, (v,r)) + self.assertTrue(v not in r, (v,r)) def testOptionsAndHashing(self): @@ -363,14 +363,14 @@ class RequirementsTests(TestCase): r2 = Requirement.parse("foo!=0.3a4") d = Distribution.from_filename - self.assert_(d("foo-0.3a4.egg") not in r1) - self.assert_(d("foo-0.3a1.egg") not in r1) - self.assert_(d("foo-0.3a4.egg") not in r2) + self.assertTrue(d("foo-0.3a4.egg") not in r1) + self.assertTrue(d("foo-0.3a1.egg") not in r1) + self.assertTrue(d("foo-0.3a4.egg") not in r2) - self.assert_(d("foo-0.3a2.egg") in r1) - self.assert_(d("foo-0.3a2.egg") in r2) - self.assert_(d("foo-0.3a3.egg") in r2) - self.assert_(d("foo-0.3a5.egg") in r2) + self.assertTrue(d("foo-0.3a2.egg") in r1) + self.assertTrue(d("foo-0.3a2.egg") in r2) + self.assertTrue(d("foo-0.3a3.egg") in r2) + self.assertTrue(d("foo-0.3a5.egg") in r2) def testDistributeSetuptoolsOverride(self): # Plain setuptools or distribute mean we return distribute. @@ -489,7 +489,7 @@ class ParseTests(TestCase): def testVersionOrdering(self): def c(s1,s2): p1, p2 = parse_version(s1),parse_version(s2) - self.assert_(p1 Date: Wed, 22 Aug 2012 16:48:48 +0200 Subject: Issue #314: test_local_index() would fail an OS X. --HG-- branch : distribute extra : rebase_source : 8d91abdbed53300e6ec80bd535e00bca17767206 --- setuptools/tests/test_easy_install.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index ab02e314..13f668d0 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -246,7 +246,8 @@ class TestUserInstallTest(unittest.TestCase): cmd.ensure_finalized() cmd.local_index.scan([new_location]) res = cmd.easy_install('foo') - self.assertEqual(res.location, new_location) + self.assertEqual(os.path.realpath(res.location), + os.path.realpath(new_location)) finally: sys.path.remove(target) for basedir in [new_location, target, ]: -- cgit v1.2.3 From ea687a55fe5d94167a1bf1ff4a75a0c14b5407cd Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 17:36:10 +0200 Subject: Issue 315: --HG-- branch : distribute extra : rebase_source : c7ad76794ac6db2a4bc1abc88e646ddcd14550db --- setuptools/tests/server.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'setuptools') diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py index 7b5cacb9..daccaba9 100644 --- a/setuptools/tests/server.py +++ b/setuptools/tests/server.py @@ -2,6 +2,7 @@ """ import urllib2 import sys +import time import threading import BaseHTTPServer from BaseHTTPServer import HTTPServer @@ -34,6 +35,9 @@ class IndexServer(HTTPServer): def stop(self): "Stop the server" + # Let the server finish the last request adn wait for a new one. + time.sleep(0.1) + # self.shutdown is not supported on python < 2.6, so just # set _run to false, and make a request, causing it to # terminate. -- cgit v1.2.3 From 0d962727403be73b0b1eac234ed81b941dd7cae9 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Wed, 22 Aug 2012 18:01:49 +0200 Subject: Issue #310: Non-ascii characters in a namespace __init__.py causes errors. --HG-- branch : distribute extra : rebase_source : 668e1c79a2bcc314bcf1f7213b317766bb8511ab --- setuptools/command/build_py.py | 4 ++-- setuptools/tests/test_test.py | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index d53960fe..505dd4f3 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -215,8 +215,8 @@ class build_py(_build_py, Mixin2to3): else: return init_py - f = open(init_py,'rU') - if 'declare_namespace' not in f.read(): + f = open(init_py,'rbU') + if 'declare_namespace'.encode() not in f.read(): from distutils import log log.warn( "WARNING: %s is a namespace package, but its __init__.py does\n" diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index 04134ec5..ddbebaa9 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -1,3 +1,5 @@ +# -*- coding: UTF-8 -*- + """develop tests """ import sys @@ -21,13 +23,19 @@ setup(name='foo', ) """ -NS_INIT = """ +NS_INIT = """# -*- coding: Latin-1 -*- +# Söme Arbiträry Ünicode to test Issüé 310 try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) """ +# Make sure this is Latin-1 binary, before writing: +if sys.version_info < (3,): + NS_INIT = NS_INIT.decode('UTF-8') +NS_INIT = NS_INIT.encode('Latin-1') + TEST_PY = """import unittest class TestTest(unittest.TestCase): @@ -50,23 +58,23 @@ class TestTestTest(unittest.TestCase): os.mkdir(os.path.join(self.dir, 'name', 'space', 'tests')) # setup.py setup = os.path.join(self.dir, 'setup.py') - f = open(setup, 'w') + f = open(setup, 'wt') f.write(SETUP_PY) f.close() self.old_cwd = os.getcwd() # name/__init__.py init = os.path.join(self.dir, 'name', '__init__.py') - f = open(init, 'w') + f = open(init, 'wb') f.write(NS_INIT) f.close() # name/space/__init__.py init = os.path.join(self.dir, 'name', 'space', '__init__.py') - f = open(init, 'w') + f = open(init, 'wt') f.write('#empty\n') f.close() # name/space/tests/__init__.py init = os.path.join(self.dir, 'name', 'space', 'tests', '__init__.py') - f = open(init, 'w') + f = open(init, 'wt') f.write(TEST_PY) f.close() @@ -105,7 +113,7 @@ class TestTestTest(unittest.TestCase): cmd.install_dir = site.USER_SITE cmd.user = 1 old_stdout = sys.stdout - sys.stdout = StringIO() + #sys.stdout = StringIO() try: try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. cmd.run() @@ -113,3 +121,4 @@ class TestTestTest(unittest.TestCase): pass finally: sys.stdout = old_stdout + \ No newline at end of file -- cgit v1.2.3 From f090838c3613065fd6505cd390511a96e08755c4 Mon Sep 17 00:00:00 2001 From: Arfrever Frehtes Taifersar Arahesis Date: Wed, 22 Aug 2012 19:32:00 +0200 Subject: Fix a typo in a comment. --HG-- branch : distribute extra : rebase_source : 779baf947b6989f1275d99cff2044adad3dd7997 --- setuptools/tests/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/tests/server.py b/setuptools/tests/server.py index daccaba9..b2ab7acc 100644 --- a/setuptools/tests/server.py +++ b/setuptools/tests/server.py @@ -35,7 +35,7 @@ class IndexServer(HTTPServer): def stop(self): "Stop the server" - # Let the server finish the last request adn wait for a new one. + # Let the server finish the last request and wait for a new one. time.sleep(0.1) # self.shutdown is not supported on python < 2.6, so just -- cgit v1.2.3 From f8d45b50bfcafabe759183e716059a2e2f702420 Mon Sep 17 00:00:00 2001 From: Lennart Regebro Date: Fri, 24 Aug 2012 15:33:56 +0200 Subject: Oups. --HG-- branch : distribute extra : rebase_source : 515bd00c3028ba0d58e57fd51d524a798b9b898d --- setuptools/tests/test_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_test.py b/setuptools/tests/test_test.py index ddbebaa9..ad7cbd0f 100644 --- a/setuptools/tests/test_test.py +++ b/setuptools/tests/test_test.py @@ -113,7 +113,7 @@ class TestTestTest(unittest.TestCase): cmd.install_dir = site.USER_SITE cmd.user = 1 old_stdout = sys.stdout - #sys.stdout = StringIO() + sys.stdout = StringIO() try: try: # try/except/finally doesn't work in Python 2.4, so we need nested try-statements. cmd.run() -- cgit v1.2.3 From 776fdebc918822b57286ac7a2107f8766f43ce56 Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Sat, 25 Aug 2012 15:26:08 -0400 Subject: add markerlib as _markerlib --HG-- branch : distribute extra : rebase_source : b9d8fa81db6c6fc3d89db54a70778eb3e8396e17 --- setuptools/tests/test_dist_info.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index 001c4433..70dce2d4 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -7,7 +7,7 @@ import unittest import textwrap try: - import markerlib + import _markerlib except: pass @@ -34,8 +34,8 @@ class TestDistInfo(unittest.TestCase): assert versioned.version == '2.718' # from filename assert unversioned.version == '0.3' # from METADATA - @skipIf('markerlib' not in globals(), - "install markerlib to test conditional dependencies") + @skipIf('_markerlib' not in globals(), + "_markerlib is used to test conditional dependencies (Python >= 2.5)") def test_conditional_dependencies(self): requires = [pkg_resources.Requirement.parse('splort==4'), pkg_resources.Requirement.parse('quux>=1.1')] @@ -51,7 +51,8 @@ class TestDistInfo(unittest.TestCase): 'VersionedDistribution-2.718.dist-info') os.mkdir(versioned) open(os.path.join(versioned, 'METADATA'), 'w+').write(DALS( - """Metadata-Version: 1.2 + """ + Metadata-Version: 1.2 Name: VersionedDistribution Requires-Dist: splort (4) Provides-Extra: baz @@ -62,7 +63,8 @@ class TestDistInfo(unittest.TestCase): 'UnversionedDistribution.dist-info') os.mkdir(unversioned) open(os.path.join(unversioned, 'METADATA'), 'w+').write(DALS( - """Metadata-Version: 1.2 + """ + Metadata-Version: 1.2 Name: UnversionedDistribution Version: 0.3 Requires-Dist: splort (==4) -- cgit v1.2.3 From 71d6c4c5a29e30a8dac82ad5a79356a5a849e783 Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Sat, 25 Aug 2012 15:31:37 -0400 Subject: move _markerlib test into setuptools/test --HG-- branch : distribute extra : rebase_source : b2d7118f3a3cdf931ba1e56090a35442bc70fd2a --- setuptools/tests/test_markerlib.py | 98 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 setuptools/tests/test_markerlib.py (limited to 'setuptools') diff --git a/setuptools/tests/test_markerlib.py b/setuptools/tests/test_markerlib.py new file mode 100644 index 00000000..4cce0430 --- /dev/null +++ b/setuptools/tests/test_markerlib.py @@ -0,0 +1,98 @@ +import os +import unittest +from setuptools.tests.py26compat import skipIf + +try: + import _ast +except ImportError: + pass + +class TestMarkerlib(unittest.TestCase): + + @skipIf('_ast' not in globals(), + "ast not available (Python < 2.5?)") + def test_markers(self): + from _markerlib import interpret, default_environment, compile + + os_name = os.name + + self.assert_(interpret("")) + + self.assert_(interpret("os.name != 'buuuu'")) + self.assert_(interpret("python_version > '1.0'")) + self.assert_(interpret("python_version < '5.0'")) + self.assert_(interpret("python_version <= '5.0'")) + self.assert_(interpret("python_version >= '1.0'")) + self.assert_(interpret("'%s' in os.name" % os_name)) + self.assert_(interpret("'buuuu' not in os.name")) + + self.assertFalse(interpret("os.name == 'buuuu'")) + self.assertFalse(interpret("python_version < '1.0'")) + self.assertFalse(interpret("python_version > '5.0'")) + self.assertFalse(interpret("python_version >= '5.0'")) + self.assertFalse(interpret("python_version <= '1.0'")) + self.assertFalse(interpret("'%s' not in os.name" % os_name)) + self.assertFalse(interpret("'buuuu' in os.name and python_version >= '5.0'")) + + environment = default_environment() + environment['extra'] = 'test' + self.assert_(interpret("extra == 'test'", environment)) + self.assertFalse(interpret("extra == 'doc'", environment)) + + def raises_nameError(): + try: + interpret("python.version == '42'") + except NameError: + pass + else: + raise Exception("Expected NameError") + + raises_nameError() + + def raises_syntaxError(): + try: + interpret("(x for x in (4,))") + except SyntaxError: + pass + else: + raise Exception("Expected SyntaxError") + + raises_syntaxError() + + statement = "python_version == '5'" + self.assertEqual(compile(statement).__doc__, statement) + + @skipIf('_ast' not in globals(), + "ast not available (Python < 2.5?)") + def test_ast(self): + try: + import ast, nose + raise nose.SkipTest() + except ImportError: + pass + + # Nonsensical code coverage tests. + import _markerlib._markers_ast as _markers_ast + + class Node(_ast.AST): + _fields = ('bogus') + list(_markers_ast.iter_fields(Node())) + + class Node2(_ast.AST): + def __init__(self): + self._fields = ('bogus',) + self.bogus = [Node()] + + class NoneTransformer(_markers_ast.NodeTransformer): + def visit_Attribute(self, node): + return None + + def visit_Str(self, node): + return None + + def visit_Node(self, node): + return [] + + NoneTransformer().visit(_markers_ast.parse('a.b = "c"')) + NoneTransformer().visit(Node2()) + -- cgit v1.2.3 From bf06ab669aacba63dfe4ee8adb5f50b72387c0bd Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Wed, 5 Sep 2012 19:01:58 -0400 Subject: adds a test for pr #4 --HG-- branch : distribute extra : rebase_source : 347b39fb279b7168490a2c62562b4223b6c419e2 --- setuptools/tests/test_sdist.py | 79 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 setuptools/tests/test_sdist.py (limited to 'setuptools') diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py new file mode 100644 index 00000000..8d9ed922 --- /dev/null +++ b/setuptools/tests/test_sdist.py @@ -0,0 +1,79 @@ +"""sdist tests""" + + +import os +import shutil +import sys +import tempfile +import unittest +from StringIO import StringIO + + +from setuptools.command.sdist import sdist +from setuptools.dist import Distribution + + +SETUP_ATTRS = { + 'name': 'sdist_test', + 'version': '0.0', + 'packages': ['sdist_test'], + 'package_data': {'sdist_test': ['*.txt']} +} + + +SETUP_PY = """\ +from setuptools import setup + +setup(**%r) +""" % SETUP_ATTRS + + +class TestSdistTest(unittest.TestCase): + def setUp(self): + self.temp_dir = tempfile.mkdtemp() + f = open(os.path.join(self.temp_dir, 'setup.py'), 'w') + f.write(SETUP_PY) + f.close() + # Set up the rest of the test package + test_pkg = os.path.join(self.temp_dir, 'sdist_test') + os.mkdir(test_pkg) + # *.rst was not included in package_data, so c.rst should not be + # automatically added to the manifest when not under version control + for fname in ['__init__.py', 'a.txt', 'b.txt', 'c.rst']: + # Just touch the files; their contents are irrelevant + open(os.path.join(test_pkg, fname), 'w').close() + + self.old_cwd = os.getcwd() + os.chdir(self.temp_dir) + + def tearDown(self): + os.chdir(self.old_cwd) + shutil.rmtree(self.temp_dir) + + def test_package_data_in_sdist(self): + """Regression test for pull request #4: ensures that files listed in + package_data are included in the manifest even if they're not added to + version control. + """ + + dist = Distribution(SETUP_ATTRS) + dist.script_name = 'setup.py' + cmd = sdist(dist) + cmd.ensure_finalized() + + # squelch output + old_stdout = sys.stdout + old_stderr = sys.stderr + sys.stdout = StringIO() + sys.stderr = StringIO() + try: + cmd.run() + finally: + sys.stdout = old_stdout + sys.stderr = old_stderr + + manifest = cmd.filelist.files + + self.assert_(os.path.join('sdist_test', 'a.txt') in manifest) + self.assert_(os.path.join('sdist_test', 'b.txt') in manifest) + self.assert_(os.path.join('sdist_test', 'c.rst') not in manifest) -- cgit v1.2.3 From d847dbfeee2b2c85d7bc0a66813c33836a9850fa Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Thu, 6 Sep 2012 15:51:09 -0400 Subject: Adds a fix for issue #318, including a regression test. This also fixes another test that was passing trivially due to *bug* in yet another test, ugh --HG-- branch : distribute extra : rebase_source : 476550766b7b756dced040ad4356b7685d6f062a --- setuptools/dist.py | 3 +- setuptools/sandbox.py | 10 ++-- setuptools/tests/__init__.py | 2 +- setuptools/tests/test_easy_install.py | 102 ++++++++++++++++++++++++++-------- 4 files changed, 88 insertions(+), 29 deletions(-) (limited to 'setuptools') diff --git a/setuptools/dist.py b/setuptools/dist.py index 0ad18122..6607cf7b 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -264,6 +264,7 @@ class Distribution(_Distribution): def fetch_build_egg(self, req): """Fetch an egg needed for building""" + try: cmd = self._egg_fetcher cmd.package_index.to_scan = [] @@ -287,7 +288,7 @@ class Distribution(_Distribution): cmd = easy_install( dist, args=["x"], install_dir=os.curdir, exclude_scripts=True, always_copy=False, build_directory=None, editable=False, - upgrade=False, multi_version=True, no_report = True + upgrade=False, multi_version=True, no_report=True, user=False ) cmd.ensure_finalized() self._egg_fetcher = cmd diff --git a/setuptools/sandbox.py b/setuptools/sandbox.py index ab2543d9..64f725e7 100755 --- a/setuptools/sandbox.py +++ b/setuptools/sandbox.py @@ -166,12 +166,12 @@ else: _EXCEPTIONS = [] try: - from win32com.client.gencache import GetGeneratePath - _EXCEPTIONS.append(GetGeneratePath()) - del GetGeneratePath + from win32com.client.gencache import GetGeneratePath + _EXCEPTIONS.append(GetGeneratePath()) + del GetGeneratePath except ImportError: - # it appears pywin32 is not installed, so no need to exclude. - pass + # it appears pywin32 is not installed, so no need to exclude. + pass class DirectorySandbox(AbstractSandbox): """Restrict operations to a single subdirectory - pseudo-chroot""" diff --git a/setuptools/tests/__init__.py b/setuptools/tests/__init__.py index eec76efd..b6988a08 100644 --- a/setuptools/tests/__init__.py +++ b/setuptools/tests/__init__.py @@ -38,7 +38,7 @@ def makeSetup(**args): try: return setuptools.setup(**args) finally: - distutils.core_setup_stop_after = None + distutils.core._setup_stop_after = None class DependsTests(unittest.TestCase): diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 13f668d0..ce8b611b 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -12,6 +12,7 @@ import urlparse import StringIO import distutils.core +from setuptools.sandbox import run_setup, SandboxViolation from setuptools.command.easy_install import easy_install, get_script_args, main from setuptools.command.easy_install import PthDistributions from setuptools.command import easy_install as easy_install_pkg @@ -110,7 +111,9 @@ class TestEasyInstallTest(unittest.TestCase): old_wd = os.getcwd() try: os.chdir(dir) - main([]) + reset_setup_stop_context( + lambda: self.assertRaises(SystemExit, main, []) + ) finally: os.chdir(old_wd) shutil.rmtree(dir) @@ -247,7 +250,7 @@ class TestUserInstallTest(unittest.TestCase): cmd.local_index.scan([new_location]) res = cmd.easy_install('foo') self.assertEqual(os.path.realpath(res.location), - os.path.realpath(new_location)) + os.path.realpath(new_location)) finally: sys.path.remove(target) for basedir in [new_location, target, ]: @@ -262,6 +265,50 @@ class TestUserInstallTest(unittest.TestCase): else: del os.environ['PYTHONPATH'] + def test_setup_requires(self): + """Regression test for issue #318 + + Ensures that a package with setup_requires can be installed when + distribute is installed in the user site-packages without causing a + SandboxViolation. + """ + + test_setup_attrs = { + 'name': 'test_pkg', 'version': '0.0', + 'setup_requires': ['foobar'], + 'dependency_links': [os.path.abspath(self.dir)] + } + + test_pkg = os.path.join(self.dir, 'test_pkg') + test_setup_py = os.path.join(test_pkg, 'setup.py') + test_setup_cfg = os.path.join(test_pkg, 'setup.cfg') + os.mkdir(test_pkg) + + f = open(test_setup_py, 'w') + f.write(textwrap.dedent("""\ + import setuptools + setuptools.setup(**%r) + """ % test_setup_attrs)) + f.close() + + foobar_path = os.path.join(self.dir, 'foobar-0.1.tar.gz') + make_trivial_sdist( + foobar_path, + textwrap.dedent("""\ + import setuptools + setuptools.setup( + name='foobar', + version='0.1' + ) + """)) + + try: + reset_setup_stop_context( + lambda: run_setup(test_setup_py, ['install']) + ) + except SandboxViolation: + self.fail('Installation caused SandboxViolation') + class TestSetupRequires(unittest.TestCase): @@ -319,30 +366,41 @@ class TestSetupRequires(unittest.TestCase): doesn't exist) and invoke installer on it. """ def build_sdist(dir): - setup_py = tarfile.TarInfo(name="setup.py") - try: - # Python 3 (StringIO gets converted to io module) - MemFile = StringIO.BytesIO - except AttributeError: - MemFile = StringIO.StringIO - setup_py_bytes = MemFile(textwrap.dedent(""" - import setuptools - setuptools.setup( - name="distribute-test-fetcher", - version="1.0", - setup_requires = ['does-not-exist'], - ) - """).lstrip().encode('utf-8')) - setup_py.size = len(setup_py_bytes.getvalue()) dist_path = os.path.join(dir, 'distribute-test-fetcher-1.0.tar.gz') - dist = tarfile.open(dist_path, 'w:gz') - try: - dist.addfile(setup_py, fileobj=setup_py_bytes) - finally: - dist.close() + make_trivial_sdist( + dist_path, + textwrap.dedent(""" + import setuptools + setuptools.setup( + name="distribute-test-fetcher", + version="1.0", + setup_requires = ['does-not-exist'], + ) + """).lstrip()) installer(dist_path) tempdir_context(build_sdist) + +def make_trivial_sdist(dist_path, setup_py): + """Create a simple sdist tarball at dist_path, containing just a + setup.py, the contents of which are provided by the setup_py string. + """ + + setup_py_file = tarfile.TarInfo(name='setup.py') + try: + # Python 3 (StringIO gets converted to io module) + MemFile = StringIO.BytesIO + except AttributeError: + MemFile = StringIO.StringIO + setup_py_bytes = MemFile(setup_py.encode('utf-8')) + setup_py_file.size = len(setup_py_bytes.getvalue()) + dist = tarfile.open(dist_path, 'w:gz') + try: + dist.addfile(setup_py_file, fileobj=setup_py_bytes) + finally: + dist.close() + + def tempdir_context(f, cd=lambda dir:None): """ Invoke f in the context -- cgit v1.2.3 From cada83b25777a9b089b85bc4417baa7016a9c652 Mon Sep 17 00:00:00 2001 From: Erik Bray Date: Tue, 11 Sep 2012 08:12:04 -0400 Subject: Make this test less chatty --HG-- branch : distribute extra : rebase_source : da18973713f46ff00931ea79f0fcd39a13fb8349 --- setuptools/tests/test_easy_install.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index ce8b611b..e49c6f49 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -302,12 +302,19 @@ class TestUserInstallTest(unittest.TestCase): ) """)) + old_stdout = sys.stdout + old_stderr = sys.stderr + sys.stdout = StringIO.StringIO() + sys.stderr = StringIO.StringIO() try: reset_setup_stop_context( lambda: run_setup(test_setup_py, ['install']) ) except SandboxViolation: self.fail('Installation caused SandboxViolation') + finally: + sys.stdout = old_stdout + sys.stderr = old_stderr class TestSetupRequires(unittest.TestCase): -- cgit v1.2.3 From 25d00ab637a11693f0a82548904058095f0a64cb Mon Sep 17 00:00:00 2001 From: Daniel Holth Date: Mon, 17 Sep 2012 08:40:37 -0400 Subject: skip markerlib tests on Python < 2.6 (no ast compilation) --HG-- branch : distribute extra : rebase_source : 2044b531becb5ca6882bfb3b59ab53aac2c8ae2e --- setuptools/tests/test_dist_info.py | 6 +++--- setuptools/tests/test_markerlib.py | 40 +++----------------------------------- 2 files changed, 6 insertions(+), 40 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_dist_info.py b/setuptools/tests/test_dist_info.py index 70dce2d4..623ccc47 100644 --- a/setuptools/tests/test_dist_info.py +++ b/setuptools/tests/test_dist_info.py @@ -7,7 +7,7 @@ import unittest import textwrap try: - import _markerlib + import ast except: pass @@ -34,8 +34,8 @@ class TestDistInfo(unittest.TestCase): assert versioned.version == '2.718' # from filename assert unversioned.version == '0.3' # from METADATA - @skipIf('_markerlib' not in globals(), - "_markerlib is used to test conditional dependencies (Python >= 2.5)") + @skipIf('ast' not in globals(), + "ast is used to test conditional dependencies (Python >= 2.6)") def test_conditional_dependencies(self): requires = [pkg_resources.Requirement.parse('splort==4'), pkg_resources.Requirement.parse('quux>=1.1')] diff --git a/setuptools/tests/test_markerlib.py b/setuptools/tests/test_markerlib.py index 4cce0430..7ff2f584 100644 --- a/setuptools/tests/test_markerlib.py +++ b/setuptools/tests/test_markerlib.py @@ -3,14 +3,14 @@ import unittest from setuptools.tests.py26compat import skipIf try: - import _ast + import ast except ImportError: pass class TestMarkerlib(unittest.TestCase): - @skipIf('_ast' not in globals(), - "ast not available (Python < 2.5?)") + @skipIf('ast' not in globals(), + "ast not available (Python < 2.6?)") def test_markers(self): from _markerlib import interpret, default_environment, compile @@ -62,37 +62,3 @@ class TestMarkerlib(unittest.TestCase): statement = "python_version == '5'" self.assertEqual(compile(statement).__doc__, statement) - @skipIf('_ast' not in globals(), - "ast not available (Python < 2.5?)") - def test_ast(self): - try: - import ast, nose - raise nose.SkipTest() - except ImportError: - pass - - # Nonsensical code coverage tests. - import _markerlib._markers_ast as _markers_ast - - class Node(_ast.AST): - _fields = ('bogus') - list(_markers_ast.iter_fields(Node())) - - class Node2(_ast.AST): - def __init__(self): - self._fields = ('bogus',) - self.bogus = [Node()] - - class NoneTransformer(_markers_ast.NodeTransformer): - def visit_Attribute(self, node): - return None - - def visit_Str(self, node): - return None - - def visit_Node(self, node): - return [] - - NoneTransformer().visit(_markers_ast.parse('a.b = "c"')) - NoneTransformer().visit(Node2()) - -- cgit v1.2.3 From 077a69aef0973333cafe4c7548dceb5418d1c36f Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 13:29:03 +0200 Subject: Purge modules under test from sys.modules prior to running tests. Fixes #301. --HG-- branch : distribute extra : rebase_source : 87561670c15ec8315f47157cdc0c06328ce8c20f --- setuptools/command/test.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'setuptools') diff --git a/setuptools/command/test.py b/setuptools/command/test.py index e5cb9bb5..a02ac142 100644 --- a/setuptools/command/test.py +++ b/setuptools/command/test.py @@ -2,6 +2,7 @@ from setuptools import Command from distutils.errors import DistutilsOptionError import sys from pkg_resources import * +from pkg_resources import _namespace_packages from unittest import TestLoader, main class ScanningLoader(TestLoader): @@ -139,6 +140,22 @@ class test(Command): def run_tests(self): import unittest + + # Purge modules under test from sys.modules. The test loader will + # re-import them from the build location. Required when 2to3 is used + # with namespace packages. + if sys.version_info >= (3,) and getattr(self.distribution, 'use_2to3', False): + module = self.test_args[-1].split('.')[0] + if module in _namespace_packages: + del_modules = [] + if module in sys.modules: + del_modules.append(module) + module += '.' + for name in sys.modules: + if name.startswith(module): + del_modules.append(name) + map(sys.modules.__delitem__, del_modules) + loader_ep = EntryPoint.parse("x="+self.test_loader) loader_class = loader_ep.load(require=False) cks = loader_class() -- cgit v1.2.3 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 ++++++++++++++ setuptools/tests/test_sdist.py | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 3 deletions(-) (limited to 'setuptools') 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): diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 8d9ed922..34123545 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- """sdist tests""" @@ -74,6 +75,36 @@ class TestSdistTest(unittest.TestCase): manifest = cmd.filelist.files - self.assert_(os.path.join('sdist_test', 'a.txt') in manifest) - self.assert_(os.path.join('sdist_test', 'b.txt') in manifest) - self.assert_(os.path.join('sdist_test', 'c.rst') not in manifest) + self.assertTrue(os.path.join('sdist_test', 'a.txt') in manifest) + self.assertTrue(os.path.join('sdist_test', 'b.txt') in manifest) + self.assertTrue(os.path.join('sdist_test', 'c.rst') not in manifest) + + def test_filelist_is_fully_composed(self): + # Test for #303. Requires HFS Plus to fail. + + # Add file with non-ASCII filename + filename = os.path.join('sdist_test', 'smörbröd.py') + open(filename, 'w').close() + + dist = Distribution(SETUP_ATTRS) + dist.script_name = 'setup.py' + cmd = sdist(dist) + cmd.ensure_finalized() + + # squelch output + old_stdout = sys.stdout + old_stderr = sys.stderr + sys.stdout = StringIO() + sys.stderr = StringIO() + try: + cmd.run() + finally: + sys.stdout = old_stdout + sys.stderr = old_stderr + + self.assertTrue(filename in cmd.filelist.files) + + +def test_suite(): + return unittest.defaultTestLoader.loadTestsFromName(__name__) + -- cgit v1.2.3 From d76ec4bfdf2fe9a2bced5ca2a3610831020453c6 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 19:52:32 +0200 Subject: Read and write manifest in UTF-8 under Python 3. Fixes #303. --HG-- branch : distribute extra : rebase_source : 609c654effd2711aa803f6a0e84013294026608f --- setuptools/command/sdist.py | 27 +++++++++++++++++++ setuptools/tests/test_sdist.py | 60 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) (limited to 'setuptools') diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index a176f635..d5259c2b 100755 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -262,7 +262,34 @@ class sdist(_sdist): self.get_finalized_command('egg_info').save_version_info(dest) + def _manifest_is_not_generated(self): + # check for special comment used in 2.7.1 and higher + if not os.path.isfile(self.manifest): + return False + fp = open(self.manifest, 'rbU') + try: + first_line = fp.readline() + finally: + fp.close() + return first_line != '# file GENERATED by distutils, do NOT edit\n'.encode() + + def read_manifest(self): + """Read the manifest file (named by 'self.manifest') and use it to + fill in 'self.filelist', the list of files to include in the source + distribution. + """ + log.info("reading manifest file '%s'", self.manifest) + manifest = open(self.manifest, 'rbU') + for line in manifest: + if sys.version_info >= (3,): + line = line.decode('UTF-8') + # ignore comments and blank lines + line = line.strip() + if line.startswith('#') or not line: + continue + self.filelist.append(line) + manifest.close() diff --git a/setuptools/tests/test_sdist.py b/setuptools/tests/test_sdist.py index 34123545..7e2f0a49 100644 --- a/setuptools/tests/test_sdist.py +++ b/setuptools/tests/test_sdist.py @@ -104,6 +104,66 @@ class TestSdistTest(unittest.TestCase): self.assertTrue(filename in cmd.filelist.files) + def test_manifest_is_written_in_utf8(self): + # Test for #303. + + # Add file with non-ASCII filename + filename = os.path.join('sdist_test', 'smörbröd.py') + open(filename, 'w').close() + + dist = Distribution(SETUP_ATTRS) + dist.script_name = 'setup.py' + cmd = sdist(dist) + cmd.ensure_finalized() + + # squelch output + old_stdout = sys.stdout + old_stderr = sys.stderr + sys.stdout = StringIO() + sys.stderr = StringIO() + try: + cmd.run() + finally: + sys.stdout = old_stdout + sys.stderr = old_stderr + + manifest = open(os.path.join('sdist_test.egg-info', 'SOURCES.txt'), 'rbU') + contents = manifest.read() + manifest.close() + self.assertTrue(len(contents)) + + # This must not fail: + contents.decode('UTF-8') + + def test_manifest_is_read_in_utf8(self): + # Test for #303. + + # Add file with non-ASCII filename + filename = os.path.join('sdist_test', 'smörbröd.py') + open(filename, 'w').close() + + dist = Distribution(SETUP_ATTRS) + dist.script_name = 'setup.py' + cmd = sdist(dist) + cmd.ensure_finalized() + + # squelch output + old_stdout = sys.stdout + old_stderr = sys.stderr + sys.stdout = StringIO() + sys.stderr = StringIO() + try: + cmd.run() + finally: + sys.stdout = old_stdout + sys.stderr = old_stderr + + cmd.filelist.files = [] + cmd.manifest = os.path.join('sdist_test.egg-info', 'SOURCES.txt') + cmd.read_manifest() + + self.assertTrue(filename in cmd.filelist.files) + def test_suite(): return unittest.defaultTestLoader.loadTestsFromName(__name__) -- cgit v1.2.3 From 11270be66d228aacca12a211e3fdcb38988fb193 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 20:32:46 +0200 Subject: Print metadata in UTF-8 independent of platform. Fixes #311. --HG-- branch : distribute extra : rebase_source : 4ff0df4ad7d9ea8cee6342f9c642e4fe634b7f18 --- setuptools/dist.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'setuptools') diff --git a/setuptools/dist.py b/setuptools/dist.py index 6607cf7b..afac180e 100644 --- a/setuptools/dist.py +++ b/setuptools/dist.py @@ -640,6 +640,38 @@ class Distribution(_Distribution): name = name[:-6] yield name + + def handle_display_options(self, option_order): + """If there were any non-global "display-only" options + (--help-commands or the metadata display options) on the command + line, display the requested info and return true; else return + false. + """ + import sys + + if sys.version_info < (3,) or self.help_commands: + return _Distribution.handle_display_options(self, option_order) + + # Stdout may be StringIO (e.g. in tests) + import io + if not isinstance(sys.stdout, io.TextIOWrapper): + return _Distribution.handle_display_options(self, option_order) + + # Print metadata in UTF-8 no matter the platform + encoding = sys.stdout.encoding + errors = sys.stdout.errors + newline = sys.platform != 'win32' and '\n' or None + line_buffering = sys.stdout.line_buffering + + sys.stdout = io.TextIOWrapper( + sys.stdout.detach(), 'utf-8', errors, newline, line_buffering) + try: + return _Distribution.handle_display_options(self, option_order) + finally: + sys.stdout = io.TextIOWrapper( + sys.stdout.detach(), encoding, errors, newline, line_buffering) + + # Install it throughout the distutils for module in distutils.dist, distutils.core, distutils.cmd: module.Distribution = Distribution -- cgit v1.2.3 From 645b5b084aa46696b490344a038875f105793308 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 20:37:54 +0200 Subject: Remove a missing fixer warning which showed during normal operations. Fixes #305. --HG-- branch : distribute extra : rebase_source : 3e5912a80758abf1e198d400c29ab03112eb68d6 --- setuptools/command/build_py.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py index 505dd4f3..8751acd4 100644 --- a/setuptools/command/build_py.py +++ b/setuptools/command/build_py.py @@ -51,10 +51,8 @@ try: if self.distribution.use_2to3_exclude_fixers is not None: excluded_fixers.extend(self.distribution.use_2to3_exclude_fixers) for fixer_name in excluded_fixers: - if fixer_name not in self.fixer_names: - log.warn("Excluded fixer %s not found", fixer_name) - continue - self.fixer_names.remove(fixer_name) + if fixer_name in self.fixer_names: + self.fixer_names.remove(fixer_name) except ImportError: class Mixin2to3: -- cgit v1.2.3 From 9553dd9910df577351ea04bb1613767096beeca0 Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Mon, 8 Oct 2012 20:58:18 +0200 Subject: marshall.load() does not necessarily raise ValueError. Fixes #283. --HG-- branch : distribute extra : rebase_source : 203cee618118fb65bf109d2db0275aa90aa5a12d --- setuptools/command/bdist_egg.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'setuptools') diff --git a/setuptools/command/bdist_egg.py b/setuptools/command/bdist_egg.py index 0ee9c55b..17fae984 100644 --- a/setuptools/command/bdist_egg.py +++ b/setuptools/command/bdist_egg.py @@ -425,12 +425,12 @@ def scan_module(egg_dir, base, name, stubs): return True # Extension module pkg = base[len(egg_dir)+1:].replace(os.sep,'.') module = pkg+(pkg and '.' or '')+os.path.splitext(name)[0] - f = open(filename,'rb'); f.read(8) # skip magic & date - try: - code = marshal.load(f); f.close() - except ValueError: - f.seek(0); f.read(12) # skip magic & date & file size; file size added in Python 3.3 - code = marshal.load(f); f.close() + if sys.version_info < (3, 3): + skip = 8 # skip magic & date + else: + skip = 12 # skip magic & date & file size + f = open(filename,'rb'); f.read(skip) + code = marshal.load(f); f.close() safe = True symbols = dict.fromkeys(iter_symbols(code)) for bad in ['__file__', '__path__']: -- cgit v1.2.3 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') 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.3 From 95907bcc8ddc3f87e46fdc6b9518d3c2f2a015ed Mon Sep 17 00:00:00 2001 From: "Stefan H. Holek" Date: Tue, 9 Oct 2012 18:38:21 +0200 Subject: Fix cause of test failure on Mac OS X. Refs #20. --HG-- branch : distribute extra : rebase_source : 92ba8151d6dfa3755b31139a9b5ada570183731d --- setuptools/package_index.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'setuptools') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index d0896feb..ffbffa99 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -779,6 +779,12 @@ def open_with_auth(url): scheme, netloc, path, params, query, frag = urlparse.urlparse(url) + # Double scheme does not raise on Mac OS X as revealed by a + # failing test. We would expect "nonnumeric port". Refs #20. + if sys.platform == 'darwin': + if netloc.endswith(':'): + raise httplib.InvalidURL("nonnumeric port: ''") + if scheme in ('http', 'https'): auth, host = urllib2.splituser(netloc) else: @@ -859,4 +865,4 @@ def local_open(url): -# this line is a kludge to keep the trailing blank lines for pje's editor \ No newline at end of file +# this line is a kludge to keep the trailing blank lines for pje's editor -- cgit v1.2.3