[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] PY2EXE and Modules




Hi Laura,

    I just got through reading the Allan Harris spin on the issue.
    Also another short sample and both use different variable names when
asking for directories.

    One shows an include statement and another a PY_DIr name. It is so
confusing to try and figure out who is right and what is the real format.

    I did read enough to try something and will see what happens. The need
for a dictionary and the path as the key, or the sub directory as the key
then I will try that and see if it works. But that is what I built in my
batch file...See example below, at bottom.
    At the moment I have all the modules in the same directory and tried
listing them, but the error comes when running the .exe and the error is on
the very first import. As if the setup did not include them. So, there comes
the include statement which is only there on one tutorial I found.

    Just getting the modules imported, the data files also, is what I need.
Also, the glob.glob( command is also mention in one place, but not in
another...

    Very confusing, if just one tutorial by the person who wrote py2exe and
pygame2exe is all that is need that explains each command in detail and not
just the list from the help menu.
    Some simple and not so complex, a simple tutorial on it all!

        Bruce



http://www.py2exe.org/index.cgi/WorkingWithVariousPackagesAndModules

lists some common problems people have had with certain packages and
modules.

Laura

SAMPLE BATCH FILE FOR THE EXECUTE:
@echo off
rem NOTE: This has -w switch deleted when running python25 py2exe FOR IT IS
INVALID!
rem Batch file to automate creation of Python executables...
rem ...using py2exe
echo Making Temp Files!
rem Contents= set fileName=
copy config\1.txt config\temp1.bat
rem Contents= set dirName=
copy config\2.txt config\temp2.bat
if "%1"=="/i" goto inp4con
if not "%1"=="/I" goto line4cmd
:inp4con
echo (After each input press return,
echo  Then press ctrl Z and return again)
echo Enter the file name whose executable you want to create:
echo (...use relative or absolute path)
rem BELOW IS FOR CONSOLE INPUT OF THE NAME INSTEAD OF FROM THE COMMAND LINE:
copy config\1.txt + con config\temp1.bat
echo Enter the setup name to be created:
echo (...should be same as file name, without the extension of course!)
copy config\2.txt + con config\temp2.bat
goto making
:line4cmd
rem Inserting the file and dir name entered on command line
echo %1.py >> config\temp1.bat
echo %1 >> config\temp2.bat
if "%2"=="/m" goto modules
if not "%2"=="/M" goto making
rem Inserting the module list from a file pre-made
:modules
echo Modules?
if "%3"=="" goto making
rem Contents= setup(includes=[
copy 3.txt + %3 config\temp3
echo ]) >> config\temp3
:making
call config\temp1.bat
rem del config\temp1.bat
call config\temp2.bat
rem del config\temp2.bat
::Now you are exporting the echo to the file!
echo Now making the setup file:
echo from distutils.core import setup > config\set.py
echo import py2exe >> config\set.py
rem echo import pygame2exe >> config\set.py

rem NOW TELL IT TO MAKE AN EXECUTABLE:
echo setup(console=["%fileName%"]) >> config\set.py
if not exist config\temp3 goto d4dir
copy config\set.py + temp3 config\set.py
rem del config\temp3
:d4dir
echo setup(name="%dirName%", >> config\set.py
echo      scripts=["%fileName%"], >> config\set.py
echo ) >> config\set.py
python25 config\set.py py2exe
rem del config\set.py
echo The executable has been created in \dist\%dirName%.exe
echo errorlevel