Help with Py2app

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Help with Py2app

Charlie Clark-6
Hi,

I'm trying to update the setup script for the LinkChecker project  
http://linkchecker.sourceforge.net/ because it no longer builds the app  
and does not work reliably in a virtualenv. I am hoping to build a  
standalone app and package it as a DMG as the project author no longer has  
access to Apple hardware.

The existing procedure is a bit convoluted in that it is actually driven  
by a makefile although `bin/python setup.py py2app` should in theory be  
sufficient. The existing setup.py is monolithic and fairly complicated so  
I tried to break out the py2app part into a separate script. When I did  
this and followed the py2app documentation it became clear that the script  
needs to be updated to use setuptools, at least for the extensions. My  
knowledge of writing setup scripts is extremely limited.

LinkChecker is a QT project and needs Python-SIP. Unfortunately I haven't  
worked out how the recipe works. Does the py2app automatically detect the  
dependency and build and package the shared libraries automatically?

Thanks for any help.

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
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|

Re: Help with Py2app

Chris Barker
On Mon, Apr 30, 2012 at 4:26 AM, Charlie Clark

> I'm trying to update the setup script for the LinkChecker project
> http://linkchecker.sourceforge.net/ because it no longer builds the app and
> does not work reliably in a virtualenv.

darn...

> I am hoping to build a standalone
> app and package it as a DMG as the project author no longer
> has access to Apple hardware.

thanks for contributing in this way!

> although `bin/python setup.py py2app` should in theory be
> sufficient.

it should, yes, though at times I've had to add explicte
most-processing code -- I usually do it in pyton in teh setup.py, but
in some ways makefile might be easier if you're more familiar with
shell scripting. I also use a shell script to build the dmg.


> tried to break out the py2app part into a separate script.

> and followed the py2app documentation it became clear that the script needs
> to be updated to use setuptools, at least for the extensions.

I don't know that py2app reslies on setuptools for anything.

> LinkChecker is a QT project and needs Python-SIP. Unfortunately I haven't
> worked out how the recipe works. Does the py2app automatically detect the
> dependency and build and package the shared libraries automatically?

it shoujld, yes -- the idea of recipies is that they "jsut work" for
the end user. If it's not, then it's a bug -- hopefully someone here
can help you find and fix it.

please post:

your setup.py

the errors you get when running the .app

Also, what I usually do is look inside the generated bundle and see
what's there -- if you find what's missing, you can often figure out
how to fix it.

you can unzip the site-packages zip file, to see what's in there.

HTH,
 -Chris


> Thanks for any help.
>
> 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
> _______________________________________________
> Pythonmac-SIG maillist  -  [hidden email]
> 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/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|

Re: Help with Py2app

Charlie Clark-6
Am 30.04.2012, 18:59 Uhr, schrieb Chris Barker <[hidden email]>:

> darn...

Yeah, well I least I bumped the MacPorts port and that works like a charm.  
It'll even give you DMG if you ask nicely. Unfortunately the DMG contains  
symlinks to the libraries and binaries so it isn't redistributable.

>> I am hoping to build a standalone
>> app and package it as a DMG as the project author no longer
>> has access to Apple hardware.
> thanks for contributing in this way!
>
>> although `bin/python setup.py py2app` should in theory be
>> sufficient.

> it should, yes, though at times I've had to add explicte
> most-processing code -- I usually do it in pyton in teh setup.py, but
> in some ways makefile might be easier if you're more familiar with
> shell scripting. I also use a shell script to build the dmg.

I'm happier with Python.

>> tried to break out the py2app part into a separate script.
>
>> and followed the py2app documentation it became clear that the script  
>> needs
>> to be updated to use setuptools, at least for the extensions.
> I don't know that py2app reslies on setuptools for anything.

Maybe it doesn't but I got an error when I moved the relevant part of  
setup.py over to a new file generated by py2applet. It was complaining  
about the Extensions not being Extension instances. Turned out  
distutils.core.Extension instances are not welcome in setuptools.

>> LinkChecker is a QT project and needs Python-SIP. Unfortunately I  
>> haven't
>> worked out how the recipe works. Does the py2app automatically detect  
>> the

>> dependency and build and package the shared libraries automatically?
> it shoujld, yes -- the idea of recipies is that they "jsut work" for
> the end user. If it's not, then it's a bug -- hopefully someone here
> can help you find and fix it.
> please post:
> your setup.py

The original is here:

http://linkchecker.git.sourceforge.net/git/gitweb.cgi?p=linkchecker/linkchecker;a=blob_plain;f=setup.py;hb=HEAD

And my feeble attempt:

http://pastebin.com/ASzHipCe

> the errors you get when running the .app

Bastian's done some fixing, although I've had to give my virtualenv access  
to my system site-packages because of Sip. We really need a pip compatible  
version of that.

When running the setup.py we're now down to:

Traceback (most recent call last):
   File "setup.py", line 833, in <module>
     setup(**args)
   File  
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py",  
line 152, in setup
     dist.run_commands()
   File "setup.py", line 360, in run_commands
     super(MyDistribution, self).run_commands()
   File  
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py",  
line 953, in run_commands
     self.run_command(cmd)
   File  
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py",  
line 972, in run_command
     cmd_obj.run()
   File "setup.py", line 702, in run
     py2app_build.run(self)
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/py2app/build_app.py",  
line 480, in run
     self._run()
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/py2app/build_app.py",  
line 637, in _run
     self.run_normal()
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/py2app/build_app.py",  
line 723, in run_normal
     py_files, extensions = self.finalize_modulefinder(mf)
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/py2app/build_app.py",  
line 690, in finalize_modulefinder
     py_files, extensions = parse_mf_results(mf)
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/modulegraph/find_modules.py",  
line 93, in parse_mf_results
     raise TypeError("Don't know how to handle '%s'" % repr(src))
TypeError: Don't know how to handle  
''/Users/charlieclark/Sites/LinkChecker/linkchecker-gui''

I think I've borked my virtualenv because I'm not getting that far when I  
run my modified setup

fuchsia:LinkChecker charlieclark$ bin/python app.py py2app
Traceback (most recent call last):
   File "app.py", line 69, in <module>
     include_dirs = include_dirs
   File  
"/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py",  
line 112, in setup
     _setup_distribution = dist = klass(attrs)
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/dist.py",  
line 260, in __init__
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/dist.py",  
line 284, in fetch_build_eggs
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py",  
line 563, in resolve
     to_activate = []
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py",  
line 799, in best_match
     dists = self._distmap.setdefault(dist.key,[])
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py",  
line 811, in obtain
     ``VersionConflict`` if an unsuitable version of the project is already
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/dist.py",  
line 327, in fetch_build_egg
   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",  
line 446, in easy_install

   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",  
line 476, in install_item

   File  
"/Users/charlieclark/Sites/LinkChecker/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py",  
line 642, in install_eggs

distutils.errors.DistutilsError: Couldn't find a setup script in  
/var/folders/q0/r5j5dzp55p734_sdh1cblxn80000gn/T/easy_install-00i3bl/sip-4.13.3-snapshot-31ad477ff5ae.zip


> Also, what I usually do is look inside the generated bundle and see
> what's there -- if you find what's missing, you can often figure out
> how to fix it.

Not getting that far.

I hope this makes more sense to you than it does to me!

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
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|

Re: Help with Py2app

Chris Barker
On Mon, Apr 30, 2012 at 10:20 AM, Charlie Clark

>>> tried to break out the py2app part into a separate script.

I'd go farther with this...

>> I don't know that py2app reslies on setuptools for anything.
>
> Maybe it doesn't but I got an error when I moved the relevant part of
> setup.py over to a new file generated by py2applet. It was complaining about
> the Extensions not being Extension instances.

right...

>>> dependency and build and package the shared libraries automatically?

note here -- it should include them, but having it both build and
package in one step may not work...

>> please post:
>> your setup.py

> And my feeble attempt:
>
> http://pastebin.com/ASzHipCe

OK -- to keep this all cleaner, I'd completely separate building and
py2app-ing. So the steps would be:

python setup.py install (or install, or develop)

make sure it's all running in that environment. Then:

python setup.py py2app

having py2app use the distutils API was a nifty idea, but I'm not sure
it's bought us anythign bu confusion in practice. The the setup.py
would either be completely separate, or you can have a clause in
there:

if "py2app" in sys.argv: (or somethign like that)
    # do the py2app stuff here


they key is not to try to use the same call to distutils.setup to
build, install, and py2app.

I usually end up with essentially completely different setup.py for
installing, py2exe and py2app, though they may be in the same file or
not.

HTH,
   -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

[hidden email]
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|

Re: Help with Py2app

Charlie Clark-6
Am 30.04.2012, 20:08 Uhr, schrieb Chris Barker <[hidden email]>:

> I'd go farther with this...
>
>>> I don't know that py2app reslies on setuptools for anything.
>>
>> Maybe it doesn't but I got an error when I moved the relevant part of
>> setup.py over to a new file generated by py2applet. It was complaining  
>> about
>> the Extensions not being Extension instances.
> right...
>
>>>> dependency and build and package the shared libraries automatically?
> note here -- it should include them, but having it both build and
> package in one step may not work...

Happy with multiple steps.

>>> please post:
>>> your setup.py
>
>> And my feeble attempt:
>>
>> http://pastebin.com/ASzHipCe

> OK -- to keep this all cleaner, I'd completely separate building and
> py2app-ing. So the steps would be:

> python setup.py install (or install, or develop)

This runs fine, as long as SIP is installed. How do I add "requires" to  
the setup?

> make sure it's all running in that environment. Then:
> python setup.py py2app
> having py2app use the distutils API was a nifty idea, but I'm not sure
> it's bought us anythign bu confusion in practice. The the setup.py
> would either be completely separate, or you can have a clause in
> there:
> if "py2app" in sys.argv: (or somethign like that)
>     # do the py2app stuff here
> they key is not to try to use the same call to distutils.setup to
> build, install, and py2app.

> I usually end up with essentially completely different setup.py for
> installing, py2exe and py2app, though they may be in the same file or

No problem with that. What dance should I be doing to get py2applet to  
generate the right script once everything has been built. Am I right in  
thinking that I need to write my own script to generate a pkg or dmg? Easy  
enough to adapt the existing code from setup I guess if only I knew where  
to plug it in.

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
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG
Reply | Threaded
Open this post in threaded view
|

Re: Help with Py2app

Chris Barker
(dont' forget to include pythonmac-sig -- it's not doen with a standard reply.)

On Mon, Apr 30, 2012 at 2:07 PM, Charlie Clark
<[hidden email]> wrote:

>> That's a setuptools (or distribute) feature, and should be in the
>> primary setup.py that the main developer uses on other platforms.
>
> Well, where should it go in the existing setup.py? I just tried it in the
> args but no joy.

it goes in "requires" somwhere -- check the setuptools docs.

>>>> python setup.py py2app
>> yup -- a dmg is easy, a one liner, something like:
>> /usr/bin/hdiutil create -srcfolder dist -volname "Name_of_the_volume"
>> -ov "The_name_of_the_file"
>> there is bdist.mpkg, but I think that's only for python packages, not
>> app bundles.
>
>
> Can I add that to my build script?

you can use an os.system callina python script, but I usually jsut run
it separately.



> I'm now getting the same error as when running the original setup.py
>
>    raise TypeError("Don't know how to handle '%s'" % repr(src))
> TypeError: Don't know how to handle
> ''/Users/charlieclark/Sites/LinkChecker/linkchecker-gui''

what is link-checker-gui ?

from that error, it looks like neither a module (clearly not - it's
not called *.py) or a package (would be a directory).

Also, it's in your home dir -- so why is it getting found by modulegraph?


> At least I've got it pointing at the right script. So it can't resolve the
> dependencies?

that looks like something else than not finding a dependency.

-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

[hidden email]
_______________________________________________
Pythonmac-SIG maillist  -  [hidden email]
http://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG