aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVirgil Dupras <hsoft@hsoft-dev.local>2011-01-09 11:26:22 +0100
committerVirgil Dupras <hsoft@hsoft-dev.local>2011-01-09 11:26:22 +0100
commit3b2820f23ea5088afbb1c76b9831e311a0b5bcd3 (patch)
tree0fe55ab70236da315f7b2a9cc5b684fc40db7c41
parentcd057f5a838f034b6830d986a4e10975011f88da (diff)
downloadmarkdown-3b2820f23ea5088afbb1c76b9831e311a0b5bcd3.tar.gz
markdown-3b2820f23ea5088afbb1c76b9831e311a0b5bcd3.tar.bz2
markdown-3b2820f23ea5088afbb1c76b9831e311a0b5bcd3.zip
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).
-rwxr-xr-xsetup.py12
1 files 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()