473,505 Members | 15,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.
Jun 27 '08 #1
4 1488
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/
Jun 27 '08 #2
On May 22, 2:44 pm, Hans Nowak <zephyrfalcon!NO_SP...@gmail.com>
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 ?
Jun 27 '08 #3
On May 22, 3:56 pm, TkNeo <tarun....@gmail.comwrote:
On May 22, 2:44 pm, Hans Nowak <zephyrfalcon!NO_SP...@gmail.com>
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?
Jun 27 '08 #4
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
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3307
by: Logan | last post by:
I have two different Python versions on my Linux system (2.2 and 2.3). I cannot remove version 2.2 because many configuration files of the system depend on this version of Python (and its...
9
3566
by: Nuff Said | last post by:
When I type the following code in the interactive python shell, I get 'UTF-8'; but if I put the code into a Python script and run the script - in the same terminal on my Linux box in which I...
29
3397
by: Maurice LING | last post by:
Hi, I remembered reading a MSc thesis about compiling Perl to Java bytecodes (as in java class files). At least, it seems that someone had compiled scheme to java class files quite successfully....
4
2331
by: stuntgoat | last post by:
Hi, I want to start using Python 2.6 and 3000. I have several questions. What, in your experiences, is a functionally elegant solution to installing 2.6 and 3 from source without breaking...
0
7218
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7478
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.