Where best to put local modules?

Discussion in 'Python' started by tinnews@isbd.co.uk, Dec 19, 2007.

  1. Guest

    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, 2007
    #1
    1. Advertising

  2. En Wed, 19 Dec 2007 14:02:20 -0300, <> 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
    Gabriel Genellina, Dec 19, 2007
    #2
    1. Advertising

  3. 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 ?
    Bruno Desthuilliers, Dec 19, 2007
    #3
  4. Guest

    Gabriel Genellina <> wrote:
    > En Wed, 19 Dec 2007 14:02:20 -0300, <> 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
    , Dec 20, 2007
    #4
  5. Guest

    Bruno Desthuilliers <> wrote:
    > 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, 2007
    #5
  6. a écrit :
    > Bruno Desthuilliers <> wrote:
    >> 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...).
    Bruno Desthuilliers, Dec 20, 2007
    #6
  7. Guest

    Bruno Desthuilliers <> wrote:
    > a écrit :
    > > Bruno Desthuilliers <> wrote:
    > >> 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, 2007
    #7
  8. Zentrader Guest

    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..
    Zentrader, Dec 20, 2007
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Remy Cool
    Replies:
    1
    Views:
    420
    Remy Cool
    Aug 27, 2003
  2. Tobiah
    Replies:
    2
    Views:
    306
    Tobiah
    Sep 14, 2003
  3. Bob van der Poel

    When to put my modules

    Bob van der Poel, Dec 30, 2003, in forum: Python
    Replies:
    4
    Views:
    298
    Bob van der Poel
    Dec 30, 2003
  4. fortepianissimo
    Replies:
    11
    Views:
    565
    fortepianissimo
    Mar 6, 2006
  5. Gabriel Rossetti
    Replies:
    3
    Views:
    534
    Jerry Hill
    Apr 25, 2008
Loading...

Share This Page