473,586 Members | 2,854 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_SimpleFil e() or pass stdin to PyRun_Interacti veLoop()
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 1197

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

Similar topics

2
3498
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 the value of some variables and continue executing). Am I having delusions or is there a way to do this? Thanks, Dave
0
1200
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 I've mode some progress on this. I noticed that the problem in fact lies on the line break. If I place a # on the end of the line, Python has no...
2
1833
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 my own REPL. Thanks. --
5
1711
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") Called from a script it does not work: $ python /home/me/test.py Traceback (most recent call last): File "/home/pau/test.py", line 1, in ?
6
1937
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
3301
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 the cursor inside the mark to enter the string,in windows,it is ok.but when i do that in linux,pressing the "left" key will just print "^[[D" in the...
4
1310
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 does not seem to work. Thanks --
3
1876
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; there is an IPShellEmbed method which returns something you can call. But how could one do the same for the stock python interactive shell? To take...
2
983
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 change in the interpreter or is there a configuration option I need to set to enable it? Thanks! -- code.py: A blog about life, the universe, and...
0
7911
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7954
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3836
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.