Re: sys.path trickery in settings.py

2009-01-04 Thread Roland van Laar

Rob Hudson wrote:
> I wouldn't say it's frowned upon, per se, but you're making things
> hard for yourself.  Why not add Django to your Python path?
>
> There are other ways to go, too...
>   
I use buildout, which lets me specifiy which eggs I want to use for each 
project,
extra svn checkouts, such as django-command-extensions.
This enables me to have multilpe django projects which different
django versions, etc and enables collegues and friends
to participate in projects that I'm working on.

Buildout has a bootstrap.py, which creates $PROJECTDIR/bin/buildout
which in turn downloads and creates all necessary files.
manage.py is still there but $PROJECTDIR/bin/django is used
as a wrapper to set the python paths for manage.py
This way, you can have as many django installations as you want,
without one interfering with the other, and manage all of
them in a congruent way.

I am not using django-buildout in google code but,
https://code.launchpad.net/djangorecipe.

To see an example:
http://svn.wirelessleiden.nl/svn/code/exodus/trunk/
bootstrap.py The file which creates bin/buildout
buildout.cfg has an extra django parameter
base.cfg has the stuff such as project name, eggs used etc.

You can try it:
$ svn co http://svn.wirelessleiden.nl/svn/code/exodus/trunk/ exodustrunk
$ cd exodustrunk
$ python bootstrap.py
$ bin/buildout

And your good to go, by using bin/django syncdb, etc, as you
would normally do with manage.py

In the example, I already have a project, if you don't have one already,
buildout will generate one for you, with the name specified in base.cfg.

Regards,

Roland van Laar

> In the shell you're working in:
> $ export PYTHONPATH=~/pkg/django-trunk
> Then ./manage.py will find it without editing the file.
>
> For myself, I have multiple versions of Django in a folder in my home
> directory and manage which one is used via a .pth file in my Python
> path.  See this snippet:
> http://www.djangosnippets.org/snippets/641/
>
> -Rob
>
> On Jan 4, 1:56 am, George Cox  wrote:
>   
>> Hi,
>>
>> I keep my django-trunk installation (and other things like
>> django_evolution) in my home directory, outside the system-wide
>> installation   To avoid having to set PYTHONPATH in the environment, I
>> set do this in my project settings.py file:
>>
>> #  sys.path trickery
>> ---
>> import os, os.path, sys
>> root = os.path.abspath( os.path.dirname( __file__ ) or os.curdir )
>> sys.path.insert( 0, os.path.normpath( os.path.join( root, '..', '..',
>> 'pkg', 'django-trunk' ) ) )
>> sys.path.insert( 0, os.path.normpath( os.path.join( root, '..', '..',
>> 'lib' ) ) )
>>
>> as such, it's necessary to edit manage.py to move the "from
>> django.core.management import execute_manager" below the "try / import
>> settings / except" block.
>>
>> Is this frowned upon?  If not, hope this helps someone. :-)
>>
>> gjvc
>> 
> >
>   


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: sys.path trickery in settings.py

2009-01-04 Thread Rob Hudson

I wouldn't say it's frowned upon, per se, but you're making things
hard for yourself.  Why not add Django to your Python path?

There are other ways to go, too...

In the shell you're working in:
$ export PYTHONPATH=~/pkg/django-trunk
Then ./manage.py will find it without editing the file.

For myself, I have multiple versions of Django in a folder in my home
directory and manage which one is used via a .pth file in my Python
path.  See this snippet:
http://www.djangosnippets.org/snippets/641/

-Rob

On Jan 4, 1:56 am, George Cox  wrote:
> Hi,
>
> I keep my django-trunk installation (and other things like
> django_evolution) in my home directory, outside the system-wide
> installation   To avoid having to set PYTHONPATH in the environment, I
> set do this in my project settings.py file:
>
> #  sys.path trickery
> ---
> import os, os.path, sys
> root = os.path.abspath( os.path.dirname( __file__ ) or os.curdir )
> sys.path.insert( 0, os.path.normpath( os.path.join( root, '..', '..',
> 'pkg', 'django-trunk' ) ) )
> sys.path.insert( 0, os.path.normpath( os.path.join( root, '..', '..',
> 'lib' ) ) )
>
> as such, it's necessary to edit manage.py to move the "from
> django.core.management import execute_manager" below the "try / import
> settings / except" block.
>
> Is this frowned upon?  If not, hope this helps someone. :-)
>
> gjvc
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



sys.path trickery in settings.py

2009-01-04 Thread George Cox

Hi,

I keep my django-trunk installation (and other things like
django_evolution) in my home directory, outside the system-wide
installation   To avoid having to set PYTHONPATH in the environment, I
set do this in my project settings.py file:

#  sys.path trickery
---
import os, os.path, sys
root = os.path.abspath( os.path.dirname( __file__ ) or os.curdir )
sys.path.insert( 0, os.path.normpath( os.path.join( root, '..', '..',
'pkg', 'django-trunk' ) ) )
sys.path.insert( 0, os.path.normpath( os.path.join( root, '..', '..',
'lib' ) ) )

as such, it's necessary to edit manage.py to move the "from
django.core.management import execute_manager" below the "try / import
settings / except" block.

Is this frowned upon?  If not, hope this helps someone. :-)


gjvc

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---