running Python2 Python3 parallel concurrent

Discussion in 'Python' started by harrismh777, Mar 31, 2011.

  1. harrismh777

    harrismh777 Guest

    Greetings,

    The purpose of this communique is to document a process for
    installing python2.7.1 in parallel with python3.2 on a concurrent
    desktop with independent idle and python path structure.

    Each version (python2, python3) will be installed in a separate
    python shell (idle) run on a separate local install so that both
    versions are running side-by-side on the same user desktop, each python
    shell having a unique .idlerc(v) configuration dir for look&feel as well
    as separate recent files lists and separate working .py folders.

    Neither of the installs should affect the other installation (nor
    idle operation), nor should the installs affect the system-wide default
    install (python2.6.2 in my case running ubuntu 9.04 jaunty). As well,
    the search paths should not overlap except at the top $HOME level. The
    over-all purpose is to be able to play with both versions together in
    order to facilitate/enable/solve concurrent development, migration, and
    debug issues between the two versions.

    I trust that if the community has already solved this problem, and
    has a better way, that I may discover it and be able to adopt it to my
    own environment as well.

    If you find any mistakes, please let me know.

    Best regards, m harris.

    The primary unordered issues for solution(s) are:

    1) separate PythonX folders for .py files, $HOME/PythonX
    2) separate desktop launchers to cleanly launch idleX for pythonX
    3) separate .idlercX files in the home dir for IDLE pythonX
    4) separate correct $HOME/local/pythonX installation folders
    5) separate correct $HOME/bin/ launch scripts and sym links
    6) Config from sources with correct --prefix setting
    7) Local Build & Install

    ===========================================================
    BUILD VERSIONS FROM SOURCE
    ===========================================================
    Download the 2.7.1 and 3.2 tarballs from here:

    http://www.python.org/download/

    From your $HOME directory create the modules (.py) folder with:

    mkdir Python3 ie., $HOME/Python3/

    .... and then create the local installation folder in $HOME/local:

    mkdir local
    cd local
    mkdir python3 ie., $HOME/local/python3/

    Create a $HOME/bin/ folder, if it does not already exist.

    Unpack each tarball in $HOME with:

    tar -xvf Python-3.2.tar.bz2 --bzip2

    cd Python-3.2 and then build & install with:

    ./configure --prefix=$HOME/local/python3
    make
    make install

    NOTES: Repeat these steps for each local version. It is important
    that the development headers already be installed, including the tk-dev
    package so that tkinter mod will get built enabling idle. The tarballs
    are available in several compression schemes... I chose bzip2.
    The --prefix option tells the installer where pythonX will live;
    this will be a local install visible only to the development user.

    ===========================================================
    Symbolic link(s)
    ===========================================================

    Create a symbolic link for python in $HOME/bin/ with:

    cd $HOME/bin/
    ln -sf $HOME/local/python3/bin/python3 python3

    note: (python3 can now be invoked from a linux terminal)

    Repeat the steps for each version.

    You may need to set your linux path to include
    $HOME/bin/ in either .profile or .bashrc if not
    already in place. This is usually already set on
    most modern linux distros if ~/bin/ exists.

    ===========================================================
    Launcher Scripts
    ===========================================================

    Create the bash launcher script used for setting the
    PYTHONPATH and starting the python3 script. Use a text
    editor of your choice to create a text file in $HOME/bin/
    called Python3-IDE containing these three lines:

    #!/bin/sh
    export PYTHONPATH=$HOME/Python3
    exec $HOME/bin/idle-python3 -n

    Now, create the python script for importing and launching
    the PyShell from idlelib; use a text editor to create a
    text file in $HOME/bin/ called idle-python3 containing:

    #!/home/<username>/bin/python3

    from idlelib.PyShell import main
    if __name__ == '__main__':
    main()

    The first line /home/<username>/ is $HOME, but may have to
    be spelled out in the script above. Now, set both scripts
    executeable with:

    chmod 0754 $HOME/bin/Python3-IDE
    chmod 0754 $HOME/bin/idle-python3

    Notes: Repeat for each version. Summary; each version will
    have its own launcher script ( PythonX-IDE ) and each will
    have its own python idle starter script ( idle-pythonX ).

    The launcher script is the 'called' file from the Desktop
    launcher icon, which sets the PYTHONPATH. The python idle
    starter script correctly starts the interpreter and then
    initiates the PyShell (python idle shell) import main and
    run.

    ===========================================================
    IDLE Configuration File .idlrcX
    ===========================================================

    By default the idlelib.configHandler sets the config
    dir to $HOME/.idlerc (we will change this so that
    each idle version will have its own config directory
    in $HOME). The cfgDir attribute is held in the config
    handler in the following module hierarchy:

    [module] idlelib.configHandler

    Class IdleConf

    def GetUserCfgDir()

    cfgDir='.idlerc'

    Use a text editor and "carefully" change the config
    handler located here:

    $HOME/local/python3/lib/python3.2/idlelib/configHandler.py

    (you might want to backup the configHandler.py file just in
    case you honk it somehow... ) :)

    Find the Class IdleConf and then locate the def called:
    GetUserCfgDir()

    Change the attribute cfgDir to:
    cfgDir='.idlerc3'

    Save the file.

    Notes: Repeat for each version. Summary, each version will
    have its own .idlercX configuration file:

    .idlerc3
    .idlerc2

    Also, the default python installation will still have its own
    configuration file .idlerc specific to the system-wide IDLE
    config.

    ===========================================================
    Construct Desktop Launchers
    ===========================================================

    Build each Desktop python application launcher in the
    usual way, and point the lancher to $HOME/bin/Python3-IDE

    Repeat this step for each version application launcher.

    ===========================================================
    DONE enjoy a cup of tea
    ===========================================================

    At this point you should be able to launch each python version in
    its own python shell from the Desktop and have them both running
    concurrently side-by-side without stepping on one anothers toes, as it
    were, and each having its own environment look & feel.

    I actually set one of the shells to have differing colors and font
    so that I can visually remember which environment I'm coding to. Also, I
    keep my python3.py files only in Python3 and my python2.py files only in
    Python2. In this way they can have the same names exactly but because
    the path structures are completely isolated the correct .py is imported
    depending on the version environment.

    Kind regards,

    m harris
    harrismh777, Mar 31, 2011
    #1
    1. Advertising

  2. harrismh777

    John Roth Guest

    On Mar 30, 7:05 pm, harrismh777 <> wrote:
    > Greetings,
    >
    >      The purpose of this communique is to document a process for
    > installing python2.7.1 in parallel with python3.2 on a concurrent
    > desktop with independent idle and python path structure.
    >
    > ...
    >
    >      Kind regards,
    >
    >      m harris
    >
    >  python2-python3-parallel.txt
    > 7KViewDownload


    You might want to look at PEP 394, which is tentatively scheduled for
    Python 3.3 and the next maintenance release of 2.7. As far as I can
    tell, this pretty much solves the problem for Unixoid and MacOS
    systems. PEP 397 is a first cut at doing the same thing for Windows.

    Regards,
    John Roth
    John Roth, Mar 31, 2011
    #2
    1. Advertising

  3. harrismh777

    harrismh777 Guest

    John Roth wrote:
    > You might want to look at PEP 394, which is tentatively scheduled for
    > Python 3.3 and the next maintenance release of 2.7. As far as I can
    > tell, this pretty much solves the problem for Unixoid and MacOS
    > systems.


    Thanks John. I finally read PEP 394 and 397. Yes, these handle the
    problem on the execute end. The solution to the problem on the
    application development end (my stuff, see previous) is concerning the
    requirement to be able to build apps for both versions in parallel---
    from the development end.
    Ultimately, it would be nice to have support in IDLE for multiple
    versions from under the umbrella of one IDE. I have decided that rather
    than try to port 32 -> 2.7 ( or 27. -> 3.2 ) that I will be developing
    for both (in parallel) concurrently. When I am done with the app two
    versions will be able, one sh-banged for 2.7 and the other sh-banged for
    3.2/
    At the moment I am using two instances of IDLE running in parallel, one
    using 2.7.1 and the other using 3.2 / I would like to see them
    combined under one IDE with configuration options for multiple version
    environments (perhaps in addition to 2.7 , 3.2).
    So, I'm playing a bit with IDLE to see what I can come up with. I don't
    know if anyone wants to see a PEP on that or not.
    And, while I'm at it, I think I'll look into a way to provide a clear
    screen option for the IDLE interactive window... :)

    kind regards,
    m harris
    harrismh777, Apr 4, 2011
    #3
  4. harrismh777

    rusi Guest

    On Mar 31, 6:05 am, harrismh777 <> wrote:
    > Greetings,
    >
    >      The purpose of this communique is to document a process for
    > installing python2.7.1 in parallel with python3.2 on a concurrent
    > desktop with independent idle and python path structure.


    Not sure if this is relevant...
    python-mode (emacs mode for python development) is broken for python 3
    I submitted a 1-line patch which makes python-mode work for 2.x and
    3.x
    Here https://bugs.launchpad.net/python-mode/ bug/450552
    rusi, Apr 5, 2011
    #4
    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. Pep
    Replies:
    6
    Views:
    810
  2. Xavier
    Replies:
    0
    Views:
    405
    Xavier
    Aug 6, 2003
  3. Skip Montanaro
    Replies:
    1
    Views:
    418
    Thomas Heller
    Aug 7, 2003
  4. snacktime
    Replies:
    13
    Views:
    553
    Dan Sommers
    Feb 22, 2005
  5. Uwe Mayer

    changing from python2.3 to python2.4

    Uwe Mayer, Apr 8, 2005, in forum: Python
    Replies:
    1
    Views:
    290
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Apr 9, 2005
Loading...

Share This Page