From: Waylan L. <wa...@gm...> - 2008-08-02 00:20:42
|
Something that has bothered me for a while now is that when we run `setup.py install`, markdown is installed just fine for module use. However, if one wants to use it on the command line, then markdown.py needs to be copied or linked to the system path and made executable. The thing is, if a separate comand line script is provided with the distribution, then the install will copy that to the path and make it executable by default. Usually `/usr/bin/` or `/usr/local/bin/` or some similar variant on *nix systems (depending on distribution) and assuming a default install, `C:\\Python\scripts\` on windows[^1]. That way, markdown.py doesn't need to be in the same dir as the source file and there's no need to append `python` to the front of the command (windows uses the file extension and *nix the shebang line). Much more useful IMO. The question is, what all should that command line script contain? I'm tempted to rip everything out of markdown.py that is related to the command line stuff and only have that in the script. But I also realize that some people may what to still use `markdownFromFile()` in their own code, so I'll probably at least leave that. But should I leave all the command line stuff in markdown.py and just do a short script something like: #!/usr/bin/env python if __name__ == '__main__': import markdown options = markdown.parse_options() if not options: sys.exit(0) markdown.markdownFromFile(**options) or the more drastic example here: http://gitorious.org/projects/python-markdown/repos/waylans-sandbox/commits/9f8232a0235ee95873c9d53531f23eabd8df33c4 and all that stuff stripped from markdown.py here: http://gitorious.org/projects/python-markdown/repos/waylans-sandbox/commits/30f0464a90a71dd2fbefa9f5c7403f0f831c05f0 Any preferences? Oh, and I should mention that, unlike in the above linked example, I'd name the script markdown.py for consistency. [^1]: I realize `C:\\Python\scripts\` is not on the system path by default, but you really should add it. There are all sorts of handy tools in there. I should also note the I may have the path slightly wrong, but I don't have a windows install handy at the moment to check. Don't worry, I'll check before updating the docs. -- ---- Waylan Limberg wa...@gm... |