From 3b2820f23ea5088afbb1c76b9831e311a0b5bcd3 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 9 Jan 2011 11:26:22 +0100 Subject: Fixed setup.py to work with python 3.x (The imported markdown module in build_docs would be the one that wasn't 2to3'ed, thus causing a syntax error). --- setup.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 67591c6..5f00c0d 100755 --- a/setup.py +++ b/setup.py @@ -116,6 +116,10 @@ class build_docs(Command): return 'Python Markdown' def run(self): + # Before importing markdown, we have to tweak sys.path because we have to import it from + # the build directory (we might have ran 2to3 on the library) + bld_cmd = self.get_finalized_command("build") + sys.path.insert(0, bld_cmd.build_lib) try: import markdown except ImportError: @@ -134,12 +138,12 @@ class build_docs(Command): if self.verbose: print ('Converting %s -> %s' % (infile, outfile)) if not self.dry_run: - doc = open(outfile, 'w') - doc.write(doc_header % {'title': title, - 'menu': menu}) + doc = open(outfile, 'wb') + header = doc_header % {'title': title, 'menu': menu} + doc.write(header.encode('utf-8')) md.convertFile(infile, doc) md.reset() - doc.write(doc_footer) + doc.write(doc_footer.encode('utf-8')) doc.close() -- cgit v1.2.3