• Portable executable on OSX

    From wdamn@21:1/5 to All on Thu Oct 20 03:01:59 2022
    hi all,

    I would like to have a portable executable of python3 on OSX.

    I google a lot about it, but I could not find any solution.
    Am I missing something or is it simply not possible?

    thanks

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cameron Simpson@21:1/5 to wdamn on Fri Oct 21 07:53:45 2022
    On 20Oct2022 03:01, wdamn <wallacechemical@gmail.com> wrote:
    I would like to have a portable executable of python3 on OSX.

    I google a lot about it, but I could not find any solution.
    Am I missing something or is it simply not possible?

    I'm not sure what you mean. My Mac comes presupplied with Python 3, and
    I'd expect any modern Mac to be the same. So a python 3 programme should
    work on any Mac.

    If you mean: "how do I write a Python script to use python 3?" the usual approach is to start the script with a shebang line like this:

    #!/usr/bin/env python3

    On _any_ UNIX or UNIXlike system (OSX/MacOS is a BSD derived UNIX) this
    will run the script with your usual "python3" command if you invoke the
    script as a command.

    Cheers,
    Cameron Simpson <cs@cskk.id.au>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Thomas Passin@21:1/5 to Cameron Simpson on Thu Oct 20 17:48:34 2022
    "Portable executable" usually means that the program resides on
    removable media, like a USB stick. You can go to a computer, plug the
    stick in, and run the program. If it's Python, then the installation on
    the removable medium needs to set up all the paths and directories
    correctly before actually running Python. That would typically be done
    with batch files setting paths and environmental variables.

    I got this working for Python on Windows some years ago. Here is the
    setup batch file I used - it gets executed when the user types "pyth37":

    @echo off
    setlocal
    : Find effective drive for this file.
    set ed=%~d0
    path %ed%\python37\Scripts;%ed%\python37;%PATH%
    set PYTHONUSERBASE=%ed%\user\python
    set HOME=%ed%\user\python
    call python %*
    endlocal

    It might need to be be more complex on MacOS, but it gives you the idea.
    The odd-looking line "set ed=%~d0" is a Windows-specific way to get
    the drive of the command file being run.

    On 10/20/2022 4:53 PM, Cameron Simpson wrote:
    On 20Oct2022 03:01, wdamn <wallacechemical@gmail.com> wrote:
    I would like to have a portable executable of python3 on OSX.

    I google a lot about it, but I could not find any solution.
    Am I missing something or is it simply not possible?

    I'm not sure what you mean. My Mac comes presupplied with Python 3, and
    I'd expect any modern Mac to be the same. So a python 3 programme should
    work on any Mac.

    If you mean: "how do I write a Python script to use python 3?" the usual approach is to start the script with a shebang line like this:

        #!/usr/bin/env python3

    On _any_ UNIX or UNIXlike system (OSX/MacOS is a BSD derived UNIX) this
    will run the script with your usual "python3" command if you invoke the script as a command.

    Cheers,
    Cameron Simpson <cs@cskk.id.au>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Angelico@21:1/5 to Thomas Passin on Fri Oct 21 08:53:51 2022
    On Fri, 21 Oct 2022 at 08:50, Thomas Passin <list1@tompassin.net> wrote:

    "Portable executable" usually means that the program resides on
    removable media, like a USB stick. You can go to a computer, plug the
    stick in, and run the program. If it's Python, then the installation on
    the removable medium needs to set up all the paths and directories
    correctly before actually running Python. That would typically be done
    with batch files setting paths and environmental variables.

    I got this working for Python on Windows some years ago. Here is the
    setup batch file I used - it gets executed when the user types "pyth37":

    @echo off
    setlocal
    : Find effective drive for this file.
    set ed=%~d0
    path %ed%\python37\Scripts;%ed%\python37;%PATH%
    set PYTHONUSERBASE=%ed%\user\python
    set HOME=%ed%\user\python
    call python %*
    endlocal

    It might need to be be more complex on MacOS, but it gives you the idea.
    The odd-looking line "set ed=%~d0" is a Windows-specific way to get
    the drive of the command file being run.


    Basic idea looks sound. Might actually be _easier_ on OSX, since it's
    Unix-like and you should be able to depend on /bin/bash. The notation
    `dirname $0` should give you the path to the current script, from
    which everything else can be calculated.

    (Caveat: Never actually done this on a Mac, and only did cursory web
    searching to check that it wasn't a ridiculous idea.)

    ChrisA

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)