Re: [Pythonmac-SIG] Building plans .....

2020-03-12 Thread Ronald Oussoren via Pythonmac-SIG


> On 11 Mar 2020, at 22:34, Jack Jansen  wrote:

[…]
> 
> - I _think_ that the restriction that a GUI program must be in an App bundle 
> no longer holds, or at least there are ways around it. There are all sorts of 
> programs installed with brew that present a GUI without being in an app 
> bundle. I’m looking at realsense-viewer right now, as an example, and it’s a 
> normal executable in 
> /usr/local/Cellar/librealsense/2.22.0/bin/realsense-viewer with a symlink in 
> /usr/local/bin. 

I’m not sure the limitation is really gone, I still see issues with a number of 
Cocoa APIs when run from a virtualenv environment, which doesn’t use the 
Python.app trick, while the same API works with a venv environement (which does 
use the Python.app trick). One example is 
>. 

There is a private API that makes it possible to use GUI libraries outside of 
an app bundle and that’s used by a number of projects, but I wouldn’t want to 
use that in Python.

Ronald
—

Twitter: @ronaldoussoren
Blog: https://blog.ronaldoussoren.net/ 


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


Re: [Pythonmac-SIG] Building plans .....

2020-03-12 Thread Ronald Oussoren via Pythonmac-SIG

> On 12 Mar 2020, at 07:48, Just van Rossum  wrote:
> 
> FWIW, as far as I can tell, a non-framework-build can't be used to build a 
> native macos app, at least not with py2app. 

That’s a limitation in the current version of py2app, but is something that 
could change if needed.

Ronald

—

Twitter: @ronaldoussoren
Blog: https://blog.ronaldoussoren.net/

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


Re: [Pythonmac-SIG] Building plans .....

2020-03-12 Thread Berg, Stuart
(I haven’t been following this thread too closely, so sorry in advance if the 
following is not exactly what you’re looking for.)

FWIW, I’ve shipped .app bundles using conda and py2app for years.*  I don’t 
have time to write up a minimal example, but I can provide links to the scripts 
we use.

It’s a little bit of a hack, but it’s not complicated.


  1.  First, create a conda environment that contains your application and all 
of its dependencies.
  2.  Run py2app in “alias mode”[1]. Alias mode creates a mostly-empty bundle 
that merely links to an external python installation.  It’s intended for 
development, but we can exploit it for our purposes. On my project, we use a 
special setup.py script for this.[2]
  3.  Move the entire conda environment into the .app bundle directory.  
There’s no need to change the directory structure.
  4.  Since the .app bundle was pointing to that environment, you need to 
find/replace the internal links that py2app wrote within your .app bundle.  
Instead of pointing to the external conda environment, they should point to the 
now-internal environment (with relative paths, of course).  It amounts to a few 
sed commands and symlinks.[3]

Note: Although you moved the conda environment, there should (usually) be no 
need to replace any paths within the conda environment directory itself.  
Unless you’re doing something weird, most conda environments use purely 
relative links internally, and are thus fully relocatable.  For example, our 
application is based on the standard scientific python stack (numpy, pandas, 
skimage, etc.), with lots of other dependencies, too.  If it works for us, it 
probably works for most people.

If you want to see what the final bundle will look like, try downloading the 
current version of ilastik[4]. (Sorry, it’s a heavy download – it’s based on a 
big conda environment, with ~120 packages.)

Maybe there are better ways of doing this, but I settled on this method without 
really needing to understand exactly what py2app is really doing.  And plus, it 
leaves your conda environment completely intact.  For instance, you can inspect 
it with “conda list -p ilastik.app/Contents/ilastik-release”, or even install 
additional packages after-the-fact.

Best,
Stuart

*I don’t work on the ilastik project any more, but I’m pretty sure the current 
team still uses this procedure.

[1]: 
https://py2app.readthedocs.io/en/latest/tutorial.html#development-with-alias-mode
[2]: https://git.io/Jv6VG
[3]: https://git.io/Jv6Vl
[4]: https://www.ilastik.org/download.html



From: Pythonmac-SIG  
on behalf of Christopher Barker 
Date: Thursday, March 12, 2020 at 12:26 PM
To: Just van Rossum 
Cc: Jack Jansen , Pythonmac-Sig 
Subject: Re: [Pythonmac-SIG] Building plans .

On Wed, Mar 11, 2020 at 11:48 PM Just van Rossum 
mailto:justvanros...@gmail.com>> wrote:
FWIW, as far as I can tell, a non-framework-build can't be used to build a 
native macos app, at least not with py2app.

I'm pretty sure it can. We've moved to PyInstaller, which does work, and 
I'm'pretty sure that py2app can work with conda's non-Framework build.

and it's on conda-forge, so presumably it's worked for at least one person :-)

https://anaconda.org/conda-forge/py2app

I do recall some issues a while back that have presumably been resolved.

I ran into this while trying to build an app on github-actions, and had to 
resort to downloading and installing Python from 
python.org
 upon build. Which is wasteful, and in my eyes completely unnecessary.

https://github.com/actions/setup-python/issues/58

I'm sad to learn conda does the same as it renders its Python completely 
useless for my work.

Actually, perhaps conda would work for you :-) I'm not clear on what gitHub 
actions allows, but you can certainly use conda on, e.g. TravisCI with OS-X. 
I've only used it to run tests, but I can't see why you couldn't build a app 
that way.

By the way, it's great to "see" all you from back in the day -- this has been a 
very quiet list lately!

-CHB


--
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
https://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG


Re: [Pythonmac-SIG] Building plans .....

2020-03-12 Thread Christopher Barker
On Wed, Mar 11, 2020 at 11:48 PM Just van Rossum 
wrote:

> FWIW, as far as I can tell, a non-framework-build can't be used to build a
> native macos app, at least not with py2app.
>

I'm pretty sure it can. We've moved to PyInstaller, which does work, and
I'm'pretty sure that py2app can work with conda's non-Framework build.

and it's on conda-forge, so presumably it's worked for at least one person
:-)

https://anaconda.org/conda-forge/py2app

I do recall some issues a while back that have presumably been resolved.


> I ran into this while trying to build an app on github-actions, and had to
> resort to downloading and installing Python from python.org upon build.
> Which is wasteful, and in my eyes completely unnecessary.
>
> https://github.com/actions/setup-python/issues/58
>
> I'm sad to learn conda does the same as it renders its Python completely
> useless for my work.
>

Actually, perhaps conda would work for you :-) I'm not clear on what gitHub
actions allows, but you can certainly use conda on, e.g. TravisCI with
OS-X. I've only used it to run tests, but I can't see why you couldn't
build a app that way.

By the way, it's great to "see" all you from back in the day -- this has
been a very quiet list lately!

-CHB


-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
___
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
https://mail.python.org/mailman/listinfo/pythonmac-sig
unsubscribe: https://mail.python.org/mailman/options/Pythonmac-SIG