[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Where best to put local modules?

tinnews

12/19/2007 5:02:00 PM

I'm just beginning to create some python modules for my own use and
I'm wondering where to put them. Initially I have put them in
$HOME/bin and I have set PYTHONPATH to point to them there. It all
seems to be OK but I was wondering if I might be storing up problems
for the future by putting python modules in with my odds and sods of
shell scripts etc. (and with my python 'main' scripts).

Would I be better off putting the modules somewhere else, e.g.
somewhere like $HOME/lib/python?


--
Chris Green
7 Answers

Gabriel Genellina

12/19/2007 6:32:00 PM

0

En Wed, 19 Dec 2007 14:02:20 -0300, <tinnews@isbd.co.uk> escribi�:

> I'm just beginning to create some python modules for my own use and
> I'm wondering where to put them. Initially I have put them in
> $HOME/bin and I have set PYTHONPATH to point to them there. It all
> seems to be OK but I was wondering if I might be storing up problems
> for the future by putting python modules in with my odds and sods of
> shell scripts etc. (and with my python 'main' scripts).
>
> Would I be better off putting the modules somewhere else, e.g.
> somewhere like $HOME/lib/python?

Try lib/pythonX.X/site-packages, which is already on sys.path so you don't
have to set PYTHONPATH

--
Gabriel Genellina

Bruno Desthuilliers

12/19/2007 7:02:00 PM

0

tinnews@isbd.co.uk a écrit :
> I'm just beginning to create some python modules for my own use and
> I'm wondering where to put them. Initially I have put them in
> $HOME/bin and I have set PYTHONPATH to point to them there. It all
> seems to be OK but I was wondering if I might be storing up problems
> for the future by putting python modules in with my odds and sods of
> shell scripts etc. (and with my python 'main' scripts).
>
> Would I be better off putting the modules somewhere else, e.g.
> somewhere like $HOME/lib/python?
>

If you're on a shared system and don't have admin access, this last
solution is probably the best - "pure" modules have nothing to do in a
bin/ directory indeed. Now if it's your own computer, why not just put
them in /path/to/python/libs/site-packages ?

tinnews

12/20/2007 8:46:00 AM

0

Gabriel Genellina <gagsl-py2@yahoo.com.ar> wrote:
> En Wed, 19 Dec 2007 14:02:20 -0300, <tinnews@isbd.co.uk> escribi?:
>
> > I'm just beginning to create some python modules for my own use and
> > I'm wondering where to put them. Initially I have put them in
> > $HOME/bin and I have set PYTHONPATH to point to them there. It all
> > seems to be OK but I was wondering if I might be storing up problems
> > for the future by putting python modules in with my odds and sods of
> > shell scripts etc. (and with my python 'main' scripts).
> >
> > Would I be better off putting the modules somewhere else, e.g.
> > somewhere like $HOME/lib/python?
>
> Try lib/pythonX.X/site-packages, which is already on sys.path so you don't
> have to set PYTHONPATH
>
That's fine if it happens to be your own system and you have root
access, however I was actually meaning on a system where I just have a
shell account.

--
Chris Green

tinnews

12/20/2007 9:28:00 AM

0

Bruno Desthuilliers <bdesth.quelquechose@free.quelquepart.fr> wrote:
> tinnews@isbd.co.uk a écrit :
> > I'm just beginning to create some python modules for my own use and
> > I'm wondering where to put them. Initially I have put them in
> > $HOME/bin and I have set PYTHONPATH to point to them there. It all
> > seems to be OK but I was wondering if I might be storing up problems
> > for the future by putting python modules in with my odds and sods of
> > shell scripts etc. (and with my python 'main' scripts).
> >
> > Would I be better off putting the modules somewhere else, e.g.
> > somewhere like $HOME/lib/python?
> >
>
> If you're on a shared system and don't have admin access, this last
> solution is probably the best - "pure" modules have nothing to do in a
> bin/ directory indeed. Now if it's your own computer, why not just put
> them in /path/to/python/libs/site-packages ?

There's one of each, a system where I have a shell account but not
root access and my home system.

There is a disadvantage of putting stuff in the site-packages directory
isn't there? If/when I upgrade the system the python modules I have added
will effectively not be visible to the upgraded system. I know I can
copy them across to the new site-packages but it's just one more chore
when upgrading. If they were in $HOME/lib/python this issue wouldn't
arise because /home stays the same across upgrades.

--
Chris Green

Bruno Desthuilliers

12/20/2007 3:17:00 PM

0

tinnews@isbd.co.uk a écrit :
> Bruno Desthuilliers <bdesth.quelquechose@free.quelquepart.fr> wrote:
>> tinnews@isbd.co.uk a écrit :
>>> I'm just beginning to create some python modules for my own use and
>>> I'm wondering where to put them. Initially I have put them in
>>> $HOME/bin and I have set PYTHONPATH to point to them there. It all
>>> seems to be OK but I was wondering if I might be storing up problems
>>> for the future by putting python modules in with my odds and sods of
>>> shell scripts etc. (and with my python 'main' scripts).
>>>
>>> Would I be better off putting the modules somewhere else, e.g.
>>> somewhere like $HOME/lib/python?
>>>
>> If you're on a shared system and don't have admin access, this last
>> solution is probably the best - "pure" modules have nothing to do in a
>> bin/ directory indeed. Now if it's your own computer, why not just put
>> them in /path/to/python/libs/site-packages ?
>
> There's one of each, a system where I have a shell account but not
> root access and my home system.

> There is a disadvantage of putting stuff in the site-packages directory
> isn't there? If/when I upgrade the system the python modules I have added
> will effectively not be visible to the upgraded system. I know I can
> copy them across to the new site-packages but it's just one more chore
> when upgrading. If they were in $HOME/lib/python this issue wouldn't
> arise because /home stays the same across upgrades.
>

Yes, true. OTHO, storing modules in your own $HOME/whatever and
modifying your $PYTHONPATH accordingly won't make the modules available
to other accounts. Which may or not be a problem (it happened to be one
for me...).

tinnews

12/20/2007 4:08:00 PM

0

Bruno Desthuilliers <bruno.42.desthuilliers@wtf.websiteburo.oops.com> wrote:
> tinnews@isbd.co.uk a écrit :
> > Bruno Desthuilliers <bdesth.quelquechose@free.quelquepart.fr> wrote:
> >> tinnews@isbd.co.uk a écrit :
> >>> I'm just beginning to create some python modules for my own use and
> >>> I'm wondering where to put them. Initially I have put them in
> >>> $HOME/bin and I have set PYTHONPATH to point to them there. It all
> >>> seems to be OK but I was wondering if I might be storing up problems
> >>> for the future by putting python modules in with my odds and sods of
> >>> shell scripts etc. (and with my python 'main' scripts).
> >>>
> >>> Would I be better off putting the modules somewhere else, e.g.
> >>> somewhere like $HOME/lib/python?
> >>>
> >> If you're on a shared system and don't have admin access, this last
> >> solution is probably the best - "pure" modules have nothing to do in a
> >> bin/ directory indeed. Now if it's your own computer, why not just put
> >> them in /path/to/python/libs/site-packages ?
> >
> > There's one of each, a system where I have a shell account but not
> > root access and my home system.
>
> > There is a disadvantage of putting stuff in the site-packages directory
> > isn't there? If/when I upgrade the system the python modules I have added
> > will effectively not be visible to the upgraded system. I know I can
> > copy them across to the new site-packages but it's just one more chore
> > when upgrading. If they were in $HOME/lib/python this issue wouldn't
> > arise because /home stays the same across upgrades.
> >
> Yes, true. OTHO, storing modules in your own $HOME/whatever and
> modifying your $PYTHONPATH accordingly won't make the modules available
> to other accounts. Which may or not be a problem (it happened to be one
> for me...).

Probably not for me. OK, thanks for all the responses, it seems there
isn't anything of huge consequence that I'm missing so I can just
decide what fits my situation best.

--
Chris Green

Zentrader

12/20/2007 4:15:00 PM

0

Wherever it is physically located, I would suggest linking the dir to /
usr/lib/python/site-python (on a Linux system). AFAIK the sole
purpose of this dir is for the type of thing you are describing. On
my system it also gets copied when Python is updated. What
permissions you give the dir is up to you. Also, you probably want it
somewhere that gets backed up routinely or you may loose your latest
and greatest version if there is a crash, etc..