472,328 Members | 1,248 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,328 software developers and data experts.

Python Interactive Interpreter Breakage

I am trying to write a Python module to embed the functionality of
Maya (the 3D modelling and animation application from Autodesk,
formerly Alias) for doing scripted scene manipulation and rendering
processes in Python.

I am aware of the CGKit project, which does this and a lot more, but
it is over-complex for our needs, and also does not work in the
context of a pure command-line Python script, only as an alternative
scripting language within Maya.

I am also aware that the next version of Maya (8.5) is reputed to have
Python integrated, hopefully both internally and externally as I am
trying to set up.

Since I'm impatient, and also love having my code obsoleted within
months, I'm still going ahead with doing it myself but have hit a
problem.

I have the code in two forms.

Firstly, a pure C++ module, which links with the Maya DLLs (this is on
Windows, before you ask) and provides three functions, one to
initialize the Maya engine, one to send it a command it it's
proprietary native scripting language, MEL, and a third to shut it
down.

An input script for this would be something like:

import maya
maya.initialize()
maya.mel("float $a = 1.234; print $a * 2;")
maya.cleanup()

I also have it in the form of an executable which embeds the Python
interpreter and implements the middle function as an internally
"added" module, doing the initialize and shutdown itself (sandwiching
the Python stuff). This version can either read in a script file and
pass it to PyRun_SimpleFile() or pass stdin to PyRun_InteractiveLoop()
to allow you to enter Python interactively just like python.exe.

An input script for this would just be the maya.mel(...) line, since
the rest is implicit.

In both cases, if I feed it an actual Python script file, then
everything works properly. The Maya engine fires up, and I can feed it
commands which it will execute, and it shuts down at the end.

However, also in both cases, if run interactively, if you send a
command to the Maya engine to perform a particular process, it does it
correctly, but the interactive interpreter is then broken. Whatever
you then type, even a blank line, results in a SyntaxError exception,
with the pointer pointing to the end of what you typed.

The process in question is telling Maya to load a plug-in (a DLL)
which is an application extension to render or export to the Mental
Images "mental ray" renderer. This is a fairly complex DLL which
itself is dependent on other DLLs, but that really shouldn't matter.

I then tried building the executable version of my code in Debug mode
against my own debug build of Python (I have tried 2.4.4, which is our
current user version, and 2.5, with the same result) and then IT WORKS
PERFECTLY! >:(

If you've stayed with me this far, well done.

Anyone have any ideas what could break the interactive interpreter
mechanism like this?

Obviously I have no control over the behaviour of the Maya API
libraries or the mental ray libraries which are subsequently loaded,
so it could be that something is trashing memory somewhere. There is
no hard crash I can debug, though (especially since the problem
doesn't happen AT ALL with a Debug build).

Maybe I need BoundsChecker to trap it. Shame I can't afford it... <:\

Yours hopeful that I haven't bored you all to tears,

Simon
Dec 16 '06 #1
0 1104

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

Similar topics

2
by: Dave Reed | last post by:
I seem to remeber reading somewhere there was a statement you could put in your python program to stop its execution and start the interactive...
0
by: Jonas Galvez | last post by:
A few days ago I posted about a problem I was having on Win2k, regarding a SyntaxError error on the interactive interpreter to anything I typed....
2
by: Miki Tebeka | last post by:
Hello All, If there a way a script can tell Python to enter interactive mode even if the -i command line switch was not given? I want py2exe...
5
by: linuxnow | last post by:
I don't know what I'm doing wrong, but the result is that _import_ only works from a python shell, but not when I call a python script. $ cat...
6
by: ThomasC | last post by:
Hello, How to configure Python2.5's interactive interpreter to get command history ? I always got ^[[A and ^[[B . Thank you !! Thomas#
4
by: yan.python | last post by:
i have a question. when i run Interactive Interpreter in linux command promt,how can i move the cursor. for example,when i enter a string,i often...
4
by: Peter J. Bismuti | last post by:
I want to interpret a file (or whatever you call it) and then keep the interactive interpreter alive so I can then continue to issue commands. ...
3
by: R. Bernstein | last post by:
The next release of pydb will have the ability to go into ipython from inside the debugger. Sort of like how in ruby-debug you can go into irb :-)...
2
by: The Pythonista | last post by:
I remember the interactive interpreter used to define the name _ to return the value of the last expression that was evaluated. However, I tried...
0
by: tammygombez | last post by:
Hey fellow JavaFX developers, I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...

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.