2 different versions of python compiling files.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TkNeo

    2 different versions of python compiling files.

    I am trying to upgrade from python 2.3 to 2.4 but not all machines can
    be upgraded. Can you guys tell me if this scenario is possible.

    1. Any machine that uses .py files that use libraries that require 2.4
    will have 2.4 on it.
    2. rest of the machines will have 2.3

    now there is a shared drive. lets say i write a new library called
    testlib.py and put it on the shared drive .. when a script uses it
    from a 2.4 based machine, it will generate a testlib.pyc and leave it
    on the shared drive. going forward that .pyc is used until the
    original lib is changed. now lets say a 2.3 based machine is trying to
    use that lib. it will try to use that pyc file which was compiled by
    py2.4. will it work or crash ?

    not sure if i did a good job on explaining my scenario.
  • Hans Nowak

    #2
    Re: 2 different versions of python compiling files.

    TkNeo wrote:
    I am trying to upgrade from python 2.3 to 2.4 but not all machines can
    be upgraded. Can you guys tell me if this scenario is possible.
    >
    1. Any machine that uses .py files that use libraries that require 2.4
    will have 2.4 on it.
    2. rest of the machines will have 2.3
    >
    now there is a shared drive. lets say i write a new library called
    testlib.py and put it on the shared drive .. when a script uses it
    from a 2.4 based machine, it will generate a testlib.pyc and leave it
    on the shared drive. going forward that .pyc is used until the
    original lib is changed. now lets say a 2.3 based machine is trying to
    use that lib. it will try to use that pyc file which was compiled by
    py2.4. will it work or crash ?
    It should work, as long as the original .py file is still there. Each Python
    version will check for a .pyc file *corresponding to that version* (e.g. Python
    2.4 will look for a .pyc file compiled with 2.4), and create one if it doesn't
    exist, overwriting any existing .pyc file in the process.

    If the original .py file is *not* there, it will most likely not work. If you
    try to import a .pyc file with the wrong version number, you get something like
    this:
    >>import foo
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    ImportError: Bad magic number in foo.pyc

    I'm not sure what would happen if multiple Pythons try to write a .pyc file at
    the same time, though...

    --
    Hans Nowak (zephyrfalcon at gmail dot org)

    Comment

    • TkNeo

      #3
      Re: 2 different versions of python compiling files.

      On May 22, 2:44 pm, Hans Nowak <zephyrfalcon!N O_SP...@gmail.c om>
      wrote:
      TkNeo wrote:
      I am trying to upgrade from python 2.3 to 2.4 but not all machines can
      be upgraded. Can you guys tell me if this scenario is possible.
      >
      1. Any machine that uses .py files that use libraries that require 2.4
      will have 2.4 on it.
      2. rest of the machines will have 2.3
      >
      now there is a shared drive. lets say i write a new library called
      testlib.py and put it on the shared drive .. when a script uses it
      from a 2.4 based machine, it will generate a testlib.pyc and leave it
      on the shared drive. going forward that .pyc is used until the
      original lib is changed. now lets say a 2.3 based machine is trying to
      use that lib. it will try to use that pyc file which was compiled by
      py2.4. will it work or crash ?
      >
      It should work, as long as the original .py file is still there. Each Python
      version will check for a .pyc file *corresponding to that version* (e.g. Python
      2.4 will look for a .pyc file compiled with 2.4), and create one if it doesn't
      exist, overwriting any existing .pyc file in the process.
      >
      If the original .py file is *not* there, it will most likely not work. If you
      try to import a .pyc file with the wrong version number, you get something like
      this:
      >
      >>import foo
      Traceback (most recent call last):
      File "<stdin>", line 1, in ?
      ImportError: Bad magic number in foo.pyc
      >
      I'm not sure what would happen if multiple Pythons try to write a .pyc file at
      the same time, though...
      >
      --
      Hans Nowak (zephyrfalcon at gmail dot org)http://4.flowsnake.org/
      The original .py will always be there but you know what, multiple
      python versions from different computers do access that one library at
      the same time.

      Anyone know a possible solution ?

      Comment

      • drobinow@gmail.com

        #4
        Re: 2 different versions of python compiling files.

        On May 22, 3:56 pm, TkNeo <tarun....@gmai l.comwrote:
        On May 22, 2:44 pm, Hans Nowak <zephyrfalcon!N O_SP...@gmail.c om>
        wrote:
        >
        >
        >
        TkNeo wrote:
        I am trying to upgrade from python 2.3 to 2.4 but not all machines can
        be upgraded. Can you guys tell me if this scenario is possible.
        >
        1. Any machine that uses .py files that use libraries that require 2.4
        will have 2.4 on it.
        2. rest of the machines will have 2.3
        >
        now there is a shared drive. lets say i write a new library called
        testlib.py and put it on the shared drive .. when a script uses it
        from a 2.4 based machine, it will generate a testlib.pyc and leave it
        on the shared drive. going forward that .pyc is used until the
        original lib is changed. now lets say a 2.3 based machine is trying to
        use that lib. it will try to use that pyc file which was compiled by
        py2.4. will it work or crash ?
        >
        It should work, as long as the original .py file is still there. Each Python
        version will check for a .pyc file *corresponding to that version* (e.g. Python
        2.4 will look for a .pyc file compiled with 2.4), and create one if it doesn't
        exist, overwriting any existing .pyc file in the process.
        >
        If the original .py file is *not* there, it will most likely not work. If you
        try to import a .pyc file with the wrong version number, you get something like
        this:
        >
        >>import foo
        Traceback (most recent call last):
        File "<stdin>", line 1, in ?
        ImportError: Bad magic number in foo.pyc
        >
        I'm not sure what would happen if multiple Pythons try to write a .pyc file at
        the same time, though...
        >
        --
        Hans Nowak (zephyrfalcon at gmail dot org)http://4.flowsnake.org/
        >
        The original .py will always be there but you know what, multiple
        python versions from different computers do access that one library at
        the same time.
        >
        Anyone know a possible solution ?
        What error message are you getting?

        Comment

        • Ivan Illarionov

          #5
          Re: 2 different versions of python compiling files.

          The original .py will always be there but you know what, multiple python
          versions from different computers do access that one library at the same
          time.
          >
          Anyone know a possible solution ?
          What about subversion or mercurial and separate copies of your library
          for each Python version?

          -- Ivan

          Comment

          Working...