Re: [Pythonmac-SIG] py2app + pyqt: Differences between command-line and double-click

2013-05-15 Thread Michael McCracken
Hi, I answered on stack overflow too - but the short version is call show()
*then also call*  raise_() on your main window.

The answer to an earlier version of this question has a couple of links for
more background:
http://stackoverflow.com/questions/3662559/why-does-my-pyqt-application-open-in-the-background-on-mac-os-x


On Wed, May 15, 2013 at 1:32 PM, Berg, Stuart be...@janelia.hhmi.orgwrote:

 Hi,

 I'm using py2app to packages my (cross-platform) PyQt app into a Mac OS X
 application bundle.  (py2app is great, btw!)

 I was wondering if anyone could point me to some documentation that
 explains in detail how a python app bundle's launch process differs from
 launching the python app directly from the command-line.  My app bundle
 seems to function exactly the same in most respects, but my main window
 doesn't activate unless I manually activate the application via command-tab.

 I give a few more details in this question on stack overflow:

 http://stackoverflow.com/questions/16574315/qt-mainwindow-does-not-appear-until-application-is-activated-manually

 Any ideas, suggestions, or links would be appreciated.

 Thanks,
 Stuart

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

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


Re: [Pythonmac-SIG] py2app + pyqt: Differences between command-line and double-click

2013-05-15 Thread Michael McCracken
There aren't any other window-focus related gotchas that I know of in the
bootstrap code, and I've looked at most of it - can you share more about
your program, and perhaps show what your setup.py looks like?



On Wed, May 15, 2013 at 2:31 PM, Berg, Stuart be...@janelia.hhmi.orgwrote:

  Hi Michael,

  Thanks for your response.  I am already calling show() and then raise()
 (though my SO question didn't make that clear -- sorry about that).  I
 think I'm having a different issue than the one in the link you provided,
 because my app behaves correctly when launched from the command line.  It
 only misbehaves when launched from the app-bundle (i.e. when launched with
 double-click).

  For that reason, I suspect that perhaps there may be a subtle difference
 in the way the app bundle launches the main thread.  (Grasping in the dark
 here...)  Any py2app experts out there care to comment?

  -Stuart

  On May 15, 2013, at 4:50 PM, Michael McCracken wrote:

  Hi, I answered on stack overflow too - but the short version is call
 show() *then also call*  raise_() on your main window.

  The answer to an earlier version of this question has a couple of links
 for more background:
 http://stackoverflow.com/questions/3662559/why-does-my-pyqt-application-open-in-the-background-on-mac-os-x


 On Wed, May 15, 2013 at 1:32 PM, Berg, Stuart be...@janelia.hhmi.orgwrote:

 Hi,

 I'm using py2app to packages my (cross-platform) PyQt app into a Mac OS X
 application bundle.  (py2app is great, btw!)

 I was wondering if anyone could point me to some documentation that
 explains in detail how a python app bundle's launch process differs from
 launching the python app directly from the command-line.  My app bundle
 seems to function exactly the same in most respects, but my main window
 doesn't activate unless I manually activate the application via command-tab.

 I give a few more details in this question on stack overflow:

 http://stackoverflow.com/questions/16574315/qt-mainwindow-does-not-appear-until-application-is-activated-manually

 Any ideas, suggestions, or links would be appreciated.

 Thanks,
 Stuart

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




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


[Pythonmac-SIG] packaged .app creating site.pyo and others, breaking code signature

2012-09-19 Thread Michael McCracken
I've been getting occasional issues where my code signature is invalid
because python has written .pyo files inside the app bundle.

Specifically it's writing

UbuntuOne.app/Contents/Resources/site.pyo

and a bunch of files in the one package that isn't included in my
.zip, for example:

UbuntuOne.app/Contents/Resources/lib/python2.7/configglue/schema.pyo

This is confusing, because I'm not setting 'optimize' in the py2app options.

I looked into the py2app bundle template, and I see in main.c where it
sets PYTHONOPTIMIZE based on the info.plist PyOptions dict. My
Info.plist has optimize = 0, and if I print os.environ in my main
script, I see 'PYTHONOPTIMIZE': '0'.

OK, so then I print sys.flags immediately afterwards, just as a sanity
check, and I get this:
sys.flags(debug=0, py3k_warning=0, division_warning=0, division_new=0,
inspect=0, interactive=0, optimize=1, dont_write_bytecode=0,
no_user_site=0, no_site=0, ignore_environment=0, tabcheck=0,
verbose=0, unicode=0, bytes_warning=0, hash_randomization=0)

Note the optimize=1. That looks like the culprit, but I'm kind of
stumped as to where that's getting set. Any ideas?

On a related note, I tried to set sys.dont_write_bytecode = True at
the top of my main script, and it still writes the .pyo files.

I imagine I could run the app once before signing it, but that's not
ideal for automated builds.

Thanks for any help,
-mike
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] py2app unable to find cprocessors.so

2012-09-13 Thread Michael McCracken
FWIW, here's how I do something similar now, to avoid having many
copies of the Qt libraries.
There is one master app, and several sub-apps.

* call setup() for each of the apps, generating full separate apps
with copies of the Qt libraries and other stuff
-- each call has a unique directory sent in the setup options
bdist_base and dist_dir. This avoids sharing build state, as
mentioned earlier in the thread. This seems to work fine, calling
setup() multiple times in the same script.

* inside main app Contents/Resources, create empty sub.app/ directory
* for each sub app:
** copy sub.app/Contents/MacOS into
main.app/Contents/Resources/sub.app/Contents/MacOS
** copy sub.app/Contents/Info.plist into
main.app/Contents/Resources/sub.app/Contents/Info.plist
** copy everything in sub.app/Contents/Resources/ that isn't include
or lib into main.app/Contents/Resources/sub.app/Contents/Resources/
** create symlinks for sub.app/Contents/Resources/include -
main.app/Contents/Resources/include (do the same with Resources/lib)
3. merge the contents of
sub.app/Contents/Resources/lib/python*/site-packages.zip into the main
app's copy using zipfile
4. merge the contents of the
sub.app/Contents/Resources/lib/python*/lib-dynload directory into the
main app's directory

NOTE: this will ignore any packages in
sub.app/Contents/Resources/lib/python*/ that aren't in the
site-packages.zip.
That's fine for me, since I have the same packages option for all of the apps.

-mike


On Thu, Sep 13, 2012 at 1:53 AM, Ronald Oussoren ronaldousso...@mac.com wrote:

 On 13 Sep, 2012, at 10:47, Paul Wiseman poal...@gmail.com wrote:

 On 13 September 2012 07:18, Ronald Oussoren ronaldousso...@mac.com wrote:


 On 10 Sep, 2012, at 16:37, Paul Wiseman poal...@gmail.com wrote:

 Ah,

 I've found out how to recreate the error

 If I create a main.py with nothing but 'import sqlalchemy'

 then use the following setup.py:

 from setuptools import setup

 setup(
 version=1,
 name=TestApp1,
 app=[main.py],
 setup_requires=[py2app]
 )

 setup(
 version=1,
 name=TestApp2,
 app=[main.py],
 setup_requires=[py2app]
 )

 If it doesn't produce the error it's probably because of this: The
 cprocessors module in SQLAlchemy is written in C and compiles
 conditionally, based on if the current platform supports compiling it.   If
 not present, SQLAlchemy continues to work perfectly well as the hooks which
 attempt to import it will fall back to pure-Python functions instead. So
 you may have a cprocessors.py which I dont think you'd get the problem, only
 if it compiled the .so when sqlalchemy installed.


 I had the cprocessors extension in my build (that is, py2app mentioned in
 copied the extension)


 I get the error, but only when it builds the second app. In my main build
 script I make a few apps in the same script (I make 3 apps which get moved
 into the main app, any additional code in their site-packages.zip is moved
 into the main apps zip, I remove the sub-apps Contents/Resources/lib
 folder and symlink it at run time to the main apps lib folder.)

 Is this a bug or are you never supposed to run multiple setups in the same
 build? If not how can I achieve the above?


 Calling distutils.setup multiple times is at best untested with py2app,
 and I wouldn't be surprised if it causes problems due to state leaking from
 one build into the next.  A workaround would be to use the subprocess module
 to run the setup jobs in separate processes.


 Isn't the problem that they share dist folders, not a process? if not where
 does the state exist? Would I need to subprocess them from different
 directories?


 The py2app command itself has state and I haven't reviewed the code to know
 for sure that all state is cleaned up when the command is used twice in the
 same process. BTW. I also don't know if distutils.setup creates a new py2app
 command object every time it is called, if the second call to
 distutils.setup creates a new py2app command object there is no information
 leakage.



 BTW. I don't quite understand what you are trying to do with these 3 apps.
 Are you building 3 apps that share a lot of code/resources and where you
 want two of the apps to link to the 3th one to reduce the amount of
 disk-space used?


 Yea exactly, I have some smaller apps which are used for specific separate
 jobs (one has a simple gui and generates and gathers log files from the main
 app and zips them up should the main app ever fail to open for instance),
 the jobs are all to do with the main app and all use a sub set of code to
 the main app, so I put the apps in the Resources folder and symlink the lib
 folder so I can include them with only using a little extra disk space, but
 more importantly keeping the installer size down.


 That sounds like something that would be useful to support directly. I'll
 add it to the list of nice-to-have featuers, but don't know when I'll get
 around to looking into this.

 Ronald



 Ronald


 On 10 

Re: [Pythonmac-SIG] py2app unable to find cprocessors.so

2012-09-13 Thread Michael McCracken
Paul, it's like this:
setup(blah, options={py2app: = {bdist_base: build/app1,
dist_dir: dist/app1}})
setup(blah, options={py2app: = {bdist_base: build/app2,
dist_dir: dist/app2}})

For the full version, see my setup.py here: (ignore windows-installer)

http://bazaar.launchpad.net/~ubuntuone-control-tower/ubuntuone-windows-installer/trunk/view/head:/scripts/setup-mac.py

see line 571 for how I call setup, line 562 for where I set the
app-specific options, and line 497 for the dict with the options that
the apps have in common.

-mike

On Thu, Sep 13, 2012 at 11:32 AM, Paul Wiseman poal...@gmail.com wrote:
 On 13 September 2012 14:36, Ronald Oussoren ronaldousso...@mac.com wrote:


 On 13 Sep, 2012, at 15:17, Paul Wiseman poal...@gmail.com wrote:

 On 13 September 2012 13:26, Ronald Oussoren ronaldousso...@mac.com
 wrote:


 On 13 Sep, 2012, at 14:17, Paul Wiseman poal...@gmail.com wrote:

 On 13 September 2012 12:13, Ronald Oussoren ronaldousso...@mac.com
 wrote:



 I checked out the latest trunk
 (http://svn.pythonmac.org/py2app/py2app/trunk/), installed that and the
 problem has gone :)

 Not sure which version I had before, but I only built this mac a week
 ago or so, so think it's maybe the current version available for download


 Hm maybe I spoke too soon, it builds ok now but when I run the app I get
 a error dialog with Open console and Terminate options, and this stack 
 trace
 in the console

 Traceback (most recent call last):
   File /Applications/ZipCloud.app/Contents/Resources/__boot__.py, line
 103, in module
 _argv_emulation()
   File /Applications/ZipCloud.app/Contents/Resources/__boot__.py, line
 101, in _argv_emulation
 _get_argvemulator().mainloop()
   File /Applications/ZipCloud.app/Contents/Resources/__boot__.py, line
 40, in mainloop
 stoptime = Evt.TickCount() + timeout
 AttributeError: 'module' object has no attribute 'TickCount'

 That's odd, that code is not present in the trunk. Have you removed the
 dist and build directories before testing the latest py2app?

 Ronald


 Yea definitely, I removed them at the start of the build script. I
 removed them myself and ran it again with the same outcome. How can I check
 which version I'm running? I guess installing the current trunk hasn't
 worked exactly


 The easiest way to check the version is run python -c 'import py2app;
 print(py2app.__version__)'.

 Ronald


 I've got 0.5.3 which I'm a bit confused at as I can get 0.6.4 from pypi. I
 just looked in the one I checked out from svn, and in the readme it says
 0.5.3 - whats the address I can checkout the latest version?


 I should have noticed this before, but the py2app sources aren't at
 svn.pythonmac.org anymore. Py2app is currently hosted at
 https://bitbucket.org/ronaldoussoren/py2app, and you'll also have to
 install the sibling projects altgraph, modulegraph and macholib.

 I hope to have some time this weekend to push out new releases of these
 projects,

 Ronald


 I tried with multiprocess but I had no joy, I didn't manage to see the
 stderr but it definitely wasn't building the subapps so I believe it was
 getting the same error.

 I've got a 10.7 macbook I'm putting devtools and sqlalchemy on which I'll
 try tomorrow and see if it will build or not to get more evidence if it's a
 problem with 10.6 or not

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


Re: [Pythonmac-SIG] py2app unable to find cprocessors.so

2012-09-13 Thread Michael McCracken
On Thu, Sep 13, 2012 at 12:16 PM, Chris Barker chris.bar...@noaa.gov wrote:
 On Thu, Sep 13, 2012 at 10:36 AM, Michael McCracken
 michael.mccrac...@gmail.com wrote:
 FWIW, here's how I do something similar now, to avoid having many
 copies of the Qt libraries.

 cool! Thanks for the description

 There is one master app, and several sub-apps.

 * call setup() for each of the apps, generating full separate apps
 with copies of the Qt libraries and other stuff
 -- each call has a unique directory sent in the setup options
 bdist_base and dist_dir. This avoids sharing build state, as
 mentioned earlier in the thread. This seems to work fine, calling
 setup() multiple times in the same script.

 good to know -- I think the OP was right, the conflict over the
 sharing build dirs -- I didn't know you could override that.

 * inside main app Contents/Resources, create empty sub.app/ directory
 * for each sub app:
 ** copy sub.app/Contents/MacOS into
 main.app/Contents/Resources/sub.app/Contents/MacOS
 ** copy sub.app/Contents/Info.plist into
 main.app/Contents/Resources/sub.app/Contents/Info.plist
 ** copy everything in sub.app/Contents/Resources/ that isn't include
 or lib into main.app/Contents/Resources/sub.app/Contents/Resources/
 ** create symlinks for sub.app/Contents/Resources/include -
 main.app/Contents/Resources/include (do the same with Resources/lib)

 OK -- here is where Im confused -- with a sylink, you can do either
 relative or absoute path, yes? absolute wouldn't work, as who knows
 where the user will install it -- but relative could, as long as the
 users keeps them all together -- is that how you handle it?

Yes, they're relative paths - all the sub-apps stay inside the main
.app wrapper.
If someone moves things around inside there, that's unsupported :)

 Alternatively I suppose you could require that main.app be installed
 in /Library/Frameworks or something, and then symlink to the absolute
 path.

 I actually kind of like that idea, 'cause it would keep the apps a bit
 more distinct, -- I have a base I want to use with multiple apps but
 don't necessarily want folks to have to install everything at once to
 use one.

Yes, that'd probably work, but it has the inconvenience of requiring
an installer...
I'm not sure what the best way to go in your situation is.
An installer isn't all that bad, I guess.

-mike

 3. merge the contents of
 sub.app/Contents/Resources/lib/python*/site-packages.zip into the main
 app's copy using zipfile
 4. merge the contents of the
 sub.app/Contents/Resources/lib/python*/lib-dynload directory into the
 main app's directory


 But anyway, this is a nice model for what py2app could so for us.

 Thanks,
   -Chris

 NOTE: this will ignore any packages in
 sub.app/Contents/Resources/lib/python*/ that aren't in the
 site-packages.zip.
 That's fine for me, since I have the same packages option for all of the 
 apps.

 -mike


 On Thu, Sep 13, 2012 at 1:53 AM, Ronald Oussoren ronaldousso...@mac.com 
 wrote:

 On 13 Sep, 2012, at 10:47, Paul Wiseman poal...@gmail.com wrote:

 On 13 September 2012 07:18, Ronald Oussoren ronaldousso...@mac.com wrote:


 On 10 Sep, 2012, at 16:37, Paul Wiseman poal...@gmail.com wrote:

 Ah,

 I've found out how to recreate the error

 If I create a main.py with nothing but 'import sqlalchemy'

 then use the following setup.py:

 from setuptools import setup

 setup(
 version=1,
 name=TestApp1,
 app=[main.py],
 setup_requires=[py2app]
 )

 setup(
 version=1,
 name=TestApp2,
 app=[main.py],
 setup_requires=[py2app]
 )

 If it doesn't produce the error it's probably because of this: The
 cprocessors module in SQLAlchemy is written in C and compiles
 conditionally, based on if the current platform supports compiling it.   If
 not present, SQLAlchemy continues to work perfectly well as the hooks which
 attempt to import it will fall back to pure-Python functions instead. So
 you may have a cprocessors.py which I dont think you'd get the problem, 
 only
 if it compiled the .so when sqlalchemy installed.


 I had the cprocessors extension in my build (that is, py2app mentioned in
 copied the extension)


 I get the error, but only when it builds the second app. In my main build
 script I make a few apps in the same script (I make 3 apps which get moved
 into the main app, any additional code in their site-packages.zip is moved
 into the main apps zip, I remove the sub-apps Contents/Resources/lib
 folder and symlink it at run time to the main apps lib folder.)

 Is this a bug or are you never supposed to run multiple setups in the same
 build? If not how can I achieve the above?


 Calling distutils.setup multiple times is at best untested with py2app,
 and I wouldn't be surprised if it causes problems due to state leaking from
 one build into the next.  A workaround would be to use the subprocess 
 module
 to run the setup jobs in separate processes.


 Isn't the problem that they share dist folders, not a process

Re: [Pythonmac-SIG] py2app unable to find cprocessors.so

2012-09-13 Thread Michael McCracken
On Thu, Sep 13, 2012 at 4:13 PM, Paul Wiseman poal...@gmail.com wrote:
 On 13 September 2012 20:16, Chris Barker chris.bar...@noaa.gov wrote:

 On Thu, Sep 13, 2012 at 10:36 AM, Michael McCracken
 michael.mccrac...@gmail.com wrote:
  FWIW, here's how I do something similar now, to avoid having many
  copies of the Qt libraries.

 cool! Thanks for the description

  There is one master app, and several sub-apps.
 
  * call setup() for each of the apps, generating full separate apps
  with copies of the Qt libraries and other stuff
  -- each call has a unique directory sent in the setup options
  bdist_base and dist_dir. This avoids sharing build state, as
  mentioned earlier in the thread. This seems to work fine, calling
  setup() multiple times in the same script.

 good to know -- I think the OP was right, the conflict over the
 sharing build dirs -- I didn't know you could override that.

  * inside main app Contents/Resources, create empty sub.app/ directory
  * for each sub app:
  ** copy sub.app/Contents/MacOS into
  main.app/Contents/Resources/sub.app/Contents/MacOS
  ** copy sub.app/Contents/Info.plist into
  main.app/Contents/Resources/sub.app/Contents/Info.plist
  ** copy everything in sub.app/Contents/Resources/ that isn't include
  or lib into main.app/Contents/Resources/sub.app/Contents/Resources/
  ** create symlinks for sub.app/Contents/Resources/include -
  main.app/Contents/Resources/include (do the same with Resources/lib)

 OK -- here is where Im confused -- with a sylink, you can do either
 relative or absoute path, yes? absolute wouldn't work, as who knows
 where the user will install it -- but relative could, as long as the
 users keeps them all together -- is that how you handle it?

 Alternatively I suppose you could require that main.app be installed
 in /Library/Frameworks or something, and then symlink to the absolute
 path.

 I actually kind of like that idea, 'cause it would keep the apps a bit
 more distinct, -- I have a base I want to use with multiple apps but
 don't necessarily want folks to have to install everything at once to
 use one.


 You could create the multiple apps at run time when running the main app,
 that's not too far away from what I'm doing at the moment.  I think it's
 mainly just a few xml plist files that cant be symlinked because they wont
 be the same as the main app. A slightly easier solution would be to zip the
 apps up and drop them in place and relatively symlink the needed parts back
 to the main app.

Yep, this could probably be made to work, but would break code
signatures on any apps that you changed in that way - just something
to keep in mind.
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] py2app unable to find cprocessors.so

2012-09-12 Thread Michael McCracken
On Wed, Sep 12, 2012 at 10:54 AM, Paul Wiseman poal...@gmail.com wrote:
 On 12 September 2012 18:13, Michael McCracken michael.mccrac...@gmail.com
 wrote:

 On Wed, Sep 12, 2012 at 4:08 AM, Paul Wiseman poal...@gmail.com wrote:
  On 10 September 2012 13:18, Ronald Oussoren ronaldousso...@mac.com
  wrote:
 
 
  On 9 Sep, 2012, at 20:34, Paul Wiseman poal...@gmail.com wrote:
 
  Hey,
 
  When building an app that is using sqlalchemy I get this error:
 
  creating python loader for extension 'sqlalchemy.cprocessors'
  error:
 
  /Users/paul/Source/Python/build/bdist.macosx-10.6-intel/python2.7-standalone/app/temp/sqlalchemy/cprocessors.py:
  No such file or directory
 
  I took a look in site packages and there is no cprocessors.py, but a
  cprocessors.so - so maybe it is just looking for the wrong extension
 
  I tried adding sqlalchemy.cprocessors to the includes list in py2app
  but
  that hasn't helped.
 
  I was wondering if I can fool it by dropping an empty cprocessors.py so
  it
  will build, then swap it out afterwards for the so, but I'm sure
  there's a
  better way and I'm not convinced that could even work.
 
  Surely py2app doesn't assume every extension is .py, or if it does can
  it
  be changed?
 
 
  Py2app does not assume that every extension is a python file. Given the
  messasge I'd say that the error occurs in the code path that creates a
  helper python file that actually loads the exention.
 
  A little background information: when py2app creates the application
  bundle all modules are stored in a zipfile and loaded using python's
  zipimporter. Extensions cannot be stored in the zipfiles because the
  zipimporter doesn't support that. Py2app therefore creates a
  placeholder
  python module in the zipfile that loads the extensions from a directory
  in
  the application bundle.
 
  BTW. could you please create a sample project that demonstrates the
  problem? I've tried to reproduce your problem on my machine and failed
  to do
  so. I did run into another problem, py2app generated an incomplete
  bundle
  due to confusion between a _collections submodule in SQLAlchemy and the
  _collections extension in the stdlib; that's something I'm currently
  trying
  to fix.
 
  Ronald
 
 
  (Oops just realised I didn't reply to the mailing list before)
 
  Ah,
 
  I've found out how to recreate the error
 
  If I create a main.py with nothing but 'import sqlalchemy'
 
  then use the following setup.py:
 
  from setuptools import setup
 
  setup(
  version=1,
  name=TestApp1,
  app=[main.py],
  setup_requires=[py2app]
  )
 
  setup(
  version=1,
  name=TestApp2,
  app=[main.py],
  setup_requires=[py2app]
  )
 
  If it doesn't produce the error it's probably because of this: The
  cprocessors module in SQLAlchemy is written in C and compiles
  conditionally, based on if the current platform supports compiling it.
  If
  not present, SQLAlchemy continues to work perfectly well as the hooks
  which
  attempt to import it will fall back to pure-Python functions instead.
  So
  you may have a cprocessors.py which I dont think you'd get the problem,
  only
  if it compiled the .so when sqlalchemy installed.
 
  I get the error, but only when it builds the second app. In my main
  build
  script I make a few apps in the same script (I make 3 apps which get
  moved
  into the main app, any additional code in their site-packages.zip is
  moved
  into the main apps zip, I remove the sub-apps Contents/Resources/lib
  folder and symlink it at run time to the main apps lib folder.)
 
  Is this a bug or are you never supposed to run multiple setups in the
  same
  build? If not how can I achieve the above?

 Paul, I'm also doing multiple calls to setup and it works.
 Does the main app import sqlalchemy?
 I ask because just removing SubApp.app/Contents/Resources/lib and
 symlinking that whole thing will remove anything in
 SubApp.app/Contents/Resources/lib/pythonx.y/lib-dynload/ , and if the
 sub app needs something in there that isn't in the lib-dynload path of
 the main app, then you won't have it in the final package.

 In my case I have a step that copies files from sub-app lib-dynload
 folders into the main app's folder before replacing the whole /lib dir
 with a symlink.
 Sounds like you might have to do the same thing.

 Hope this helps,
 -mike


 Ah I think I do need that step you're right. my sub apps are a subset of the
 main app, so I think I've gotten away with not copying anything over. I'll
 definitely add that into my build script though.

 The error isn't related to the fact I symlink the lib folders together,
 though, this is failing while building the second app. I just mentioned it
 to explain why I want to call setup multiple times, I didn't know if it was
 a common practice or not.

 Yea the main.py is just import sqlalchemy in my example, so the first and
 second app will be the same in the example (both import sqlalchemy). Could
 you check if you have

Re: [Pythonmac-SIG] py2app: works for me on 10.6, not 10.7

2012-08-02 Thread Michael McCracken
On Thu, Aug 2, 2012 at 7:40 AM, Ronald Oussoren ronaldousso...@mac.com wrote:

 On 31 Jul, 2012, at 16:47, Michael McCracken michael.mccrac...@gmail.com 
 wrote:

 Hi, my py2app setup script is working fine if I run it on 10.6, but on
 10.7 I've run into some problems.

 I want a standalone app, and on 10.6 I didn't specify semi_standalone:
 False in the options, and it worked fine.
 On 10.7, it appeared to be using the system python (loading old system
 versions of some dependencies), and on a quick look through the py2app
 code it seemed to be deciding it was semi-standalone, so I added
 semi_standalone: False.

 That won't work, py2app won't copy parts files from /System into the 
 application bundle.

Yes, that explains the runtime could not be located error.
For the archives - this was solved by actually making sure, for real,
that I wasn't running py2app with the system python.
I had mistakenly built a zope-buildout python wrapper that called the
system python when I wasn't expecting it to.

Thanks,
-mike

 Ronald

 This solved results in a app wrapper without the Python.framework
 copied in, giving me the Python runtime could not be located error.

 Is there something obvious I'm missing in moving builds to 10.7?

 Thanks,
 -mike
 ___
 Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
 http://mail.python.org/mailman/listinfo/pythonmac-sig
 unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

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


[Pythonmac-SIG] py2app: works for me on 10.6, not 10.7

2012-07-31 Thread Michael McCracken
Hi, my py2app setup script is working fine if I run it on 10.6, but on
10.7 I've run into some problems.

I want a standalone app, and on 10.6 I didn't specify semi_standalone:
False in the options, and it worked fine.
On 10.7, it appeared to be using the system python (loading old system
versions of some dependencies), and on a quick look through the py2app
code it seemed to be deciding it was semi-standalone, so I added
semi_standalone: False.
This solved results in a app wrapper without the Python.framework
copied in, giving me the Python runtime could not be located error.

Is there something obvious I'm missing in moving builds to 10.7?

Thanks,
-mike
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] py2app: works for me on 10.6, not 10.7

2012-07-31 Thread Michael McCracken
Thanks, Chris - you gave me an important clue.

We are using homebrew to install python 2.7.3, so I assumed we were OK
there, but we are also using zope's buildout to download dependencies,
and it creates a python wrapper script with #!/usr/bin/python .

So indeed, I was using the wrong python. Thanks for getting me to look again.

Cheers,
-mike

On Tue, Jul 31, 2012 at 11:56 AM, Chris Barker chris.bar...@noaa.gov wrote:
 On Tue, Jul 31, 2012 at 7:47 AM, Michael McCracken
 michael.mccrac...@gmail.com wrote:
 Hi, my py2app setup script is working fine if I run it on 10.6, but on
 10.7 I've run into some problems.

 I want a standalone app, and on 10.6 I didn't specify semi_standalone:
 False in the options, and it worked fine.
 On 10.7, it appeared to be using the system python (loading old system
 versions of some dependencies),

 I'm not totally sure, but 10.7 probably has a version of python out of
 the box that 10.6 doesn't. But anyway, if you want it standalone, you
 need to make sure that you DONT'T use Apple's Python:

 Did you install the same python.org versions on 10.7 as you did on 10.6?

 Are you sure you're running py2app (i.e. setup.py py2app) with that Python?

 If so, py2app should keep it all clear for you.

 (note: if any extensions need to be compiled, you need to make sure
 you use an older XCode, also, but if your app is running fine with the
 right pyton outside py2app, then you should be set.)

 HTH,
  -Chris


  and on a quick look through the py2app
 code it seemed to be deciding it was semi-standalone, so I added
 semi_standalone: False.
 This solved results in a app wrapper without the Python.framework
 copied in, giving me the Python runtime could not be located error.

 Is there something obvious I'm missing in moving builds to 10.7?

 Thanks,
 -mike
 ___
 Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
 http://mail.python.org/mailman/listinfo/pythonmac-sig
 unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG



 --

 Christopher Barker, Ph.D.
 Oceanographer

 Emergency Response Division
 NOAA/NOS/ORR(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
 unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] py2app: works for me on 10.6, not 10.7

2012-07-31 Thread Michael McCracken
On Tue, Jul 31, 2012 at 2:28 PM, Michael McCracken
michael.mccrac...@gmail.com wrote:
 Thanks, Chris - you gave me an important clue.

 We are using homebrew to install python 2.7.3, so I assumed we were OK
 there, but we are also using zope's buildout to download dependencies,
 and it creates a python wrapper script with #!/usr/bin/python .

That is, *if you're not careful*, it can create a python wrapper
script with the wrong python.
It can also do the right thing.

 So indeed, I was using the wrong python. Thanks for getting me to look again.

 Cheers,
 -mike

 On Tue, Jul 31, 2012 at 11:56 AM, Chris Barker chris.bar...@noaa.gov wrote:
 On Tue, Jul 31, 2012 at 7:47 AM, Michael McCracken
 michael.mccrac...@gmail.com wrote:
 Hi, my py2app setup script is working fine if I run it on 10.6, but on
 10.7 I've run into some problems.

 I want a standalone app, and on 10.6 I didn't specify semi_standalone:
 False in the options, and it worked fine.
 On 10.7, it appeared to be using the system python (loading old system
 versions of some dependencies),

 I'm not totally sure, but 10.7 probably has a version of python out of
 the box that 10.6 doesn't. But anyway, if you want it standalone, you
 need to make sure that you DONT'T use Apple's Python:

 Did you install the same python.org versions on 10.7 as you did on 10.6?

 Are you sure you're running py2app (i.e. setup.py py2app) with that Python?

 If so, py2app should keep it all clear for you.

 (note: if any extensions need to be compiled, you need to make sure
 you use an older XCode, also, but if your app is running fine with the
 right pyton outside py2app, then you should be set.)

 HTH,
  -Chris


  and on a quick look through the py2app
 code it seemed to be deciding it was semi-standalone, so I added
 semi_standalone: False.
 This solved results in a app wrapper without the Python.framework
 copied in, giving me the Python runtime could not be located error.

 Is there something obvious I'm missing in moving builds to 10.7?

 Thanks,
 -mike
 ___
 Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
 http://mail.python.org/mailman/listinfo/pythonmac-sig
 unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG



 --

 Christopher Barker, Ph.D.
 Oceanographer

 Emergency Response Division
 NOAA/NOS/ORR(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
 unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Question about py2app packages and includes options

2012-07-18 Thread Michael McCracken
On Wed, Jul 18, 2012 at 11:14 AM, Chris Barker chris.bar...@noaa.gov wrote:
 On Tue, Jul 17, 2012 at 3:49 PM, Michael McCracken
 michael.mccrac...@gmail.com wrote:

 That makes sense - but as you mention, it seems like there's some
 missing functionality.

 I think so, yes, but it can get the job done.

 However, it's no fun if you have a lot of subpackages to add that way.

 nope -- but for the most part they are picked up by regular imports,
 anyway. You only need to do this if there are some dynamic importing
 in your code -- and in that case, it's likely you'll want the whole
 package anyway.

In my (probably unusual) situation, it's not dynamic imports: I have
these helper apps that I'm including in the main app bundle. I wanted
to have their Frameworks and lib directories just be symlinks to the
top level, which then had to have the sum of all the modules.

The modules the sub-apps use are picked up and put in the zip just
fine when they're built separately, but I need to put those modules in
the toplevel .zip. I was looking for a nice way to do that from the
options, but that's the specific thing that's missing.

That said, the code to just directly merge the zips and lib-dynload
directories was pretty straightforward and seems to be working well.

If anyone else ever has a similar need, I'd be happy to share it.

-mike


 --

 Christopher Barker, Ph.D.
 Oceanographer

 Emergency Response Division
 NOAA/NOS/ORR(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
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


[Pythonmac-SIG] Question about py2app packages and includes options

2012-07-17 Thread Michael McCracken
I am trying to package a main .app with helper apps in
Main.app/Resources/Helper.app, and I want to have a single
Resources/lib directory and a single Frameworks/ directory to cut down
on space.

So I'm tweaking the main app's includes and packages options to get
all the dependencies in one place, and relying on the automatic logic
won't work.

My question is: why does 'packages' copy the package recursively, but
not into the .zip, while 'includes' only gets single modules?
I was expecting packages to put the whole package in the .zip, and I
didn't find any explanation in the docs.

This is a minor point, since it works fine with 'packages' doing what
it does, it'd just be nice to get them into the zip.

Thanks,
-mike
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Question about py2app packages and includes options

2012-07-17 Thread Michael McCracken
On Tue, Jul 17, 2012 at 5:25 PM, Chris Barker chris.bar...@noaa.gov wrote:
 On Tue, Jul 17, 2012 at 11:03 AM, Michael McCracken

 My question is: why does 'packages' copy the package recursively, but
 not into the .zip,

 because there are packages that don't work right if zipped -- so this
 gets around that.

That makes sense - but as you mention, it seems like there's some
missing functionality.

 while 'includes' only gets single modules?

 I suspect it's because there should be a way to include a particular
 module without the whole package. Essentially:

 includes adds a module to list, just as thought there were an
 import module name line in the code -- it is used to cover dynamic
 imports that won't be caught by walking the code.

 packages makes na compete copy of the package, and puts it outside
 the zip bundle -- this is fro including packages that have auxiliary
 files, etc, and/or can't be zipped for other reasons.

 It's a big ugly, but I've managed to put packages into the zip with
 something like this:

 includes = [package,
 package.subpackage
 package.subpackage.module1
 package.subpackage.module2
 ]

 for some reason (is it a bug? -- or has it been fixed?) doing:

 includes = [ package.subpackage.module]

 puts module in the root, so it's there but can't be imported the same way.

I don't have time to test, but I think that's been fixed.
However, it's no fun if you have a lot of subpackages to add that way.

For what it's worth, the approach I'm now taking is to create the full
packages for each helper app, then just directly add the missing files
in site-packages.zip and lib-dynload from the helper into the main
app.
Using ZipFile, it's not too bad.

I looked at the source for how py2app uses modulegraph, to see if I
could just generate the dependencies for the sub apps and pass them as
the 'includes' for the main app, but that seemed involved enough that
I ended up doing the above.

-mike

 HTH,

 - Chris



 --

 Christopher Barker, Ph.D.
 Oceanographer

 Emergency Response Division
 NOAA/NOS/ORR(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
 unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] PyQT on Lion? (Charlie Clark)

2012-07-16 Thread Michael McCracken
Arana, please feel free to ask here about any questions building
distributable apps with PyQt - I'm currently working on this and I
might be able to share some workarounds I've had to use.

Also, I'd suggest you use the current development version of py2app,
which has some related changes.

For example, see an earlier thread about needing to create a qt.conf
file in the app bundle to avoid plugin warnings and potential crashes:
http://mail.python.org/pipermail/pythonmac-sig/2012-May/023569.html

-mike

On Mon, Jul 16, 2012 at 3:51 PM, Arana Fireheart aranafirehe...@mac.com wrote:
 Charlie,

 Thanks for the response. Part of the reason I was trying to use 
 virtualenv was to 'disconnect' from a few years of builds (some successful/ 
 some unsuccessful). I was hoping to avoid doing a 'clean install' of my 
 machine and reinstall of of the apps etc.

 The latest attempt is to perform a 'new' install of PyQT and then 
 copy the site-packages directory into the virtual environment (or possibly 
 sym link it). I think this one shows the most promise for getting an 
 environment that will not only run my PyQT apps but allow me to build a 
 distribution version with py2app (which I have NEVER managed to be able to 
 do!!)

 I'll let you all know how it goes, Iv'e got my finger's crossed!

 Arana



 On Jul 12, 2012, at 6:00 AM, pythonmac-sig-requ...@python.org wrote:

 Am 11.07.2012, 14:41 Uhr, schrieb Arana Fireheart aranafirehe...@mac.com:

 Charlie,
  I tried virtualenv after reading lots of people extolling it's 
 virtues. Having had little luck with other methods I thought I would give 
 it a try. I have managed to get this all built on my MacBookPro which is 
 running Snow Leopard, but not on my desktop machine (iMac). HomeBrew lists 
 PyQT as installed, but when I try to run some code it fails with a can't 
 find module.
  What I don't get is why python can't locate the installed modules. Do 
 you have any hints as to how I can track this down?

 Hi Arana,

 virtualenv's are indeed a great idea. They allow you to isolate the
 libraries for different projects from each other. However, if you are
 using libraries that need compiling then it can be better to use system
 libraries. You can do this in a virtualenv with the switch 
 --system-site-packages

 Charlie
 --
 Charlie Clark
 Managing Director
 Clark Consulting  Research
 German Office
 Kronenstr. 27a
 Düsseldorf
 D- 40217
 Tel: +49-211-600-3657
 Mobile: +49-178-782-6226



 unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG

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


Re: [Pythonmac-SIG] Sqlite database drivers with py2app?

2012-06-28 Thread Michael McCracken
Patrick, I've run into a similar problem - qt needs a qt.conf file to
be created in the Contents/Resources folder of the app bundle, with a
directive telling it where to find plugins. otherwise it looks in the
default system path.

The environment variable QT_DEBUG_PLUGINS=1 can be very useful here.

-mike

On Thu, Jun 28, 2012 at 11:16 AM, Patrick Kenny ptmke...@gmail.com wrote:
 I have a python application that uses a sqlite database. On my machine,
 which has all the dependencies installed, there are no issues. However, when
 I bundle the application with py2app, clicking a menu that causes the
 database to be accessed results in this error:

 Database error: Driver not loaded Driver not loaded

 For the Windows installer, the files in \Qt\version\plugins\sqldrivers\*.*
 can be copied to \myApp\sqldrivers\*

 The same files on the Mac can be found
 in /opt/local/share/qt4/plugins/sqldrivers (installed via Macports).

 However, copying the sqldrivers directory to my application's Resources or
 Frameworks directories still results in the same error.

 How can I add sqlite support into my application that is built using py2app?

 Any help would be much appreciated.


 Regards,
 Patrick

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

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


Re: [Pythonmac-SIG] Sqlite database drivers with py2app?

2012-06-28 Thread Michael McCracken
Hey, I'm glad that was useful!

Another thing that probably won't affect you, but in case it does -
make sure you keep a reference in your python script to the
QtApplication that you create.
ie, do 'app = QApplication(sys.argv)' instead of just 'QApplication(sys.argv)'.

Otherwise the QApplication will get garbage collected and weird things
happen, including forgetting where to look for plugins!

Feel free to ask about PyQt4 here, as I'm working on porting a PyQt
application to OS X now, and may have run into other problems already.

Cheers,
-mike

On Thu, Jun 28, 2012 at 7:37 PM, Patrick Kenny ptmke...@gmail.com wrote:
 Thanks, that solved my problem!

 I really appreciate your help!


 Cheers,
 Patrick

 On 2012年6月29日Friday at 1:57, Michael McCracken wrote:

 Patrick, I've run into a similar problem - qt needs a qt.conf file to
 be created in the Contents/Resources folder of the app bundle, with a
 directive telling it where to find plugins. otherwise it looks in the
 default system path.

 The environment variable QT_DEBUG_PLUGINS=1 can be very useful here.

 -mike

 On Thu, Jun 28, 2012 at 11:16 AM, Patrick Kenny ptmke...@gmail.com wrote:

 I have a python application that uses a sqlite database. On my machine,
 which has all the dependencies installed, there are no issues. However, when
 I bundle the application with py2app, clicking a menu that causes the
 database to be accessed results in this error:

 Database error: Driver not loaded Driver not loaded

 For the Windows installer, the files in \Qt\version\plugins\sqldrivers\*.*
 can be copied to \myApp\sqldrivers\*

 The same files on the Mac can be found
 in /opt/local/share/qt4/plugins/sqldrivers (installed via Macports).

 However, copying the sqldrivers directory to my application's Resources or
 Frameworks directories still results in the same error.

 How can I add sqlite support into my application that is built using py2app?

 Any help would be much appreciated.


 Regards,
 Patrick

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


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


[Pythonmac-SIG] py2app and PyQt: QT plugins cause loading multiple QT library versions

2012-05-31 Thread Michael McCracken
New user, so new thread, in reference to (PyQt and py2app) Gui starts
in IDLE but not as app.

This happens when Qt loads image plugins from the
system location (likely set during Qt's configure), which
then load the system Qt.

The problem and a workaround are described here:
http://lists.trolltech.com/qt-interest/2008-09/thread00258-0.html

py2app's PyQt sample doesn't exercise enough of Qt to hit this problem.
I'm not sure exactly what part of Qt you'd need to trigger it, but
I guess the Color Picker might work.

The quick way, if you know you don't need these plugins, is to
create an empty qt.conf file at MyApp.app/Contents/Resources/qt.conf.

The plugin search path can be set in that qt.conf, or an empty one
just stops it from looking for plugins.
I've verified that an empty file avoids the issue, haven't tested
setting the path.

For py2app, I guess some thought is required for a nice API to handle
this case, since these are C dylibs that won't be detected at bundle time.
Ideally, we could have an option that takes a list of qt plugins we need,
and creates the appropriate qt.conf.

There isn't a quick way to add this in, so I thought I'd ask for comments
on how it should be designed. I will probably need plugin support soon,
and I'd like to be able to contribute the change back.

Thanks,
-mike
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG