Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > continuing development on modules after they're installed

Reply
Thread Tools

continuing development on modules after they're installed

 
 
hoesley
Guest
Posts: n/a
 
      12-10-2010
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!
 
Reply With Quote
 
 
 
 
Ian
Guest
Posts: n/a
 
      12-10-2010
On Dec 10, 9:57*am, hoesley <hoes...@gmail.com> 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
 
Reply With Quote
 
 
 
 
Jonathan Gardner
Guest
Posts: n/a
 
      12-10-2010
On Fri, Dec 10, 2010 at 9:32 AM, Ian <> wrote:
> On Dec 10, 9:57*am, hoesley <hoes...@gmail.com> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Functions continuing to ru after returning something? Bradley Hintze Python 7 09-01-2010 06:52 AM
iterators and continuing after a StopIteration Roald de Vries Python 0 08-07-2010 01:57 PM
Continuing after error Sheldon Python 1 09-28-2006 12:40 PM
Xtra DNS continuing to resolve names after DNS moved away Richard NZ Computing 4 08-09-2005 05:27 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57