[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pygame] Log of attempt to get pygame source to build on cygwin (HELP APPRECIATED :-)



Log of trying to install pygame
(http://www.pygame.org/ftp/pygame-1.1.tar.gz)
on cygwin(1.3.2) running on w2k(sp2)

Comment: there are largish sections of compiler/script output, in this
narrative, they
are commented with """..."""


First of all... doesn't work if you get the precompiled binaries for
windows...
so avoid that (unless someone knows better).
What we need is a source build of pygame for cygwin (not what I want to
do, but there
doesn't seem to be a way to get a precompiled cygwin for a unix box -
probably fair enough given
the breadth of 'unix box')

Download the .tar.gz file, (url above)
Expand it, tar -xzvf ../download/pygame/pygame-1.1.tar.gz
Now we have /cygdrive/c/Python21/pygame-1.1 tree
cd to top of this subtree and look ...

Now... Pete Shinners suggests trying the following to persuade distutils
(wot that?ed?)
to build a cygwin version:-
<<in a file named "setup.cfg">>
[build_ext]
compiler=cygwin
<<endoffile>>
So first step is create that,
OK


Then do "python setup.py install" from the ./pygame-1.1 tree hopefully...
So try that,
I get :


WARNING, No "Setup" File Exists, Running "config.p
Using UNIX configuration...

calling "sdl-config"
Found SDL version: 1.2.2

Hunting dependencies...
SDL     : not found
FONT    : not found
IMAGE   : not found
MIXER   : not found
SMPEG   : not found

If you get compiler errors during install, doublec
the compiler flags in the "Setup" file.


Continuing With "setup.py"
running install
running build
running build_py
creating build
creating build/lib.cygwin_nt-5.0-1.3.2-i686-2.1
creating build/lib.cygwin_nt-5.0-1.3.2-i686-2.1/py
copying lib/cursors.py -> build/lib.cygwin_nt-5.0-
copying lib/locals.py -> build/lib.cygwin_nt-5.0-1
copying lib/UserRect.py -> build/lib.cygwin_nt-5.0
copying lib/version.py -> build/lib.cygwin_nt-5.0-
copying lib/__init__.py -> build/lib.cygwin_nt-5.0
running build_ext
building 'pygame.surfarray' extension
creating build/temp.cygwin_nt-5.0-1.3.2-i686-2.1
gcc -mcygwin -mdll -O -Wall -I/NEED_INC_PATH_FIX -
/surfarray.c -o build/temp.cygwin_nt-5.0-1.3.2-i68
In file included from src/surfarray.c:23:
src/pygame.h:63: SDL.h: No such file or directory
src/surfarray.c:25: SDL_byteorder.h: No such file
error: command 'gcc' failed with exit status 1
"""

Which isn't ideal :-)

What's going on then.
Well first sdl-config is being found (good) but not the .h and lib (.a in
this case I think) files.
Sooo... let's run sdl-config and see what it says (the idea of these
things seems to be that the installed
code reports back to dependent apps/code via a -config utility which
adopts a standard commandline and
output format.
so, "sdl-config --libs --cflags --", which outputs
"""
-L/usr/local/lib -lmingw32 -lSDLmain -lSDL -mwindows -mno-cygwin
-I/usr/local/include -I/usr/local/include/SDL -Dmain=SDL_main
-I/usr/include/mingw -DWIN32 -Uunix
"""

So how come this isn't getting through to setup.py, which is still trying
to build things with
a .h include directory of /NEED_INC_PATH_FIX, which looks a wee bit like a
heads up...

This is perhaps because (see the top of that script output for,
"""
Hunting dependencies...
SDL     : not found
FONT    : not found
IMAGE   : not found
MIXER   : not found
SMPEG   : not found
"""
in other words none of the libraries were found.
Nor the includes.


Now strangely... the setup.py code (part of pygame) cannot cope with
multiple include or library directories
in the output from sdl-config - something I was looking at on an earlier
attempt to build pygame.
The code which handles this is in ./pygame/config_unix.py
"""
def main():
    global DEPS

    print 'calling "sdl-config"'
    configinfo = "-I/usr/local/include/SDL -L/usr/local/lib -D_REENTRANT
-lSDL"
    try:
        configinfo = os.popen(configcommand).readlines()
        print 'Found SDL version:', configinfo[0]
        configinfo = ' '.join(configinfo[1:])
        configinfo = configinfo.split()
        for w in configinfo[:]:
            if ',' in w: configinfo.remove(w)
        configinfo = ' '.join(configinfo)
        #print 'Flags:', configinfo
    except:
        raise SystemExit, """Cannot locate command, "sdl-config". Default
SDL co
mpile
flags have been used, which will likely require a little editing."""

    print 'Hunting dependencies...'
    if localbase:
        incdir = localbase + '/include/SDL11'
        libdir = localbase + '/lib'
    else:
        incdir = libdir = ''
        for arg in configinfo.split():
            if arg.startswith('-I'):
                incdir = arg[2:]
#!!!      print 'incdir set to [' + incdir + ']'
            elif arg.startswith('-L'):
                libdir = arg[2:]
    for d in DEPS:
        d.configure(incdir, libdir)

    DEPS[0].inc_dir = None
    DEPS[0].lib_dir = None
    DEPS[0].cflags = configinfo

    return DEPS
"""

Localbase isn't defined (check with $ set), so
This code reads the output of sdl-config and then uses the LAST appearing
-I and -L options from the
sdl-config output to setup the include and library directories.

So what is the output of sdl-config then ?
"""
$ sdl-config --libs --cflags
-L/usr/local/lib -lmingw32 -lSDLmain -lSDL -mwindows -mno-cygwin
-I/usr/local/include -I/usr/local/include/SDL -Dmain=SDL_main
-I/usr/include/mingw -DWIN32 -Uunix
"""

Which means it will be trying /usr/include/mingw for the include directory
(last mentioned, probably wrong)
and /usr/local/lib for libraries (last mentioned, well only one mentioned,
good)

Let's check that by inserting the (commented out above) line marked #!!!!
in the code above.

After a bit of hunting around...

Well it works if I run ./config.py but that isn't how ./setup.py install
is working, it seems
that something else is writing the /NEED_INC_PATH_FIX mess into the
compilation.

I wonder why ??


grep NEED_INC_PATH_FIX *


OK maybe it is config_unix after all... seems that config.py contains the
NEED_INC_PATH_FIX assignment.
Let's test this theory by changing config.py to have a default -I
(include) param. value of 'SHOULD_NEVER_SEE_THIS_INC_PATH'
so now we have (snippet from config.py)
"""
def prepdep(dep, basepath):
    "add some vars to a dep"
    dep.line = dep.name + ' = -l' + dep.lib
    dep.varname = '$('+dep.name+')'

    if not dep.found:
        if dep.name == 'SDL': #fudge if this is unfound SDL
#            dep.line = 'SDL = -I/NEED_INC_PATH_FIX -L/NEED_LIB_PATH_FIX
-lSDL'
            dep.line = 'SDL = -I/SHOULD_NEVER_SEE_THIS_INC_PATH
-L/SHOULD_NEVER_SEE_THIS_LIB_PATH -lSDL'
"""
(I did the -L lib one too)

Now try "./setup.py install" again to see if these bad -I and -L values
make it through...
Nope... they don't

oh dear...

Where else do they come from, doh! also in file "Setup"
So edit that one too, to -I/SETUP_BAD_INC_PATH and -L/SETUP_BAD_LIB_PATH
and try again, to see if that's the one (pretty sure it is, but assuming
it would be bad)


Yes... hurrah... now the compilation attempted is
 gcc -mcygwin -mdll -O -Wall -I/SETUP_BAD_INC_PATH
-I/usr/include/python2.1
 -c src/surfarray.c -o build/temp.cygwin_nt-5.0-1.3.2-i686-2.1/surfarray.o

So why isn't the -I value getting set to a non-default (bad) value?
Well setup.py is creating the Setup file... (going in circles ?)
Ah... on reading this it looks like the Setup file had to be removed, or
it wouldn't be recreated.
Maybe... it uses config.py which probably calls config_unix, hmmm.
Let's try that, and see if the SHOULD_NEVER_SEE_THIS_INC_PATH makes it
through to the Setup file.
 rm Setup
 ./setup.py install

yes hurrah the output includes the line,
 gcc -mcygwin -mdll -O -Wall -I/SHOULD_NEVER_SEE_THIS_INC_PATH
-I/usr/include/python2.1
 -c src/surfarray.c -o build/temp.cygwin_nt-5.0-1.3.2-i686-2.1/surfarray.o

Well at least the error gets there for a reason...

So perhaps my idea about the output from sdl-config being processed badly
is right ?


As a manual test, try patching the 'Setup' file (saves debugging
config_unix.py for now - although we
do know, I think I do anyway - Python newbie, that the hunting dependcies
code cannot work if sdl-config
wants more than one -I or -L value.
But we can patch to anything so, change Setup (first few real lines) to
read :

#SDL = -I/SHOULD_NEVER_SEE_THIS_INC_PATH -L/NEED_LIB_PATH_FIX -lSDL
SDL = -I/usr/local/include -I/usr/local/include/SDL -Dmain=SDL_main
-I/usr/include/mingw -DWIN32 -Uunix

And try again (but not removing Setup this time of course)
 ./setup.py install


Hmmm... the gcc error output has changed now, to (pls excuse linewraps),
"""
building 'pygame.surfarray' extension
gcc -mcygwin -mdll -O -Wall -Dmain=DL_main -DWIN32 -Uunix
-I/usr/local/include -
I/usr/local/include/SDL -I/usr/include/mingw -I/usr/include/python2.1 -c
src/sur
farray.c -o build/temp.cygwin_nt-5.0-1.3.2-i686-2.1/surfarray.o
In file included from /usr/local/include/SDL/SDL.h:33,
                 from src/pygame.h:63,
                 from src/surfarray.c:23:
/usr/local/include/SDL/SDL_main.h:51: warning: `main' redefined
*Initialization*:1: warning: this is the location of the previous
definition
In file included from /usr/include/python2.1/pyport.h:110,
                 from /usr/include/python2.1/Python.h:54,
                 from src/pygame.h:57,
                 from src/surfarray.c:23:
/usr/include/sys/select.h:28: parse error before `fd_set'
error: command 'gcc' failed with exit status 1
"""

Oh dear... this is getting rather involved,  I was hoping to avoid
anything to do with fd_set !!!
Isn't that part of the TCP/IP socket handling..., along with select.h,
well that much at least ties together.

Hmmm we have two main progs, and perhaps too many libraries.
Perhaps I should empty out the build subtree and try again...?


Unfortunately that makes no difference (well it announces creating
build/temp.cygwin.../ directory again.
Not much progress




I'll send this in and have a coffee... if anyone recognises this and has
an answer (+ve or -ve) I'd appreciate it.


Cheers


peter

Pete Shinners wrote:

> > ...just being slightly lazy following a 24h stint of trying to get
> > pygame to work ! OK It does work with demos, I just can't build it
> > and use it from Python.
>
> wow, it sounds like you've put a lot of work into this. here's
> some insight into distutils..
>
> first, i'm almost positive distutils doesn't work for cross-compiling.
> there may be some way to get it working, but i've never heard of it
> being used. i also wouldn't know where to start.
>
> second, distutils defaults to using the MS compile (cl.exe) on
> windows, but it can easily use several different compilers.
> the "build_ext" command in distutils takes a --compiler flag.
> you can give multiple commands to distutils in one commandline,
> each with the appropriate flags.. you would be looking for
> something like this
>
> python setup.py install build_ext --compiler=cygwin
>
> if passing this compiler info to distutils becomes a hassle,
> distutils also lets you store a config file where you can keep
> commandline arguments that you always use..
>
> <<in a file named "setup.cfg">>
> [build_ext]
> compiler=cygwin
> <<endoffile>>
>
> you may also find more helpful tips here,
> http://www.python.org/doc/current/inst/non-ms-compilers.html
>
>
> also, you mentioned the examples were working for you, but
> you could compile pygame? i don't quite understand that. you
> don't get the pygame examples without pygame :]
>
> as a last resort, there are several precompiled version of
> pygame for windows. but for cvs versions of pygame you'll
> need to get the compiling working.
>
> also, feel free to send in your progress. i'll be glad to
> help you get this going.
>
> ____________________________________
> pygame mailing list
> pygame-users@seul.org
> http://pygame.seul.org

--


-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGPfreeware 7.0.3 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xnIByl6ypUM2Zafq9AKUJsCRtMIPWakXUGfnHy9iUsiGSa6q6Je
w1XpMgs7AAICB/9HKgMIKYR5WyA96n0e36C1y9vKfG7IR7SbSzHe0InTS6W/y8c5
cjkyIcFjiz+f6UblUj8SPzi9pZVwl/cE/YSZ7NscWED4mjTpbt8s6IOaxvvneeZN
GJMbKuNY9BY39+/ynwsqFSkxPQ8oCQUnfHGMjC8nhDFBvnZRU2pHZvyvgH+qecNd
8vDGNGkUFSj8R5jLF2M/jFjvYMjTd3VR3pUuMslslCDnQGNfDPkcB+9sRkoZPpRP
aUt9g5vzMYlZVDSmDTiy8zZ+lhcsq2TbHkwqX4iwow/KB3lsdFgUzbp8V9FlSnuL
X4B04MviS2/+nfxM7TZIYn+uXle3+pfGlF2liQBMBBgRAgAMBQI7gNOHBRsMAAAA
AAoJEBylPoXihJTJSPcAnRPSivOU4RbzkmfvZF7RBycxm5ubAJ96QW1kGhkc13zR
ozfk3rcGqoHeWg==
=fGmQ
-----END PGP PUBLIC KEY BLOCK-----


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org