Cross-platform development with PyOgre?

osxguy

04-08-2006 04:03:26

I would like to do development on Linux and generate easy-to-install games for Linux/Windows/Mac users.

I use Python for development. I do primary development on Linux and OS/X. I don't have a modern copy of Windows available to me, and don't plan on buying Windows again anytime soon. However, many of my potential customers run Windows.

Now, there is a program called py2exe that can make a single Windows executable file from a Python program. This way, Windows users can install my Python/PyOgre games. The problem is that py2exe requires Windows to run. It doesn't work on Linux even using WINE - there are unsuccessful reports of people trying.

Basically I have three main questions:

1. If I develop my Python game with PyOgre on Linux against stable, released binary versions of Python, OGRE and PyOgre, will my Python code work on Windows if the Windows user installs the same version of OGRE (for their platform), the same version of PyOgre (for their platform), the same version of Python, and my Python source code and media?
2. Is there an easy way of creating an installable package for Windows users without using Windows? Something that would install all of the items in (1) automatically?
3. Is (shudder) Java or Jython a better language choice for this kind of write-once, deploy-anywhere scenario?

I've been thinking about Jython, but the problem is that PyOgre uses SWIG bindings to native C++ code, and this generates a platform-specific binary module imported by Python, so even with Jython the result wouldn't be platform-independent as long as we're using SWIG Python-to-C++ bindings.

Unfortunately I'm starting to think that a pure Java solution (ogre4j) might be the only way to develop easy-to-install Windows software without using Windows.

Comments?

osxguy

04-08-2006 04:40:22

I just found the program "Inno Setup" which works on Linux under WINE. It apparently can be used to create single-file installable Windows EXE files, running (under WINE) on Linux.

So how about this for a procedure to create PyOgre executables for Windows under Linux:
* Assume no registry keys are set or required by any software installation.
* Install OGRE for Windows on Linux using WINE.
* Install Python for Windows on Linux using WINE.
* Install PyOgre for Windows on Linux using WINE.
* Manually make a list of all files installed by OGRE, Python, PyOgre.
* Run "Inno Setup" on Linux using WINE.
* Enter the list of all files installed by OGRE, Python, PyOgre.
* Add list of all of my Python source files.
* Create Windows EXE file using "Inno Setup".

Think this would work?

Istari

04-08-2006 11:01:10

If you use stable pre-built versions of PyOgre and Python, you should have no problem with distribution to Windows clients.
And if you are interested, here is a collection of notes which I made when I was thinking about distribution of my own PyOgre games.

Python requires the following files:
  1. Python24.dll
    An exe file, which can be python.exe or a custom one like the one created by py2exe (or even a custom one created by you with the mingw32 cross-compiler)
    lib/site.py (and all the modules it depends on)
    (any other modules from the standard library that you may need)[/list:u]
    PyOgre requires the Ogre libraries to run and looks first for them in the same directory as the swig wrapper.
    So that's where you should put the Ogre libraries (or use a pre-built binary distribution of PyOgre which includes the Ogre libs).
    The .pyc and .pyo files that Python writes it's bytecode to are platform independent and may be used in place of the .py files.
    Python imports .py/.pyc/.pyo (but not .pyd/.dll) files from zip files natively. All you need to do is make sure that the zip file's path is in sys.path
    Your install directory could then look something like this:
    1. dll-libs/pyogre/*
      media/*
      media.cfg
      resources.cfg
      ...
      Python24.dll
      modules.zip (this would include your game .pyo files and what you need from the standard Python library)
      game.exe (this should add os.path.abspath('./modules.zip') and os.path.abspath('./dll-libs') to sys.path and then import your game module and execute it)[/list:u]

griminventions

04-08-2006 19:45:41

Nice summary of the data's organization. Thanks for that.

I don't suppose PyOgre is running on Mac OSX yet? (I've been away for a while.)

Istari

04-08-2006 22:34:41

I don't think that anyone is currently working on getting PyOgre to run on OS X.