diff -r 6c5245427ccb Lib/distutils/command/sdist.py --- a/Lib/distutils/command/sdist.py Fri Apr 15 17:55:36 2011 -0700 +++ b/Lib/distutils/command/sdist.py Sun Jun 12 09:41:47 2011 +0800 @@ -363,6 +363,11 @@ content = self.filelist.files[:] content.insert(0, '# file GENERATED by distutils, do NOT edit') + + # We always use '/' as file path separator in MANIFEST file + # To fix bug: http://bugs.python.org/issue828450 + content = [line.replace('\\','/') for line in content] + self.execute(file_util.write_file, (self.manifest, content), "writing manifest file '%s'" % self.manifest) diff -r 6c5245427ccb Lib/distutils/tests/test_sdist.py --- a/Lib/distutils/tests/test_sdist.py Fri Apr 15 17:55:36 2011 -0700 +++ b/Lib/distutils/tests/test_sdist.py Sun Jun 12 09:41:47 2011 +0800 @@ -47,13 +47,13 @@ README inroot.txt setup.py -data%(sep)sdata.dt -scripts%(sep)sscript.py -some%(sep)sfile.txt -some%(sep)sother_file.txt -somecode%(sep)s__init__.py -somecode%(sep)sdoc.dat -somecode%(sep)sdoc.txt +data/data.dt +scripts/script.py +some/file.txt +some/other_file.txt +somecode/__init__.py +somecode/doc.dat +somecode/doc.txt """ class SDistTestCase(PyPIRCCommandTestCase): @@ -233,7 +233,7 @@ f = open(join(self.tmp_dir, 'MANIFEST')) try: manifest = f.read() - self.assertEqual(manifest, MANIFEST % {'sep': os.sep}) + self.assertEqual(manifest, MANIFEST) finally: f.close() @@ -419,6 +419,65 @@ f.close() self.assertEqual(manifest, ['README.manual']) + + def test_manifest_sep(self): + # http://bugs.python.org/issue828450 + # check if every file path line in MANIFEST takes '/' as path + # separator, thus Unix can read MANIFEST file generated by Windows + # without any problem, and the reverse is ok + + dist, cmd = self.get_cmd() + cmd.ensure_finalized() + cmd.run() + + # always use slash character ('/') as separator + MANIFEST_STR = """\ + # file GENERATED by distutils, do NOT edit + README + setup.py + somecode/__init__.py + """ + + f = open(cmd.manifest) + try: + manifest = [line.strip() for line in f.read().split('\n') + if line.strip() != ''] + + manifest_slash = [line.strip() for line in MANIFEST_STR.split('\n') + if line.strip() != ''] + self.assertEqual(manifest, manifest_slash) + finally: + f.close() + + def test_read_manifest(self): + # check if it's ok to read the MANIFEST file when all the file paths + # in it has taken '/' as separator, especially when Python use '\' as + # the separator on a specific system + + dist, cmd = self.get_cmd() + cmd.ensure_finalized() + # cmd will run later, thus know what different thing happens + + MANIFEST_STR = """\ + README + setup.py + somecode/__init__.py + """ + + f = open(join(self.tmp_dir, 'MANIFEST'), 'w') + try: + # using a more easy way to test: directly write the string into + # the MANIFEST file instead creating files + f.write(MANIFEST_STR) + filelist = [line.strip() for line in MANIFEST_STR.split('\n') + if line.strip() !=''] + os.sep = '\\' + cmd.run()# cmd run now + filelist_generated = [line.strip().replace('\\','/') for line in \ + cmd.filelist.files[:] if line.strip() !=''] + self.assertEqual(filelist, filelist_generated) + finally: + f.close() def test_suite(): return unittest.makeSuite(SDistTestCase)