From 17d7336059df1ea80cc57623065ca5e7362ec133 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Mon, 16 Mar 2009 12:40:37 -0400 Subject: Allow markdown.py script to run on Windows - stop it from importing itself instead of the library. Note that this only works if the markdown library is installed (mostly likely in sitepackages). It will not work if the markdown library is in the same directory as markdown.py (such as an uninstalled source distribution). --- markdown.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'markdown.py') diff --git a/markdown.py b/markdown.py index aae3e76..d7bff46 100755 --- a/markdown.py +++ b/markdown.py @@ -29,6 +29,17 @@ Copyright 2004 Manfred Stienstra (the original version) License: BSD (see docs/LICENSE for details). """ +import sys, os +if sys.platform == 'win32': + # We have to remove the Scripts dir from path on windows. + # If we don't, it will try to import itself rather than markdown lib. + # This appears to *not* be a problem on *nix systems, only Windows. + try: + sys.path.remove(os.path.dirname(__file__)) + except (ValueError, NameError): + pass + +# Now we can import the markdown lib. import logging from markdown import COMMAND_LINE_LOGGING_LEVEL from markdown import commandline -- cgit v1.2.3