471,357 Members | 1,092 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

Where best to put local modules?

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
Dec 19 '07 #1
7 3132
ti*****@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 ?
Dec 19 '07 #2
En Wed, 19 Dec 2007 14:02:20 -0300, <ti*****@isbd.co.ukescribi�:
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

Dec 19 '07 #3
Gabriel Genellina <ga*******@yahoo.com.arwrote:
En Wed, 19 Dec 2007 14:02:20 -0300, <ti*****@isbd.co.ukescribi?:
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
Dec 20 '07 #4
Bruno Desthuilliers <bd*****************@free.quelquepart.frwrote:
ti*****@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
Dec 20 '07 #5
ti*****@isbd.co.uk a écrit :
Bruno Desthuilliers <bd*****************@free.quelquepart.frwrote:
>ti*****@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...).
Dec 20 '07 #6
Bruno Desthuilliers <br********************@wtf.websiteburo.oops.comwr ote:
ti*****@isbd.co.uk a écrit :
Bruno Desthuilliers <bd*****************@free.quelquepart.frwrote:
ti*****@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
Dec 20 '07 #7
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..
Dec 20 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Matthew Barnes | last post: by
7 posts views Thread by Andreas Neudecker | last post: by
2 posts views Thread by Torsten Mohr | last post: by
4 posts views Thread by Fabian Braennstroem | last post: by
4 posts views Thread by Tom Jones | last post: by
2 posts views Thread by allen.fowler | last post: by
1 post views Thread by Jeff | last post: by
3 posts views Thread by Jorgen Bodde | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.