[Python-checkins] distutils2: merged with tarek's code
tarek.ziade
python-checkins at python.org
Mon May 31 01:56:09 CEST 2010
tarek.ziade pushed 7df3a7ac7545 to distutils2:
http://hg.python.org/distutils2/rev/7df3a7ac7545
changeset: 184:7df3a7ac7545
parent: 183:97ff6c99d984
parent: 175:644cf5550a05
user: Josip Djolonga
date: Sun May 30 05:16:05 2010 +0200
summary: merged with tarek's code
files: src/distutils2/tests/test_version.py
diff --git a/src/CONTRIBUTORS.txt b/src/CONTRIBUTORS.txt
new file mode 100644
--- /dev/null
+++ b/src/CONTRIBUTORS.txt
@@ -0,0 +1,24 @@
+============
+Contributors
+============
+
+Distutils2 is a project that was started and that is maintained by
+Tarek Ziadé, and many people are contributing to the project.
+
+If you did, please add your name below in alphabetical order !
+
+Thanks to:
+
+- Pior Bastida
+- Titus Brown
+- Nicolas Cadou
+- Yannick Gringas
+- Carl Meyer
+- Michael Mulich
+- George Peris
+- Sean Reifschneider
+- Erik Rose
+- Brian Rosner
+- Alexandre Vassalotti
+- Martin von Löwis
+
diff --git a/src/DEVNOTES.txt b/src/DEVNOTES.txt
new file mode 100644
--- /dev/null
+++ b/src/DEVNOTES.txt
@@ -0,0 +1,10 @@
+Notes for developers
+====================
+
+- Distutils2 runs from 2.4 to 3.2 (3.x not implemented yet), so
+ make sure you don't use a syntax that doesn't work under
+ a specific Python version.
+
+- Always run tests.sh before you push a change. This implies
+ that you have all Python versions installed.
+
diff --git a/src/distutils2/command/sdist.py b/src/distutils2/command/sdist.py
--- a/src/distutils2/command/sdist.py
+++ b/src/distutils2/command/sdist.py
@@ -121,6 +121,7 @@
self.metadata_check = 1
self.owner = None
self.group = None
+ self.filelist = None
def _check_archive_formats(self, formats):
supported_formats = [name for name, desc in get_archive_formats()]
@@ -152,10 +153,14 @@
if self.dist_dir is None:
self.dist_dir = "dist"
+ if self.filelist is None:
+ self.filelist = Manifest()
+
+
def run(self):
# 'filelist' contains the list of files that will make up the
# manifest
- self.filelist = Manifest()
+ self.filelist.clear()
# Run sub commands
for cmd_name in self.get_sub_commands():
@@ -200,7 +205,7 @@
if self.use_defaults:
self.add_defaults()
if template_exists:
- self.read_template()
+ self.filelist.read_template(self.template)
if self.prune:
self.prune_file_list()
diff --git a/src/distutils2/converter/fixers/fix_imports.py b/src/distutils2/converter/fixers/fix_imports.py
--- a/src/distutils2/converter/fixers/fix_imports.py
+++ b/src/distutils2/converter/fixers/fix_imports.py
@@ -20,6 +20,9 @@
if node.type != syms.import_from:
return
+ if not hasattr(imp, "next_sibling"):
+ imp.next_sibling = imp.get_next_sibling()
+
while not hasattr(imp, 'value'):
imp = imp.children[0]
@@ -34,6 +37,8 @@
next = imp.next_sibling
while next is not None:
pattern.append(next.value)
+ if not hasattr(next, "next_sibling"):
+ next.next_sibling = next.get_next_sibling()
next = next.next_sibling
if pattern == ['import', 'setup']:
imp.value = 'distutils2.core'
diff --git a/src/distutils2/converter/fixers/fix_setup_options.py b/src/distutils2/converter/fixers/fix_setup_options.py
--- a/src/distutils2/converter/fixers/fix_setup_options.py
+++ b/src/distutils2/converter/fixers/fix_setup_options.py
@@ -41,6 +41,10 @@
def _fix_name(self, argument, remove_list):
name = argument.children[0]
+
+ if not hasattr(name, "next_sibling"):
+ name.next_sibling = name.get_next_sibling()
+
sibling = name.next_sibling
if sibling is None or sibling.type != token.EQUAL:
return False
@@ -48,6 +52,8 @@
if name.value in _OLD_NAMES:
name.value = _OLD_NAMES[name.value]
if name.value in _SEQUENCE_NAMES:
+ if not hasattr(sibling, "next_sibling"):
+ sibling.next_sibling = sibling.get_next_sibling()
right_operand = sibling.next_sibling
# replacing string -> list[string]
if right_operand.type == token.STRING:
diff --git a/src/distutils2/manifest.py b/src/distutils2/manifest.py
--- a/src/distutils2/manifest.py
+++ b/src/distutils2/manifest.py
@@ -54,6 +54,12 @@
for sort_tuple in sortable_files:
self.files.append(os.path.join(*sort_tuple))
+ def clear(self):
+ """Clear all collected files."""
+ self.files = []
+ if self.allfiles is not None:
+ self.allfiles = []
+
def remove_duplicates(self):
# Assumes list has been sorted!
for i in range(len(self.files) - 1, 0, -1):
diff --git a/src/distutils2/tests/test_converter.py b/src/distutils2/tests/test_converter.py
--- a/src/distutils2/tests/test_converter.py
+++ b/src/distutils2/tests/test_converter.py
@@ -36,4 +36,4 @@
return unittest2.makeSuite(ConverterTestCase)
if __name__ == '__main__':
- run_unittest(test_suite())
+ unittest2.main(defaultTest="test_suite")
diff --git a/src/distutils2/tests/test_core.py b/src/distutils2/tests/test_core.py
--- a/src/distutils2/tests/test_core.py
+++ b/src/distutils2/tests/test_core.py
@@ -60,6 +60,19 @@
distutils2.core.run_setup(
self.write_setup(setup_using___file__))
+ def test_run_setup_stop_after(self):
+ f = self.write_setup(setup_using___file__)
+ for s in ['init', 'config', 'commandline', 'run']:
+ distutils2.core.run_setup(f, stop_after=s)
+ self.assertRaises(ValueError, distutils2.core.run_setup,
+ f, stop_after='bob')
+
+ def test_run_setup_args(self):
+ f = self.write_setup(setup_using___file__)
+ d = distutils2.core.run_setup(f, script_args=["--help"],
+ stop_after="init")
+ self.assertEqual(['--help'], d.script_args)
+
def test_run_setup_uses_current_dir(self):
# This tests that the setup script is run with the current directory
# as its own current directory; this was temporarily broken by a
diff --git a/src/distutils2/tests/test_sdist.py b/src/distutils2/tests/test_sdist.py
--- a/src/distutils2/tests/test_sdist.py
+++ b/src/distutils2/tests/test_sdist.py
@@ -343,6 +343,19 @@
finally:
archive.close()
+ def test_get_file_list(self):
+ dist, cmd = self.get_cmd()
+ cmd.finalize_options()
+ cmd.template = os.path.join(self.tmp_dir, 'MANIFEST.in')
+ f = open(cmd.template, 'w')
+ try:
+ f.write('include MANIFEST.in\n')
+ finally:
+ f.close()
+
+ cmd.get_file_list()
+ self.assertIn('MANIFEST.in', cmd.filelist.files)
+
def test_suite():
return unittest2.makeSuite(SDistTestCase)
diff --git a/src/runtests.py b/src/runtests.py
--- a/src/runtests.py
+++ b/src/runtests.py
@@ -6,7 +6,7 @@
def test_main():
import distutils2.tests
- from distutils2.tests import run_unittest, reap_children
+ from distutils2.tests import run_unittest, reap_children, TestFailed
from distutils2._backport.tests import test_suite as btest_suite
# just supporting -q right now
# to enable detailed/quiet output
@@ -14,10 +14,15 @@
verbose = sys.argv[-1] != '-q'
else:
verbose = 1
-
- run_unittest([distutils2.tests.test_suite(), btest_suite()],
- verbose_=verbose)
- reap_children()
+ try:
+ try:
+ run_unittest([distutils2.tests.test_suite(), btest_suite()],
+ verbose_=verbose)
+ return 0
+ except TestFailed:
+ return 1
+ finally:
+ reap_children()
if __name__ == "__main__":
try:
@@ -26,4 +31,5 @@
print('!!! You need to install unittest2')
sys.exit(1)
- test_main()
+ sys.exit(test_main())
+
diff --git a/src/tests.sh b/src/tests.sh
--- a/src/tests.sh
+++ b/src/tests.sh
@@ -1,12 +1,28 @@
#!/bin/sh
-echo Testing with Python 2.4....
-python2.4 runtests.py -q
+echo -n "Running tests for Python 2.4..."
+python2.4 runtests.py -q > /dev/null 2> /dev/null
+if [ $? -ne 0 ];then
+ echo "Failed"
+ exit $1
+else
+ echo "Success"
+fi
-echo
-echo Testing with Python 2.5....
-python2.5 runtests.py -q
+echo -n "Running tests for Python 2.5..."
+python2.5 runtests.py -q > /dev/null 2> /dev/null
+if [ $? -ne 0 ];then
+ echo "Failed"
+ exit $1
+else
+ echo "Success"
+fi
-echo
-echo Testing with Python 2.6....
-python2.6 runtests.py -q
+echo -n "Running tests for Python 2.6..."
+python2.6 runtests.py -q > /dev/null 2> /dev/null
+if [ $? -ne 0 ];then
+ echo "Failed"
+ exit $1
+else
+ echo "Success"
+fi
--
Repository URL: http://hg.python.org/distutils2
More information about the Python-checkins
mailing list