473,763 Members | 1,333 Online
Bytes | Software Development & Data Engineering Community
+ 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 3580

<ve******@yahoo .com> wrote in message
news:11******** *************@e 56g2000cwe.goog legroups.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************ **********@i39g 2000cwa.googleg roups.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.goo glegroups.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
1785
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 all of the files compile and the programs runs perfectly on a windows 2000 machine. However, when I move the files to a Unix machine, the files won't compile..."No variable BLACK defined in java.awt.Color"
8
3719
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 in the subject, did a web search, and it seems kind of powerfull. My main interrest is web development in Zope/CMF/Plone, where there is a lot of repeated code in the products. So automated code generation seems
0
2444
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 UML, and using automatic code generation to make Python APIs, XML I/O etc. (more below). We can be found at http://www.ccpn.ac.uk/index.html As a general point, automtic code generation would seem like a good idea in special cases where:
6
2254
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 which I want to declare an instance of the class in the other header file. I assume that through some circulair reference this won't work, but I don't know how otherwise to be able to declare the instances. The compile error that I receive is:
0
1493
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 configure script. My setup is as follows: ../src/php-4.4.2
6
2157
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 functionality being kept separate. I've been going over the various approaches I could follow in order to implement the OS-specific functionality. The requirements I have are as follows :
1
2565
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 reasons, but i have problems to have access to GPIO pins on the board to read and write on harware(pic, memories...) so i want to include into python a porting of io.h I founded an already python wrapped version of io.h called ioport.c that i found...
2
6361
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 : $ ../glibc-2.5/configure --prefix=/mnt/new/Mars/glibc_HQ_test/GLIBC/ install/ --with-__thread --enable-kernel=2.6.11 --enable-shared
1
1585
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 compilation is not possible.. is it possible to cross compile the files (1.3 version) in JDK1.5 environment.. Kindly suggest me
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9386
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9938
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7366
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5270
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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 we have to send another system
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.