473,473 Members | 1,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cross compile generation of .pyc from .py files...

Hi all,

We've managed to cross-compile (from i686 targeting ppc) python (2.4.2)
binaries and
extension modules.

However we cannot figure out how to cross-compile the .py (of
distribution) files and
generate the .pyc files for the target ppc from an i686 system. Is it
possible to cross
compile .pyc files from .py files?

Some of the errors we get when we run 'python -v' on the target system
include:
.....
# /usr/lib/python2.4/site.pyc has bad magic
import site # from /usr/lib/python2.4/site.py

# /usr/lib/python2.4/types.pyc has bad magic
import types # from /usr/lib/python2.4/types.py
......

Thanks,
/venkat

Mar 1 '06 #1
7 3556

<ve******@yahoo.com> wrote in message
news:11*********************@e56g2000cwe.googlegro ups.com...
However we cannot figure out how to cross-compile the .py (of
distribution) files and
generate the .pyc files for the target ppc from an i686 system. Is it
possible to cross
compile .pyc files from .py files?


I am under the impression that .pyc files are system independent.
Have you tried simply copying them over?

tjr

Mar 1 '06 #2
You should look at this blog entry:
http://www.voidspace.org.uk/python/w..._11.shtml#e222

But if you have the original .py it's quite insane to want to hack the
..pyc only for porting it under others architectures. Instead, use
setuptools.

--
sebastien - http://seb.dbzteam.com

Mar 1 '06 #3

Terry Reedy wrote:
...
I am under the impression that .pyc files are system independent.
Have you tried simply copying them over?

tjr


Hi Terry,

It appears that python on the target ppc system is expecting to see
ppc-related info in the .pyc files. These .pyc were generated at cross
compile time (on i686 system) and packaged, deployed, installed on the
ppc system. The "...has bad magic..." appears to indicate that
ppc-version of python is expecting to see ppc-specific .pyc files, but
is encountering i686-specific .pyc files... For some reason, the
cross-compile step that results in the .pyc files is not generating
them for the proper ppc-target, but is building them for the i686
system where they were being cross-compiled...

Thanks,
/venkat

Mar 1 '06 #4
In article <11**********************@i39g2000cwa.googlegroups .com>,
ve******@yahoo.com wrote:
Terry Reedy wrote:
...
I am under the impression that .pyc files are system independent.
Have you tried simply copying them over?

tjr
Hi Terry,

It appears that python on the target ppc system is expecting to see
ppc-related info in the .pyc files.


There is no such thing.
These .pyc were generated at cross
compile time (on i686 system) and packaged, deployed, installed on the
ppc system. The "...has bad magic..." appears to indicate that
ppc-version of python is expecting to see ppc-specific .pyc files, but
is encountering i686-specific .pyc files... For some reason, the
cross-compile step that results in the .pyc files is not generating
them for the proper ppc-target, but is building them for the i686
system where they were being cross-compiled...


..pyc files are only compatible with the same major Python version, so it
sounds like you're using different versions on both platforms.

Just
Mar 1 '06 #5
Hi Sebastian,

Thanks for that link and your notes.

I was under the impression, that the .pyc files will be used (if found)
by python to speed up execution of scripts... and so we packaged,
deployed and installed the .py/.pyc files on to the ppc-target system.
That package includes, site.py(c), types.py(c) etc., among others.

Though I see these errors when I invokde 'python -v', I'm able to
execute the .py files... but was hoping to use the .pyc files to
benefit from the enhanced speed of execution. Like I mentioned to
Terry, for some reason only the cross compile generation of .pyc for
the ppc-target is not getting done right, whereas the actual
ppc-specific python (2.4.2) binaries and extension (.so) modules are
getting created properly.

We were not trying to just ship the .pyc files and reverse-engineer the
..py files from them on the target ppc system.

Thanks,
/venkat

Mar 1 '06 #6

<ve******@yahoo.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
ppc system. The "...has bad magic..." appears to indicate that


The format of .pyc files, which are generated for greater speed of repeat
runs, is considered an internal implementation detail subject to change.
The exact details are generally specific to each x,y version. (For
instance, byte codes are occasionally added.) So each version generally
has a version-specific magic number and will only run .pyc files with the
same magic number. If you get 'bad magic' from the interpreter, then you
have a mismatch.

If you are shipping .py files, there is no need to also ship .pyc files.
Let them be generated as needed or run compileall at installation.

Terry Jan Reedy

Mar 1 '06 #7
ve******@yahoo.com wrote:
I was under the impression, that the .pyc files will be used (if found)
by python to speed up execution of scripts... and so we packaged,
deployed and installed the .py/.pyc files on to the ppc-target system.
That package includes, site.py(c), types.py(c) etc., among others.

Though I see these errors when I invokde 'python -v', I'm able to
execute the .py files... but was hoping to use the .pyc files to
benefit from the enhanced speed of execution.

[snip...]

..pyc files do not increase the speed of execution -- only the speed of
importing modules. Even then, the benefit is only seen the first time
the modules are loaded, as the .pyc files will be generated
automatically. I'd say the tiny, one-time speedup isn't worth it; and
if you really want the modules to be precompiled, it's better to do it
at installation time using distutils.

-- David

Mar 1 '06 #8

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

Similar topics

2
by: Robot Tree | last post by:
I have a small GUI program (7 classes), and several of them have constants defined in them, such as: private static final Color DEFAULT_COLOR = Color.BLACK; I've imported java.awt.Color, and...
8
by: Max M | last post by:
Yesterday there was an article on Slashdot: http://books.slashdot.org/article.pl?sid=03/09/04/1415210&mode=flat&tid=108&tid=126&tid=156 It is about automatic code generation. I got interrested...
0
by: Rasmus Fogh | last post by:
Someone raised the question of automatic code generation a few weeks back. And yes, we (CCPN) are using automatic Python code generation in a major way. Basically we are making data models in...
6
by: Maart_newbie | last post by:
Hi all, Can anyone tell me how I can include one header Form1.h into another header Form2.h and the other way around without evolving into compile errors? Both headers contain only one class in...
0
by: CptDondo | last post by:
I hope someone can help me out. I am trying to cross-compile xcache <http://trac.lighttpd.net/xcache/> and I'm not having much luck. The problem is that xcache depends on phpize to build the...
6
by: greek_bill | last post by:
Hi, I'm interested in developing an application that needs to run on more than one operating system. Naturally, a lot of the code will be shared between the various OSs, with OS specific...
1
by: Otacon22 | last post by:
Hi all, I want to create a robot with a router board based on processor atheros 2.6, called "fonera". I have installed a version of linux, Openwrt and python and i want to use it for some...
2
by: akhilesh.noida | last post by:
I am trying to compile glibc-2.5 for ARM based board. But I am getting errors while configuring it. Please check and give your inputs for resolving this. configure command : $...
1
by: akaley | last post by:
Hi all, I tried to cross compile the java files from 1.5 to 1.3 in JDK 1.5 environment by using the below command javac -target 1.3 *.java. But it showing an error message Like cross...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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
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,...
0
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
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
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.