[Pythonmac-SIG] MachoPython 2.2.2 build works; 3 minor questions

Russell E Owen owen@astro.washington.edu
Fri, 8 Nov 2002 09:56:52 -0800


>On Friday, Nov 8, 2002, at 01:26 Europe/Amsterdam, Russell E Owen wrote:
>>1) Readlines support is missing when python is run via the shell 
>>script in pythonw, though one can activate it by doing "import 
>>readline". Any idea how to get that done automatically at startup?
>
>Put it in your PYTHONSTARTUP file. Or add it to sitecustomize.py. Or 
>there are probably many other ways...

Thanks. I added it to sitecustomize.py and it worked beautifully.

As a warning to others:

I was NOT able to get PYTHONPATH working. There are two problems (the 
first expected, the second may be a bug):

I defined a file ~/pythonstartup.py that had a print statement, so I 
could see immediately if it worked.

(problem 1) Defining PYTHONSTARTUP in ~/.cshrc worked fine for python 
but was not seen by pythonw, as verified by examining os.environ. 
This is not surprising, because aqua applications cannot see 
environment variables defined in .cshrc.

I then removed the definition from ~/.cshrc, added it to 
~/.MacOSX/environment.plist (which is where environment variables 
should be defined if you want aqua applications to see them -- a 
handy trick for using BBEdit with Python) and logged out and back in 
again....

(problem 2) This time the variable showed up just fine in os.environ, 
both in pythonw and python. However, in NEITHER case did the startup 
file it pointed to actually get run! I suspect this is a bug.

Finally, just for completeness, I manually defined PYTHONSTARTUP 
using "setenv" and again the startup file worked in python but not 
pythonw.

>>2) Is it possible to make a Python/Tkinter source file that can be 
>>run as a command (i.e. that has a working #! line...
>
>#!/Applications/Python.app/Contents/MacOS/python
>Not pretty, but it works.

Unfortunately, it works exactly like #!/usr/local/lib/python: the 
Python code runs (which is a big step forward from 
#!/usr/local/bin/pythonw), but one cannot bring Tk windows to the 
front!

>(or)...Under 10.2 you could create a minimal C program that does an 
>execve() of /Applications/Python.app/Contents/MacOS/python, I think 
>that will work okay.

I also tried this. It did work, but unfortunately it worked exactly 
the same as python itself: one cannot bring Tk windows to the front.

Thank you for all your help. I'll try to fix the debug print 
statements as you suggested and I filed a bug report on it as you 
requested.

Regards,

-- Russell