[Pythonmac-SIG] Module build fails because distutils adds "-isysroot"

2009-09-30 Thread Patrick Näf
Hi folks

I'm currently writing a very simple Python module in C that provides an
interface to libaprutil's MD5 routines. I compile my module using
distutils, as per instructions in the "Building C and C++ Extensions with
distutils" chapter of the official Python docs.

Since Mac OS X has libaprutil pre-installed, it seems natural that I try
to use the system version of the library. My Python module's .c file
therefore contains the following #include directive:

  #include 

Everything works fine (module compiles and I can use it) as long as I use
the system version of Python (2.5.1) to compile the module. The problem is
that I *really* need to build the module with Python 2.6 or newer, and
this is where my trouble starts. I have Python 3.1.1 installed in
/Library/Frameworks/Python, and with this version of Python my module's
build fails miserably, like this:

tharbad:~ patrick$
/Library/Frameworks/Python.framework/Versions/3.1/bin/python3.1 ./setup.py
build_ext --inplace
running build_ext
building 'aprmd5' extension
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3
-I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -c
aprmd5.c -o build/temp.macosx-10.3-fat-3.1/aprmd5.o
aprmd5.c:43:60: aprmd5.c:43:60: error: apr-1/apr_md5.h: No such file or
directory
[...]

The problem here is that the gcc option "-isysroot" moves the root for
system includes to the SDK directory (/Developer/SDKs/MacOSX10.4u.sdk),
away from the normal root (/). Unfortunately, the SDK does not contain the
header , which causes the build to fail. Where does
"-isysroot" come from? Not from my module, it's added automatically by
distutils.

I believe I have correctly diagnosed the problem, and I can certainly work
around it *somehow* in my module, but since I am rather new to Python I
have trouble deciding on a solution that is appropriate. I am therefore
writing to this list, hoping someone reading this can give me some advice.

1) Is my problem a known situation for which there is a generally
accepted, best-practice solution? If so, a pointer in the right direction
would be most welcome. If not, what would seem to be a good solution? Make
my own build of libaprutil using the MacOSX10.4u SDK? Rely on a
third-party build of libaprutil (e.g. fink)? Force the compiler to use the
system's libaprutil?

2) Is this a bug in the MacOSX10.4u SDK, i.e. should the SDK contain the
headers for libaprutil? This seems possible to me, because the SDK
certainly contains headers for other libraries (e.g. openssl), so why not
for libaprutil?

3) Is this a bug in the Python distribution, i.e. should the Python 3.1.1
distutils *not* add "-isysroot"? I think this is not the case, distutils
should add the option because Python probably was built with the SDK.

4) Is my work obsolete because someone already has written a Python module
that interfaces libaprutil and has solved all of my problems? If this is
so, again, pointers would be very welcome.


Thanks for your time
Patrick


System setup:
- Mac OS X 10.5.8 (includes libaprutil 1.2.7)
- gcc --version: powerpc-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc.
build 5493)
- Yes, I *do* have the MacOSX10.4u SDK installed :-)
- Python 3.1.1, downloaded from
http://www.python.org/ftp/python/3.1.1/python-3.1.1.dmg (I have also tried
Python 2.6.2 and 3.0.1, with the same result)


___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Lanchd + virtualenv

2009-09-30 Thread Gabriel Rossetti

Ronald Oussoren wrote:


On 25 Sep, 2009, at 14:56, Gabriel Rossetti wrote:


Hello everyone,

I would like to create a Launchd plist entry to start a virtualenv 
and run a python project. I created my plist, but I'm not sure how to 
get it to activate the virtualenv and run the program.


Unless you do something special you don't have to activate the 
virtualenv at all, just make sure that the '#!' line in the script 
you're starting refers to the python in the virtualenv (instead of 
having '#!/usr/bin/env python').


I have a virtualenv containing a mercurial installation and regularly 
use the mercurial command-line tools without activating the virtualenv.


Ronald

Ok, thanks, so from what I understand I only need to activate it if I 
have to install a package into it.


Gabriel
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Module build fails because distutils adds "-isysroot"

2009-09-30 Thread Dave Peterson

Hi Patrick,

Patrick Näf wrote:

... my module's
build fails miserably, like this:

tharbad:~ patrick$
/Library/Frameworks/Python.framework/Versions/3.1/bin/python3.1 ./setup.py
build_ext --inplace
running build_ext
building 'aprmd5' extension
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
-fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3
-I/Library/Frameworks/Python.framework/Versions/3.1/include/python3.1 -c
aprmd5.c -o build/temp.macosx-10.3-fat-3.1/aprmd5.o
aprmd5.c:43:60: aprmd5.c:43:60: error: apr-1/apr_md5.h: No such file or
directory
[...]

The problem here is that the gcc option "-isysroot" moves the root for
system includes to the SDK directory (/Developer/SDKs/MacOSX10.4u.sdk),
away from the normal root (/). Unfortunately, the SDK does not contain the
header , which causes the build to fail. Where does
"-isysroot" come from? Not from my module, it's added automatically by
distutils.
  


The options distutils uses come from the file at root>/lib/python2.5/config/Makefile.  I don't think there is any 
distutils API provided to override/change these, just ways to append to 
them when specifying your extension configuration.  These options are 
used because they are the same ones used when building that Python 
distribution.


So my first suggestion is that you try redefining the -isysroot option 
in the flags you can specify in your extension's config.  There is a 
good chance the compiler will use the last specification on the line 
rather than doing something else when it gets two values.


If that doesn't work, the only other thing I can think of is to 
temporarily edit the config/Makefile to remove / change the inclusion of 
the -isysroot option.


HTHs,

-- Dave

___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] Problems getting started with py2app and wxPython

2009-09-30 Thread Jeff Garbers
Hello! I'm just getting started trying to build a standalone Mac  
application based on wxPython.  I'm on OS X 10.6.1, using Python 2.6.1  
as distributed with the OS.


The app is a simple "hello world" type of thing:


import wx

class MyApp(wx.App):
def OnInit(self):
frame = wx.Frame(None, -1, "Hello from wxPython")
frame.Show(True)
self.SetTopWindow(frame)
return True

app = MyApp(0)
app.MainLoop()




I generate my setup.py with py2applet and build the app:


py2applet --make-setup wxtest.py
python setup.py py2app


All appears to go well, but when I run the resulting app, I get an  
error immediately:



wxtest Error
An unexpected error has occurred during execution of the main script

ImportError: '/usr/lib/python2.6/lib-dynload/wx/_core_.so' not found


Reviewing the output from py2app, I notice that that module -- among  
others -- was stripped:



...
stripping libwx_macud-2.8.0.dylib
stripping _controls_.so
stripping wxtest
stripping _core_.so
stripping _misc_.so
stripping _gdi_.so
stripping _windows_.so



I've been spoiled by things "just working" in both OS X and Python, so  
this sort of thing throws me for a
loop, especially as a rookie.   Why is pyapp stripping those modules,  
and how can I keep it from doing so?
Can anybody suggest a fix or point me in the right direction? Thanks  
in advance for any help you can offer.









 
___

Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Problems getting started with py2app and wxPython

2009-09-30 Thread Christopher Barker

Jeff Garbers wrote:
Hello! I'm just getting started trying to build a standalone Mac 
application based on wxPython.  I'm on OS X 10.6.1, using Python 2.6.1 
as distributed with the OS.


note that py2ap will not bundle up python itself in this case, and your 
app will only work on 10.6 systems.



ImportError: '/usr/lib/python2.6/lib-dynload/wx/_core_.so' not found


hmmm -- this means it's looking in your system, rather than the bundle, 
for the wx libs...


Reviewing the output from py2app, I notice that that module -- among 
others -- was stripped:



...
stripping libwx_macud-2.8.0.dylib
stripping _controls_.so
stripping wxtest
stripping _core_.so
stripping _misc_.so
stripping _gdi_.so
stripping _windows_.so


 Why is pyapp stripping those modules, 


stripping does not mean removing -- I thin it means removing debug 
symbols, etc, i.e. making it smaller. It should not cause this problem.


Aside from putting dylibs into the bundle, py2app also re-writes the 
headers, so that they are linked against the copies in the bundle, 
rather than the system ones -- it looks like this has gone awry.


Do take a look in the bundle ans see what's there. It's very helpful for 
debugging.



I'm not running 10.6, or python2.6, so I'm not much help here, but do 
make sure that you are running the latest py2app -- there have been 2.6 
fixes recently.


You also might try installing a Python.org build, and using that instead 
of Apple's -- you'll need to do that if you want to support older 
systems anyway.


-Chris




--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R(206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

chris.bar...@noaa.gov
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] Lanchd + virtualenv

2009-09-30 Thread Ronald Oussoren


On 30 Sep, 2009, at 17:31, Gabriel Rossetti wrote:


Ronald Oussoren wrote:


On 25 Sep, 2009, at 14:56, Gabriel Rossetti wrote:


Hello everyone,

I would like to create a Launchd plist entry to start a virtualenv  
and run a python project. I created my plist, but I'm not sure how  
to get it to activate the virtualenv and run the program.


Unless you do something special you don't have to activate the  
virtualenv at all, just make sure that the '#!' line in the script  
you're starting refers to the python in the virtualenv (instead of  
having '#!/usr/bin/env python').


I have a virtualenv containing a mercurial installation and  
regularly use the mercurial command-line tools without activating  
the virtualenv.


Ronald

Ok, thanks, so from what I understand I only need to activate it if  
I have to install a package into it.


You only have to activate when you need to have executables from the  
virtualenv on your shell's search-path (that is $PATH). Activating is  
handy when you are installing software, but is also needed when a  
script in the virtualenv executes another script in the environment  
and assumes that that other script is on the search-path.


Ronald


Gabriel




smime.p7s
Description: S/MIME cryptographic signature
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


[Pythonmac-SIG] web services

2009-09-30 Thread sudhakar s
HI,   Can any one suggest me how to create a simple web service.
   Started working with webservices but fully confused with searches i made.

   any one have simple web service script which is currently working?
-- 
With Regards,
S Sudhakar.
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig


Re: [Pythonmac-SIG] web services

2009-09-30 Thread Chris Rebert
On Wed, Sep 30, 2009 at 11:41 PM, sudhakar s  wrote:
>
> HI,
>    Can any one suggest me how to create a simple web service.
>    Started working with webservices but fully confused with searches i made.
>
>    any one have simple web service script which is currently working?

How is this relevant to Python on the Mac OS X platform specifically?

Cheers,
Chris
--
http://blog.rebertia.com
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig