473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

compatbility of .pyc files

I have a requirement to prevent 'accidental' tampering
with some software written in Python. If I ensure that all
of the modules concerned are compiled into .pyc's, and remove
the .py's to another location, then I should be safe until
the next upgrade of the Python interpretter.

My questions:

Are the .pyc's usable without recompilation between 'minor'
releases of the interpretter (e.g., 2.3.1 -> 2.3.2 -> etc)?

I presume that the .pyc's are NOT compatible
across more major releases (e.g., 2.3.x -> 2.4.x)?

Is there a hard and fast rule about compatibility across
releases that I can rely on?

Jul 18 '05 #1
5 1958
I find myself having to write some code on Windows :-(. To alleviate
the pain, at least I get to use Python for some of it.

I'm trying to write a simple application, say "eggs.py". It pops a
tkinter gui and lets the user do some stuff. The system has Python
installed so I don't care about wrapping it in a .exe file or anything
like that. But I'd like to make a desktop icon for eggs.py and let the
user double-click it and run the app without also getting a DOS box on
the screen.

Is there a simple way to do that? I didn't see anything in the Python
docs about it. I suspect that this is really a dumb Windows question,
but I avoid Windows whenever I can, so most anything I can ask about it
is probably dumb.

Thanks much.
Jul 18 '05 #2
Blair Hall wrote:
Are the .pyc's usable without recompilation between 'minor'
releases of the interpretter (e.g., 2.3.1 -> 2.3.2 -> etc)?
Yes.
I presume that the .pyc's are NOT compatible
across more major releases (e.g., 2.3.x -> 2.4.x)?
Correct.
Is there a hard and fast rule about compatibility across
releases that I can rely on?


Each Python version uses a "magic", as returned by
imp.get_magic(). Whenever that changes (and it will at
worst change between 2.x, 2.x+1), you need to recompile
the .pyc files.

If you pass it an "old" pyc file (i.e. one with an
incorrect magic), Python will silently ignore the .pyc
file, use the source, and attempt to regenerate the
..pyc file.

Regards,
Martin
Jul 18 '05 #3
On Wed, 23 Feb 2005 13:31:12 +1300, Blair Hall wrote:
I have a requirement to prevent 'accidental' tampering
with some software written in Python. If I ensure that all
of the modules concerned are compiled into .pyc's, and remove
the .py's to another location, then I should be safe until
the next upgrade of the Python interpretter.


Depending on how "scare quote-y" the scare quotes are, if you're really
out to avoid accidental tampering, why not just set the *.py files to
read-only?

Beyond that you get into rapidly diminishing returns; removing the .py
files is feasible if you have some semblance of control over the
interpreter, beyond that and you're usually better off with a binding
legal agreement.
Jul 18 '05 #4
Paul Rubin wrote:
I find myself having to write some code on Windows :-(. To alleviate
the pain, at least I get to use Python for some of it.

I'm trying to write a simple application, say "eggs.py". It pops a
tkinter gui and lets the user do some stuff. The system has Python
installed so I don't care about wrapping it in a .exe file or anything
like that. But I'd like to make a desktop icon for eggs.py and let the
user double-click it and run the app without also getting a DOS box on
the screen.
Rename the file "eggs.py" to "eggs.pyw" and create a shortcut to that
file. The file will be opened using pythonw.exe instead of python.exe.

--
Vincent Wehren


Is there a simple way to do that? I didn't see anything in the Python
docs about it. I suspect that this is really a dumb Windows question,
but I avoid Windows whenever I can, so most anything I can ask about it
is probably dumb.

Thanks much.

Jul 18 '05 #5
Paul Rubin wrote:
I find myself having to write some code on Windows :-(. To alleviate
the pain, at least I get to use Python for some of it.

I'm trying to write a simple application, say "eggs.py". It pops a
tkinter gui and lets the user do some stuff. The system has Python
installed so I don't care about wrapping it in a .exe file or anything
like that. But I'd like to make a desktop icon for eggs.py and let the
user double-click it and run the app without also getting a DOS box on
the screen.

Is there a simple way to do that? I didn't see anything in the Python
docs about it. I suspect that this is really a dumb Windows question,
but I avoid Windows whenever I can, so most anything I can ask about it
is probably dumb.

Thanks much.


renaming the eggs.py to eggs.pyw will tell windows to use pythonw.exe
to start this python file (and will not open a console) You can then
create a shortcut in the normal way

Martin

Jul 18 '05 #6

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

Similar topics

2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
44
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
18
by: JKop | last post by:
Here's what I know so far: You have a C++ project. You have source files in it. When you go to compile it, first thing the preprocessor sticks the header files into each source file. So now...
3
by: pooja | last post by:
Suppose i have created a class c1 with f1()in c1.cpp and included this c1.cpp in file1.cpp file , which is also having main() by giving the statement #include "c1.cpp". the same i can do by...
11
by: ambika | last post by:
Iam just trying to know "c". And I have a small doubt about these header files. The header files just contain the declaration part...Where is the definition for these declarations written??And how...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
3
by: aRTx | last post by:
I have try a couple of time but does not work for me My files everytime are sortet by NAME. I want to Sort my files by Date-desc. Can anyone help me to do it? The Script <? /* ORIGJINALI
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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,...

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.