To answer the question in terms of Python packaging (typically
consuming Django apps isn't going to differ from consuming any other
python package) ...


On Apr 21, 11:44 am, Bryan Wheelock <bryan.wheel...@gmail.com> wrote:
> I have a question about using Pluggable apps with Django.
>
> My question is about best practices.
> If you have pluggable apps, do you put the entire app ( e.g. django-survey
> or django-ads ) into a subdirectory and then add each app individually to
> the python path?
>

I let a tool(s) do all my work for managing Python packages (usually
Buildout). Typically though this will put packages in a shared
location in a strucutre such as:

/path/to/cache/<distributionname-version>/

If you see a Python distribution with a setup.py (setup.py is python's
way of describing the python code in a python distribution) then the
'packages' and 'package_dir' arguments in the setup.py module will
describe where to find the Python source code ... so it's possible
(but typically quite rare) that the paths you need to add are nested
in arbitrary locations throughout the pluggable app.

If you are building up the sys.path by hand, you'll need to peek at
the setup.py and ensure that you are adding the correct locations -
but you'll find that most of the time the simple use-case is present.
That is the disribution name ('django-survey') provides a single
python package of the same name ('django-survey') and that the
location of that package is in the top-level. However, you will find
some disributions put the python packages in a sub-directory
(typically named 'src/' but sometimes you'll see 'lib/python') ...
this more cleaning seperates the python code from other assets that
are part of the disribution, e.g.:

django-pluggypokey/
  setup.py
  docs/
    README.txt
    foo.txt
  designnotes/
    to-do.txt
  src/
    pluggy/
    pokey/

In a case like this, the distribution is named 'django-pluggyexample'
but it provides the 'pluggy' and the 'pokey' packages. The setup.py
would state this with:

setup = (
    ...
    package_dir={'': 'src'},
    packages=['pluggy','pokey'],
)

But one can be as obtuse as you like, for example, if you moved the
pluggy code into the designnotes folder (!):

django-pluggypokey/
  setup.py
  docs/
    README.txt
    foo.txt
  designnotes/
    pluggy/
    to-do.txt
  src/
    pokey/

Then setup.py would reflect this with:

setup = (
    ...
    package_dir={'': 'src', 'pluggy': 'designnotes',},
    packages=['pluggy','pokey'],
)

Which is a pretty bad way to organize your package, but the point
being that setup.py allows for endlessly flexible possibilities, and
so it's best to use tools to install packages (either aggregating
everything into a single directory which is added to PYTHONPATH or
with a series of modifications to sys.path).

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to