473,748 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Building Py2Exe from source

I need to be able to build Py2Exe from the source code as I am making
a Windows executable where I wish to preprocess the modules before
importing them.It looks like I can do this by adding lines to
Load_Module() in py2exe's start.c. However problem I have is that I
can't build Py2Exe using the instructions provided. Using the
designated command of "python setup.py install" I get this error:
Traceback (most recent call last):
File "setup.py", line 340, in ?
raise RuntimeError, msg
RuntimeError: PYWIN32DIR invalid.

To build py2exe from source, you must either:

- Download and build Mark Hammond's pywin32 source code
from http://starship.python.net/crew/mhammond, and set
the PYWIN32DIR variable to point to this directory

- or change this setup script to not build run_svc target,
then you will not be able to build Windows NT services
with py2exe.
The main problem I encountered is that the 2nd option appears
misleading: removing run_svc from the list of targets does no good as
it still attempts to find some sort of "win32" directory before it
even gets that far. Or maybe I'm missing something.

If option 1 requires following these arduous-looking instructions:
<http://starship.python .net/crew/mhammond/win32/BuildingExtensi ons.html>
then I'd rather bypass that if at all possible. :) I only need to
build standard executables, not DLLs, NT services, or anything to do
with COM.

Any help getting around this problem would be much appreciated.

(Platform: Win98SE, Python 2.3.3.)

--
Ben Sizer
Jul 18 '05 #1
2 2682
ky*****@hotmail .com (Kylotan) writes:
I need to be able to build Py2Exe from the source code as I am making
a Windows executable where I wish to preprocess the modules before
importing them.
Hm, is this really a good idea? py2exe includes the .pyc (or .pyo)
files, not the sources itself. Can't you preprocess them while building
the exe? This way you would only have to hack python-code, not C code...
It looks like I can do this by adding lines to
Load_Module() in py2exe's start.c. However problem I have is that I
can't build Py2Exe using the instructions provided. Using the
designated command of "python setup.py install" I get this error:
Traceback (most recent call last):
File "setup.py", line 340, in ?
raise RuntimeError, msg
RuntimeError: PYWIN32DIR invalid.

To build py2exe from source, you must either:

- Download and build Mark Hammond's pywin32 source code
from http://starship.python.net/crew/mhammond, and set
the PYWIN32DIR variable to point to this directory

- or change this setup script to not build run_svc target,
then you will not be able to build Windows NT services
with py2exe.
The main problem I encountered is that the 2nd option appears
misleading: removing run_svc from the list of targets does no good as
it still attempts to find some sort of "win32" directory before it
even gets that far. Or maybe I'm missing something.
You *should* be able to hack the py2exe setup-script to do this, only
removing run_svc from the list is certainly not enough.
Any help getting around this problem would be much appreciated.

(Platform: Win98SE, Python 2.3.3.)


Normally I would recommend the upcoming py2exe 0.5 for this, although it
does not yet run on Win98, but I'm working on it.

Thomas
Jul 18 '05 #2
Thomas Heller <th*****@python .net> wrote in message news:<oe******* ***@python.net> ...
ky*****@hotmail .com (Kylotan) writes:
I need to be able to build Py2Exe from the source code as I am making
a Windows executable where I wish to preprocess the modules before
importing them.
Hm, is this really a good idea? py2exe includes the .pyc (or .pyo)
files, not the sources itself. Can't you preprocess them while building
the exe? This way you would only have to hack python-code, not C code...


One of my requirements is encryption of the pyc files. (I need -some-
degree of basic protection against decompyle and the like.) The file
in the archive needs to be encrypted and only decrypted when it comes
to be imported. This looks like only being about 3 or 4 lines of extra
C code (given a standalone encryption library) if put in the correct
place.
You *should* be able to hack the py2exe setup-script to do this, only
removing run_svc from the list is certainly not enough.
Sadly Python is my 2nd language, and these distutils scripts in
general are possibly the most complex (or at least idiosyncratic) code
that I've seen. I understand very little of it. :) And wouldn't know
where to start altering it.
Normally I would recommend the upcoming py2exe 0.5 for this, although it
does not yet run on Win98, but I'm working on it.


Ok. I don't need to do this urgently, but Win98SE is going to be both
a key development and deployment platform for me.

--
Ben Sizer
Jul 18 '05 #3

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

Similar topics

3
3644
by: ulysses | last post by:
hi. I use python 23,py2exe 0.4.3 ,wxpython do my py app in win32. I use gettext to support multi languages. I build a small fuction for load language at top of main module. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def setLan(lan): import gettext langs = gettext.GNUTranslations(open (join ( localPath, ( "lan/"+lan+".mo" ) )
2
6983
by: Anthony Baxter | last post by:
I'm trying to use py2exe and Inno Setup to build an installer for shtoom, which uses tkinter. If I take the py2exe generated directory, and run the executable from there, it works fine. If I add all the files in the directory to an installer (including the tk-8.4 and tcl-8.4 directories), it builds an installer fine. But when I run the installer, and install to, say c:/Program Files/Shtoom,
3
5724
by: Werner Merkl | last post by:
Hi, Python is really great, for small to big programs. For my colleagues and some circumstances I sometimes need to "compile" a script using py2exe. Cause I use Windows, I like to use the (Windows) ability, to add some version infos, comments, etc to the exe file. If I use explorer to check, these properties are visible and correct.
1
1774
by: Intaek LIM | last post by:
i'd tried to build my work with py2exe. my work consisted of: D:\temp\main.py D:\temp\ui\__init__.py (contains __all__= D:\temp\ui\dlg.py D:\temp\ui\dlgevent.py D:\temp\mymod\__init__.py (contains __all__= D:\temp\mymod\auth.py D:\temp\mymod\session.py
0
1530
by: Jimmy Retzlaff | last post by:
py2exe 0.6.4 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.4:
0
1517
by: Jimmy Retzlaff | last post by:
py2exe 0.6.5 released ===================== py2exe is a Python distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation. Console and Windows (GUI) applications, Windows NT services, exe and dll COM servers are supported. Changes in 0.6.5:
0
13472
bartonc
by: bartonc | last post by:
You can find the original author of the script by ggling " Py2Exe version 6.3 setup" The cool thing about this is that it calls py2exe, just in case you're uncomfortable with the command line. I had to search hi and lo for the example of how to exclude Tkinter. Coming soon: scipy includes and numpy include that gets rid of complaints of missing modules that are fantom errors. # Py2Exe version 6.3 setup file for wxPython GUI programs. #...
2
1916
by: vedrandekovic | last post by:
Hello, Is there any solution for building exe file from python script something like bbfreeze.When user write some script in my program, it must compile script into exe without opening console ( cmd ).I'am working on Windows XP SP2 and Python 2.5. Regards,
5
2122
by: Alexnb | last post by:
Hello I am sure most of you are familiar with py2exe. I am having a bit of a problem. See the program has a few pictures involved and the .ico it uses for the windows. However, the pictures are stored in the same directory as the source, something like: C:\Docs and settings\me\My docs\python\program. When I run the program for the interpreter, just as a .py, everything works just as it should. However, when I compile the main source as...
0
8822
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,...
0
9528
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9359
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9236
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8235
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6792
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
6072
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4592
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...
3
2206
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.