views:

49

answers:

2

I've created a markdown extension file (called mdx_xxx.py) for a django project I'm working on but I can't really decide where to put it.

The documentation says that the file should reside on the PYTHONPATH and I've seen several blog posts inviting to just put the file in the root directory of the project.

However, that seems like an odd place to me as I would rather see it in the related application directory but then it's not on the PYTHONPATH anymore.

Could some experienced django programmer shed some light on this issue?

Thanks

+1  A: 

Not everything should be in your project. This is a requirement, a dependency. You could still package them together, and you'll need to put this at the top level, I think. That basically means importable from the same location as the project itself. Personally, I push everything to a virtualenv, so its nice and clean. If you do the same, you're deployment process should include putting both your project and any dependencies safely into that virtualenv. Otherwise, to whatever location you have in path.

ironfroggy
+1  A: 

Requiring extension files to live directly on the Python path, and not inside any package, is (IMO) an unfortunate limitation of the Python markdown implementation.

If your extension is very specific to your project, I think putting it in the project root is the best option available.

On the other hand, if your extension is reusable in other cases, I would package it up with a simple setup.py and install it into a virtualenv using pip, like I do with all my other dependencies.

Carl Meyer