diff options
author | Waylan Limberg <waylan@gmail.com> | 2009-03-16 12:40:37 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2009-03-16 12:40:37 -0400 |
commit | 17d7336059df1ea80cc57623065ca5e7362ec133 (patch) | |
tree | db6646196b64e59dcaa082c2f26b15c0f850b37e /markdown.py | |
parent | a39deb26b31de97e2cf4fd867089e656e0c40a2d (diff) | |
download | markdown-17d7336059df1ea80cc57623065ca5e7362ec133.tar.gz markdown-17d7336059df1ea80cc57623065ca5e7362ec133.tar.bz2 markdown-17d7336059df1ea80cc57623065ca5e7362ec133.zip |
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).
Diffstat (limited to 'markdown.py')
-rwxr-xr-x | markdown.py | 11 |
1 files changed, 11 insertions, 0 deletions
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 |