Re: continuing development on modules after they're installed



On Fri, Dec 10, 2010 at 9:32 AM, Ian <ian.g.kelly@xxxxxxxxx> wrote:
On Dec 10, 9:57 am, hoesley <hoes...@xxxxxxxxx> 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
jgardner@xxxxxxxxxxxxxxxxxxx
.



Relevant Pages

  • Re: Whats so funny? WAS Re: rotor replacement
    ... That I have to download and perhaps install them to use ... > * I have to download and build the MySQLdb package to talk to MySQL ... > servers from Python code ... I can write something using a core module instead of an external ...
    (comp.lang.python)
  • RE: Python 2.4 killing commercial Windows Python development ?
    ... > install fully useable Python on their Windows machines. ... > Quicksomething for Windows, or RealPlayer, ... The Windows application that I develop and distribute relies on Python ...
    (comp.lang.python)
  • Re: bytecode non-backcompatibility
    ... Unstable bytecodes makes updating to a newer version of Python very ... >>>tedious and risk breaking old scripts, ... > setup.py install" to install the library into site-package. ... each port has a list of all the other ports it depends ...
    (comp.lang.python)
  • HOWTO: Python 2.3 on Fedora Core 1 Linux
    ... About the 'new' Python ... Appendix A: Python Installation with Tkinter - edit: Modules/Setup.dist ... Be aware that it is always risky to install new software; ... # uncomment and/or edit those parts as indicated. ...
    (comp.lang.python)
  • Re: Python 2.4 killing commercial Windows Python development ?
    ... install fully useable Python on their Windows machines. ... different to me than having to install Shockwave, ... Quicksomething for Windows, or RealPlayer, ... The Windows application that I develop and distribute relies on Python ...
    (comp.lang.python)