• Crash when launching python

    From Guenther Sohler@3:633/280.2 to All on Thu Sep 5 01:27:40 2024
    Hi,

    My "Project" is to integrate python support into OpenSCAD. It runs quite
    well, but
    there are still issues on MacOS. On My MacOS it works, but it crashes when
    I ship
    the DMG files.
    It looks very much like python is not able to find the "startup" python
    files and therefore crashes.

    Is it possible to turn on debugging and to display on the console, where python is loading files from ?


    Thank you

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From Stefan Ram@3:633/280.2 to All on Thu Sep 5 01:52:28 2024
    Guenther Sohler <guenther.sohler@gmail.com> wrote or quoted:
    Is it possible to turn on debugging and to display on the console, where >python is loading files from ?

    The "-v" flag? It's like a snitch for module loading. It'll spill
    the beans on where each module's coming from - whether it's a file
    or baked right into Python. Stack those "-v"s for the full 411.

    Now, if you're feeling extra Californian, you can set the
    "PYTHONVERBOSE" environment variable to some integer. It's like
    hitting the "-v" button multiple times, but with that laid-back
    West Coast vibe.

    Oh, and get this - "sys.settrace(tracefunc)" is like the
    ultimate stalker for your code. It lets you set up a trace
    function that'll tail your Python source code closer than
    paparazzi on Rodeo Drive. Perfect for when you wanna debug
    your code like you're solving a Hollywood mystery!



    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: Stefan Ram (3:633/280.2@fidonet)
  • From dn@3:633/280.2 to All on Thu Sep 5 05:25:13 2024
    On 5/09/24 03:27, Guenther Sohler via Python-list wrote:
    Hi,

    My "Project" is to integrate python support into OpenSCAD. It runs quite well, but
    there are still issues on MacOS. On My MacOS it works, but it crashes when
    I ship
    the DMG files.
    It looks very much like python is not able to find the "startup" python
    files and therefore crashes.

    Is it possible to turn on debugging and to display on the console, where python is loading files from ?


    (am not a Mac user)

    Starting with 'the basics', are you familiar with:
    5. Using Python on a Mac https://docs.python.org/3/using/mac.html
    (and the more general preceding sections)

    This doc likely includes mention of such parameters:
    1.2. Environment variables https://docs.python.org/3/using/cmdline.html#environment-variables

    Here is a library for programmatic manipulation:
    site — Site-specific configuration hook https://docs.python.org/3/library/site.html#module-site

    Please let us know how things progress...

    --
    Regards,
    =dn

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: DWM (3:633/280.2@fidonet)
  • From Barry Scott@3:633/280.2 to All on Thu Sep 5 05:48:21 2024


    On 4 Sep 2024, at 16:27, Guenther Sohler via Python-list =
    <python-list@python.org> wrote:
    =20
    Is it possible to turn on debugging and to display on the console, =
    where
    python is loading files from ?
    =20

    I assume you have a .app that is then packaged into a .dmg.

    It will be the .app that you need to either build with a debug version =
    of your code
    or after building the .app edit the debug code into it.

    Do you know that .app files are a tree of files?
    You can right-click on an .app in Finder and it will have a "Show =
    Package Context" option.

    Or using the terminal and you can:
    cd <appname>.app/Contents

    then have a look around.

    Beware that you cannot use print to stdout for a .app as its =
    stdin/stdout do not go anywhere useful.
    What I do is use code like this in the main function:

    sys.stdout =3D open( '/home/barry/debug.log', 'w', 1 )
    sys.stderr =3D sys.stdout=20

    Now you can use print(); look in the debug.log to see what happened.
    Also any tracebacks will end up in the debug.log.

    Barry


    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From Greg Ewing@3:633/280.2 to All on Thu Sep 5 11:25:08 2024
    On 5/09/24 7:48 am, Barry Scott wrote:
    Beware that you cannot use print to stdout for a .app as its stdin/stdout do not go anywhere useful.

    You can invoke the executable inside the package from the Terminal.

    Normally it's in the <appname>.app/Contents/MacOS subdirectory. The name varies, but there's usually just one executable file in there. Run that
    from a shell and you should see anything written to stdout or stderr.

    --
    Greg

    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)
  • From Barry@3:633/280.2 to All on Thu Sep 5 23:51:01 2024


    On 5 Sep 2024, at 02:32, Greg Ewing via Python-list <python-list@python.or=
    wrote:
    =20
    Normally it's in the <appname>.app/Contents/MacOS subdirectory. The name varies, but there's usually just one executable file in there. Run that
    from a shell and you should see anything written to stdout or stderr.

    I recall that does not always work for app code that expects the macOS optio= ns that are passed in when launching from GUI.

    Barry



    --- MBSE BBS v1.0.8.4 (Linux-x86_64)
    * Origin: ---:- FTN<->UseNet Gate -:--- (3:633/280.2@fidonet)