continuing development on modules after they're installed

Discussion in 'Python' started by hoesley, Dec 10, 2010.

  1. hoesley

    hoesley Guest

    I just started using distutils to install the modules I'm working on
    to site-packages. Now, however, if I make changes in my development
    directory, then import the modules into python, it always loads up the
    installed version. Thus, I can't continue development without first
    uninstalling the modules I'm working on, so that the interpreter finds
    them in the local directory instead of site-packages. Is there any
    simple way around this? I figure this must be a very common thing to
    encounter. Thanks!
    hoesley, Dec 10, 2010
    #1
    1. Advertising

  2. hoesley

    Ian Guest

    On Dec 10, 9:57 am, hoesley <> wrote:
    > I just started using distutils to install the modules I'm working on
    > to site-packages. Now, however, if I make changes in my development
    > directory, then import the modules into python, it always loads up the
    > installed version. Thus, I can't continue development without first
    > uninstalling the modules I'm working on, so that the interpreter finds
    > them in the local directory instead of site-packages. Is there any
    > simple way around this? I figure this must be a very common thing to
    > encounter. Thanks!


    Do you need the installed version to be distinct from the development
    version? If not, you can "install" the module using a simple soft
    link (on Unix) or a .pth file (on Windows) that points to your
    development directory.

    If you do need them to be distinct, a simple way to preferentially get
    the development version is to add it to the *beginning* of sys.path:

    sys.path.insert(0, '/path/to/development/directory/')

    This process can be simplified further by putting it in a
    PYTHONSTARTUP script.

    HTH,
    Ian
    Ian, Dec 10, 2010
    #2
    1. Advertising

  3. On Fri, Dec 10, 2010 at 9:32 AM, Ian <> wrote:
    > On Dec 10, 9:57 am, hoesley <> wrote:
    >> I just started using distutils to install the modules I'm working on
    >> to site-packages. Now, however, if I make changes in my development
    >> directory, then import the modules into python, it always loads up the
    >> installed version. Thus, I can't continue development without first
    >> uninstalling the modules I'm working on, so that the interpreter finds
    >> them in the local directory instead of site-packages. Is there any
    >> simple way around this? I figure this must be a very common thing to
    >> encounter. Thanks!

    >
    > Do you need the installed version to be distinct from the development
    > version?  If not, you can "install" the module using a simple soft
    > link (on Unix) or a .pth file (on Windows) that points to your
    > development directory.
    >
    > If you do need them to be distinct, a simple way to preferentially get
    > the development version is to add it to the *beginning* of sys.path:
    >
    > sys.path.insert(0, '/path/to/development/directory/')
    >
    > This process can be simplified further by putting it in a
    > PYTHONSTARTUP script.
    >


    A simpler way to do this is to use virtualenv.

    $ virtualenv --no-site-packages YourEnv
    $ . YourEnv/bin/activate
    $ cd YourProject
    $ python setup.py develop

    (I'm not sure on the Windows commands, although I assume they exist
    and are just as trivial as the Unix ones.)

    Now, there is a link from the lib/python2.6/site-packages files to
    YourProject. (Or Python2.7 or whatever version you are using.)

    I'd also look at using Paster to create the package. It gives you a
    pretty decent setup for straight up Python packages.

    --
    Jonathan Gardner
    Jonathan Gardner, Dec 10, 2010
    #3
    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. Asfand Yar Qazi
    Replies:
    4
    Views:
    384
    Asfand Yar Qazi
    Nov 12, 2004
  2. Martin M.
    Replies:
    4
    Views:
    335
    Simon Brunning
    Dec 15, 2005
  3. Sheldon

    Continuing after error

    Sheldon, Sep 28, 2006, in forum: Python
    Replies:
    1
    Views:
    282
    Georg Brandl
    Sep 28, 2006
  4. Roald de Vries
    Replies:
    0
    Views:
    206
    Roald de Vries
    Aug 7, 2010
  5. Bradley Hintze
    Replies:
    7
    Views:
    276
    Dennis Lee Bieber
    Sep 1, 2010
Loading...

Share This Page