473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 1180

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 interpreter at that point (and then you could change...
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. The thread is located here: tinyurl.com/2kk7b ...
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 to create an interactive session, without writing...
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 test.py mod = __import__("/home/me/tests/test_imp")...
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 enter the quotation mark "" first,and the move...
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. How can this be done? I saw online a -m flag but it...
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 :-) For ipython, this can be done pretty simply;...
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 it just today and got a NameError. Is this a...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.