Crystal Space
Welcome, Guest. Please login or register.
August 02, 2014, 04:10:24 am

Login with username, password and session length
Search:     Advanced search
9005 Posts in 2043 Topics by 8273 Members
Latest Member: Ai16x2t
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  General Crystal Space Discussion
| | |-+  py2app or py2exe with CS?
« previous next »
Pages: [1] Print
Author Topic: py2app or py2exe with CS?  (Read 4317 times)
jason
Guest


Email
« on: October 19, 2005, 09:06:07 pm »

Has anyone tried to create an executable with py2app (for Mac) or py2exe (for Windows) with Crystal Space?  Using Python to drive the engine would become viable for commercial games if there's a way to not require players to have to download and install Python.  I'm highly interested in using this engine for this purpose.
Thanks!
Logged
griminventions
Newbie
*
Posts: 33


View Profile
« Reply #1 on: October 21, 2005, 07:31:46 am »

Just thought I'd mention, I'm working on this.  And it was me who posted the above question, so hello myself.  Smiley

The executable is getting the data etc, but it's using the VFS and/or env variables.  The Resources dir does not include the data, so obviously this would not work on a machine that didn't have CS installed, and that's not what we want.  I'm still wrapping my mind around how these pieces all fit together.

I wonder if modifying the vfs.cfg to point to the app bundle would allow the executable to look for those resources inside the app bundle?

...much to learn...
Logged
Ruel Haldi
Newbie
*
Posts: 18


View Profile Email
« Reply #2 on: November 18, 2005, 12:11:19 am »

I've been waiting to see if you would get any replies.

I only started a few weeks ago, so I won't be much help. However, this is the last critical step in my decision whether to choose to continue with CrystalSpace. I've brute-forced my way through most of the other Python issues I ran into, but this problem is just too far over my head. I now have a few proof-of-concept apps built, but without the ability to compile and give the final application to someone that doesn't have CS and Python, there isn't much point in continuing.

Eagerly awaiting any news on this front.
Logged
sunshine
Administrator
Sr. Member
*****
Posts: 294


View Profile
« Reply #3 on: November 18, 2005, 05:40:02 am »

What exactly is the trouble you are encountering. It should be possible to get this working. Perhaps you can rephrase your question or issue more precisely.
Logged
Ruel Haldi
Newbie
*
Posts: 18


View Profile Email
« Reply #4 on: November 18, 2005, 09:38:01 pm »

I will try to explain, although I'm still very new and Grimventions clearly knows what he's doing better than I do.

When you have finished a Python script, and you want to make it accessible to other users that don't have Python (and all the libraries) available on their machine, you compile it as an executable (in Windows) so it can be run on any computer. This is a critical step to making useful programs in Python, since you can't expect your users to go download (and install) Python before they can run your program.

The problem arises in that we don't know how well py2exe will handle the complex CS environment. From his post, I think Grimventions is initially having trouble getting the executable to recognize where to look for the VFS.

In my case, I'm stuck at a much earlier point, as I can't even get py2exe to start a compile. Here's the error message, unfortunately it doesn't reference any part of CS, so  I don't know if the problem is even related to CS, or it's somewhere within py2exe itself. Though since py2exe can handle anything else I've thrown at it, I'm not really sure where to start.

C:\CS>python gamesetup.py py2exe
Traceback (most recent call last):
  File "gamesetup.py", line 2, in ?
    from distutils.core import setup
  File "C:\Python24\lib\distutils\core.py", line 21, in ?
    from distutils.dist import Distribution
  File "C:\Python24\lib\distutils\dist.py", line 13, in ?
    from copy import copy
  File "C:\Python24\lib\copy.py", line 65, in ?
    import inspect
  File "C:\Python24\lib\inspect.py", line 31, in ?
    import sys, os, types, string, re, dis, imp, tokenize, linecache
  File "C:\Python24\lib\dis.py", line 6, in ?
    from opcode import *
ImportError: dynamic module does not define init function (initopcode)
Logged
sunshine
Administrator
Sr. Member
*****
Posts: 294


View Profile
« Reply #5 on: November 21, 2005, 02:37:48 pm »

This error appears to be internal to either py2exe or Python 2.4 itself. It is failing when importing the distribution-supplied 'dis' module. Are you sure that your Python distribution is not perhaps corrupt?

As for griminvention's post, it sounds more like he didn't tell py2exe to copy the CS data files / DLL's / etc. into the generated distribution file.
Logged
Ruel Haldi
Newbie
*
Posts: 18


View Profile Email
« Reply #6 on: December 15, 2005, 02:41:05 am »

Since I still haven't heard any py2exe success stories, I suspect that nobody has ever prepared a CrystalSpace (using Python) script into an exe file. This is an important issue for anyone wishing to use Python for CrystalSpace, because if you can't freeze it to an exectuble, you have to copy the whole thing (uncompiled, with all the libraries) to other users.

I'm still stuck at the same error despite reinstall of Python (including older versions). py2exe has been able to handle any other file that I've thrown at it (including some test cases), so to me, it seems like the issue must be a failure to handle CrystalSpace's code. For example, I've used py2exe on some other games that I've made using the pygame libraries and a proof-of-concept using Ogre3d.

However, I like the design philosophy and the visual results from CrystalSpace best, so I still want to follow it. Unfortunately, I do not have the background to approach this level of problem. Possibly, I'm just doing something stupid. However, I'm forced to proceed with my effort using other engines. But I'll definitely keep an eye here for any updates.
Logged
sunshine
Administrator
Sr. Member
*****
Posts: 294


View Profile
« Reply #7 on: December 15, 2005, 02:48:14 pm »

Item #2 on this page says that the problem is probably your Python search path:

http://biggles.sourceforge.net/doc/1.5/faq/

From this, I gather that your Python search path mentions a directory containing a libopcode.dll (or obcode.dll or whatever). You want to try to re-arrange your Python search path so that it searches the Python library directory first and finds Python's own opcode.py first. Even this might not work, though, because it still might get confused over CS's "opcode" plugin DLL.

If the above doesn't work, you might try to rename CS's opcode plugin, as well as the corresponding .csplugin file if one exists.

Please report if renaming the CS opcode plugin resolves the problem. If it does, we can rename the plugin in CS itself to something other (such as csopcode.dll, for instance).
« Last Edit: December 15, 2005, 02:52:10 pm by sunshine » Logged
Ruel Haldi
Newbie
*
Posts: 18


View Profile Email
« Reply #8 on: December 15, 2005, 04:20:08 pm »

Ah! That definitely explains the problem. Now that I understand better, I will try to fix it. I'm kinda busy for a while, so it may be a week or two before I can address it properly.

Thank you!
Logged
Ruel Haldi
Newbie
*
Posts: 18


View Profile Email
« Reply #9 on: December 15, 2005, 07:34:24 pm »

I got a spare moment today, so I put in a few minutes, and I got it to work. Big thanks to Sunshine for explaining what my problem was!

For future users, here's what I did:
Since CrystalSpace was using the same name for one of Python's modules, I copied the Python module (opcode.py) renaming it (disopcode.py). Then, I changed dis.py to import disopcode.py instead of opcode.py. This worked perfectly, although it's not the best solution because if I ever reinstall Python or future modules try to call opcode.py, I'll run into the same problem again. However, it works for now. I now have a finished proof-of-concept compiled into a finished .exe file. It's only 23kb, but comes with ~8 megs of DLLs and PYDs and compressed PYCs.

I did try switching Python's path order as suggested, but this didn't achieve quick results, so I switched it back and moved on. I also looked at changing CrystalSpace's opcode module's name, but since I wasn't certain of all the spots that referenced it, I decided my method would be easier.
Logged
sunshine
Administrator
Sr. Member
*****
Posts: 294


View Profile
« Reply #10 on: December 16, 2005, 03:16:57 pm »

Quote
I also looked at changing CrystalSpace's opcode module's name, but since I wasn't certain of all the spots that referenced it, I decided my method would be easier.

Nothing in CS references it by its filename, so it should be safe to rename the DLL (and the associated .csplugin file if there is one). CS plugins are self-describing. SCF scans for DLL's and asks the DLL for the names of the SCF classes it holds. The rest of CS only references the plugin by the SCF names.

I'm going to go ahead and rename the CS 'opcode' plugin in the CVS repository to avoid this problem in the future.
Logged
sunshine
Administrator
Sr. Member
*****
Posts: 294


View Profile
« Reply #11 on: December 16, 2005, 03:53:06 pm »

I renamed the module to 'csopcode' in CS's CVS repository. This change should be reflected to anonymous CVS within six hours.
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 5.163 seconds with 15 queries.