Fix some DeprecationWarnings and ResourceWarnings.

--HG--
branch : distribute
extra : rebase_source : 1293f856181d35c735670b021e8745208103f640
parent cbcd321e
...@@ -7,6 +7,7 @@ CHANGES ...@@ -7,6 +7,7 @@ CHANGES
------ ------
* Fix test suite with Python 2.6. * Fix test suite with Python 2.6.
* Fix some DeprecationWarnings and ResourceWarnings.
------ ------
0.6.31 0.6.31
......
...@@ -15,8 +15,10 @@ if sys.version_info >= (3,): ...@@ -15,8 +15,10 @@ if sys.version_info >= (3,):
from distutils import dir_util, file_util, util, log from distutils import dir_util, file_util, util, log
log.set_verbosity(1) log.set_verbosity(1)
fl = FileList() fl = FileList()
for line in open("MANIFEST.in"): manifest_file = open("MANIFEST.in")
for line in manifest_file:
fl.process_template_line(line) fl.process_template_line(line)
manifest_file.close()
dir_util.create_tree(tmp_src, fl.files) dir_util.create_tree(tmp_src, fl.files)
outfiles_2to3 = [] outfiles_2to3 = []
dist_script = os.path.join("build", "src", "distribute_setup.py") dist_script = os.path.join("build", "src", "distribute_setup.py")
...@@ -39,7 +41,9 @@ from distutils.util import convert_path ...@@ -39,7 +41,9 @@ from distutils.util import convert_path
d = {} d = {}
init_path = convert_path('setuptools/command/__init__.py') init_path = convert_path('setuptools/command/__init__.py')
exec(open(init_path).read(), d) init_file = open(init_path)
exec(init_file.read(), d)
init_file.close()
SETUP_COMMANDS = d['__all__'] SETUP_COMMANDS = d['__all__']
VERSION = "0.6.32" VERSION = "0.6.32"
...@@ -132,21 +136,27 @@ if _being_installed(): ...@@ -132,21 +136,27 @@ if _being_installed():
_before_install() _before_install()
# return contents of reStructureText file with linked issue references # return contents of reStructureText file with linked issue references
def _linkified(rstfile): def _linkified(rst_path):
bitroot = 'http://bitbucket.org/tarek/distribute' bitroot = 'http://bitbucket.org/tarek/distribute'
revision = re.compile(r'\b(issue\s*#?\d+)\b', re.M | re.I) revision = re.compile(r'\b(issue\s*#?\d+)\b', re.M | re.I)
rstext = open(rstfile).read() rst_file = open(rst_path)
rst_content = rst_file.read()
rst_file.close()
anchors = revision.findall(rstext) # ['Issue #43', ...] anchors = revision.findall(rst_content) # ['Issue #43', ...]
anchors = sorted(set(anchors)) anchors = sorted(set(anchors))
rstext = revision.sub(r'`\1`_', rstext) rst_content = revision.sub(r'`\1`_', rst_content)
rstext += "\n" rst_content += "\n"
for x in anchors: for x in anchors:
issue = re.findall(r'\d+', x)[0] issue = re.findall(r'\d+', x)[0]
rstext += '.. _`%s`: %s/issue/%s\n' % (x, bitroot, issue) rst_content += '.. _`%s`: %s/issue/%s\n' % (x, bitroot, issue)
rstext += "\n" rst_content += "\n"
return rstext return rst_content
readme_file = open('README.txt')
long_description = readme_file.read() + _linkified('CHANGES.txt')
readme_file.close()
dist = setup( dist = setup(
name="distribute", name="distribute",
...@@ -156,7 +166,7 @@ dist = setup( ...@@ -156,7 +166,7 @@ dist = setup(
author="The fellowship of the packaging", author="The fellowship of the packaging",
author_email="distutils-sig@python.org", author_email="distutils-sig@python.org",
license="PSF or ZPL", license="PSF or ZPL",
long_description = open('README.txt').read() + _linkified('CHANGES.txt'), long_description = long_description,
keywords = "CPAN PyPI distutils eggs package management", keywords = "CPAN PyPI distutils eggs package management",
url = "http://packages.python.org/distribute", url = "http://packages.python.org/distribute",
test_suite = 'setuptools.tests', test_suite = 'setuptools.tests',
......
...@@ -236,7 +236,7 @@ class TestUserInstallTest(unittest.TestCase): ...@@ -236,7 +236,7 @@ class TestUserInstallTest(unittest.TestCase):
f = open(egg_file, 'w') f = open(egg_file, 'w')
try: try:
f.write('Name: foo\n') f.write('Name: foo\n')
except: finally:
f.close() f.close()
sys.path.append(target) sys.path.append(target)
...@@ -387,7 +387,7 @@ class TestSetupRequires(unittest.TestCase): ...@@ -387,7 +387,7 @@ class TestSetupRequires(unittest.TestCase):
lines = stdout.splitlines() lines = stdout.splitlines()
self.assertTrue(len(lines) > 0) self.assertTrue(len(lines) > 0)
self.assert_(lines[-1].strip(), 'test_pkg') self.assertTrue(lines[-1].strip(), 'test_pkg')
try: try:
tempdir_context(setup_and_run) tempdir_context(setup_and_run)
......
...@@ -16,15 +16,15 @@ class TestMarkerlib(unittest.TestCase): ...@@ -16,15 +16,15 @@ class TestMarkerlib(unittest.TestCase):
os_name = os.name os_name = os.name
self.assert_(interpret("")) self.assertTrue(interpret(""))
self.assert_(interpret("os.name != 'buuuu'")) self.assertTrue(interpret("os.name != 'buuuu'"))
self.assert_(interpret("python_version > '1.0'")) self.assertTrue(interpret("python_version > '1.0'"))
self.assert_(interpret("python_version < '5.0'")) self.assertTrue(interpret("python_version < '5.0'"))
self.assert_(interpret("python_version <= '5.0'")) self.assertTrue(interpret("python_version <= '5.0'"))
self.assert_(interpret("python_version >= '1.0'")) self.assertTrue(interpret("python_version >= '1.0'"))
self.assert_(interpret("'%s' in os.name" % os_name)) self.assertTrue(interpret("'%s' in os.name" % os_name))
self.assert_(interpret("'buuuu' not in os.name")) self.assertTrue(interpret("'buuuu' not in os.name"))
self.assertFalse(interpret("os.name == 'buuuu'")) self.assertFalse(interpret("os.name == 'buuuu'"))
self.assertFalse(interpret("python_version < '1.0'")) self.assertFalse(interpret("python_version < '1.0'"))
...@@ -36,7 +36,7 @@ class TestMarkerlib(unittest.TestCase): ...@@ -36,7 +36,7 @@ class TestMarkerlib(unittest.TestCase):
environment = default_environment() environment = default_environment()
environment['extra'] = 'test' environment['extra'] = 'test'
self.assert_(interpret("extra == 'test'", environment)) self.assertTrue(interpret("extra == 'test'", environment))
self.assertFalse(interpret("extra == 'doc'", environment)) self.assertFalse(interpret("extra == 'doc'", environment))
def raises_nameError(): def raises_nameError():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment